{"_id":"@iadvize-oss/store","_rev":"959-1d425a9e803504c193f03ef035bb5a33","name":"@iadvize-oss/store","dist-tags":{"NO-TICKET-init-store":"0.1.1-beta.0-canary-3af8852-1593804135256","dependabot-npm_and_yarn-packages-store-eslint-7.4.0":"0.1.1-beta.1-canary-1531df4-1593861440069","dependabot-npm_and_yarn-packages-store-rollup-2.19.0":"0.1.1-beta.1-canary-57cac7c-1593927167449","dependabot-npm_and_yarn-packages-store-rollup-2.20.0":"0.1.1-beta.1-canary-7904260-1594063600692","dependabot-npm_and_yarn-packages-store-types-jest-26.0.4":"0.1.1-beta.1-canary-f56cfed-1594069930240","dependabot-npm_and_yarn-packages-store-rollup-2.21.0":"0.1.1-beta.1-canary-d607ade-1594151271343","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-13.0.1":"0.1.1-beta.1-canary-88edb19-1594594071665","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-13.0.2":"0.1.1-beta.1-canary-e212c6b-1594683870301","dependabot-npm_and_yarn-packages-store-ts-jest-26.1.2":"0.1.1-beta.1-canary-33c8496-1594712079540","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-14.0.0":"0.1.1-beta.1-canary-53bc6f1-1594764933441","dependabot-npm_and_yarn-packages-store-lodash-4.17.19":"0.1.1-beta.1-canary-9cb04e0-1594888633620","dependabot/npm_and_yarn/packages/store/lodash-4.17.19":"0.1.1-beta.1-canary-379e9b2-1594888650110","dependabot-npm_and_yarn-packages-store-ts-jest-26.1.3":"0.1.1-beta.1-canary-e85d998-1594963539813","dependabot-npm_and_yarn-packages-store-typescript-3.9.7":"0.1.1-beta.1-canary-406844f-1594968886419","dependabot-npm_and_yarn-packages-store-rollup-2.22.0":"0.1.1-beta.1-canary-4bc65b5-1595052865085","dependabot-npm_and_yarn-packages-store-types-jest-26.0.5":"0.1.1-beta.1-canary-b59168a-1595089729543","dependabot-npm_and_yarn-packages-store-rollup-2.22.1":"0.1.1-beta.1-canary-5c15244-1595100182405","dependabot-npm_and_yarn-packages-store-eslint-7.5.0":"0.1.1-beta.1-canary-dfd0e87-1595100822165","dependabot-npm_and_yarn-packages-store-rollup-2.22.2":"0.1.1-beta.1-canary-6658d39-1595395296782","dependabot-npm_and_yarn-packages-store-types-jest-26.0.6":"0.1.1-beta.1-canary-94717e0-1595522681171","dependabot-npm_and_yarn-packages-store-rollup-2.23.0":"0.1.1-beta.1-canary-0db5dac-1595530793940","dependabot-npm_and_yarn-packages-store-types-jest-26.0.7":"0.1.1-beta.1-canary-7243d09-1595548899533","dependabot-npm_and_yarn-packages-store-ts-jest-26.1.4":"0.1.1-beta.1-canary-41a87b2-1595927100551","dependabot-npm_and_yarn-packages-store-jest-26.2.0":"0.1.1-beta.1-canary-f2bdef4-1596105915606","dependabot-npm_and_yarn-packages-store-jest-26.2.1":"0.1.1-beta.1-canary-8bac19e-1596109317428","dependabot-npm_and_yarn-packages-store-types-jest-26.0.8":"0.1.1-beta.1-canary-3bbd938-1596173576246","dependabot-npm_and_yarn-packages-store-eslint-7.6.0":"0.1.1-beta.1-canary-d816a04-1596238574602","dependabot-npm_and_yarn-packages-store-jest-26.2.2":"0.1.1-beta.1-canary-c01bf33-1596579274849","dependabot-npm_and_yarn-packages-store-types-jest-26.0.9":"0.1.1-beta.1-canary-ceb9e9c-1596672339865","dependabot-npm_and_yarn-packages-store-tslib-2.0.1":"0.1.1-beta.1-canary-8b35b3a-1596753627736","dependabot-npm_and_yarn-packages-store-rollup-plugin-typescript2-0.27.2":"0.1.1-beta.1-canary-1b01986-1596824996142","dependabot-npm_and_yarn-packages-store-rollup-2.23.1":"0.1.1-beta.1-canary-b7da9f2-1596830005960","dependabot-npm_and_yarn-packages-store-rollup-plugin-terser-7.0.0":"0.1.1-beta.1-canary-0fa5751-1597044771127","dependabot-npm_and_yarn-packages-store-typedoc-0.18.0":"0.1.1-beta.1-canary-c8a8e12-1597044976405","dependabot-npm_and_yarn-packages-store-jest-26.3.0":"0.1.1-beta.1-canary-9a115ff-1597059582601","dependabot-npm_and_yarn-packages-store-ts-jest-26.2.0":"0.1.1-beta.1-canary-e5008af-1597142548118","dependabot-npm_and_yarn-packages-store-jest-26.4.0":"0.1.1-beta.1-canary-3ea22b7-1597266324713","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-15.0.0":"0.1.1-beta.1-canary-52bd956-1597326377494","dependabot-npm_and_yarn-packages-store-rollup-2.24.0":"0.1.1-beta.1-canary-90db262-1597348990029","dependabot-npm_and_yarn-packages-store-rollup-2.25.0":"0.1.1-beta.1-canary-20c3df1-1597383024073","dependabot-npm_and_yarn-packages-store-eslint-7.7.0":"0.1.1-beta.1-canary-c00a01c-1597440824908","dependabot-npm_and_yarn-packages-store-types-jest-26.0.10":"0.1.1-beta.1-canary-a400ff8-1597448982395","dependabot-npm_and_yarn-packages-store-rollup-2.26.0":"0.1.1-beta.1-canary-e545cb2-1597467242331","dependabot-npm_and_yarn-packages-store-rollup-2.26.1":"0.1.1-beta.1-canary-ae0fe20-1597553515893","dependabot-npm_and_yarn-packages-store-rollup-2.26.2":"0.1.1-beta.1-canary-c1aa20e-1597556679855","dependabot-npm_and_yarn-packages-store-rollup-2.26.3":"0.1.1-beta.1-canary-b5fa4cc-1597702483719","dependabot-npm_and_yarn-packages-store-rollup-2.26.4":"0.1.1-beta.1-canary-84c57a8-1597820666754","dependabot-npm_and_yarn-packages-store-rollup-2.26.5":"0.1.1-beta.1-canary-52fae2c-1598078451504","dependabot-npm_and_yarn-packages-store-jest-26.4.2":"0.1.1-beta.1-canary-75ead24-1598101772693","dependabot-npm_and_yarn-packages-store-ts-jest-26.3.0":"0.1.1-beta.1-canary-43b0029-1598508136298","dependabot-npm_and_yarn-packages-store-typescript-4.0.2":"0.1.1-beta.1-canary-302cb2f-1598511379174","dependabot-npm_and_yarn-packages-store-rollup-2.26.6":"0.1.1-beta.1-canary-6199248-1598596356042","dependabot-npm_and_yarn-packages-store-typedoc-0.19.0":"0.1.1-beta.1-canary-4efe7cd-1598814242233","dependabot-npm_and_yarn-packages-store-rollup-2.26.8":"0.1.1-beta.1-canary-91d1219-1598814441744","dependabot-npm_and_yarn-packages-store-rollup-plugin-terser-7.0.1":"0.1.1-beta.1-canary-b727291-1598814833332","dependabot-npm_and_yarn-packages-store-types-jest-26.0.12":"0.1.1-beta.1-canary-93368f9-1598968509830","dependabot-npm_and_yarn-packages-store-eslint-7.8.0":"0.1.1-beta.1-canary-179958d-1598975321633","dependabot-npm_and_yarn-packages-store-rollup-2.26.9":"0.1.1-beta.1-canary-fecb9f9-1599035863913","dependabot-npm_and_yarn-packages-store-eslint-7.8.1":"0.1.1-beta.1-canary-6c430a7-1599067324562","dependabot-npm_and_yarn-packages-store-types-jest-26.0.13":"0.1.1-beta.1-canary-4eddecb-1599146632825","dependabot-npm_and_yarn-packages-store-rollup-plugin-terser-7.0.2":"0.1.1-beta.1-canary-d78862d-1599333660354","dependabot-npm_and_yarn-packages-store-typedoc-0.19.1":"0.1.1-beta.1-canary-978b682-1599339847878","dependabot-npm_and_yarn-packages-store-eslint-7.9.0":"0.1.1-beta.1-canary-196f9bf-1600038347756","dependabot-npm_and_yarn-packages-store-types-jest-26.0.14":"0.1.1-beta.1-canary-c1efd1d-1600350621428","dependabot-npm_and_yarn-packages-store-typescript-4.0.3":"0.1.1-beta.1-canary-fc3c95b-1600532456987","dependabot-npm_and_yarn-packages-store-ts-jest-26.4.0":"0.1.1-beta.1-canary-7885fd2-1600599363854","dependabot-npm_and_yarn-packages-store-typedoc-0.19.2":"0.1.1-beta.1-canary-a5f9f0f-1600670413494","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-15.1.0":"0.1.1-beta.1-canary-3dbacad-1600677845280","dependabot-npm_and_yarn-packages-store-rollup-plugin-typescript2-0.27.3":"0.1.1-beta.1-canary-bfa0287-1601096684300","dependabot-npm_and_yarn-packages-store-eslint-7.10.0":"0.1.1-beta.1-canary-fe7cb43-1601223881235","dependabot-npm_and_yarn-packages-store-ts-jest-26.4.1":"0.1.1-beta.1-canary-54573f3-1601461243537","dependabot-npm_and_yarn-packages-store-jest-26.5.0":"0.1.1-beta.1-canary-0733957-1601948726081","dependabot-npm_and_yarn-packages-store-jest-26.5.2":"0.1.1-beta.1-canary-381fbfd-1602084704750","dependabot-npm_and_yarn-packages-store-tslib-2.0.2":"0.1.1-beta.1-canary-3308ad9-1602101764632","dependabot-npm_and_yarn-packages-store-rollup-2.29.0":"0.1.1-beta.1-canary-3ec1053-1602243270932","dependabot-npm_and_yarn-packages-store-eslint-7.11.0":"0.1.1-beta.1-canary-ab9ac0e-1602418192166","dependabot-npm_and_yarn-packages-store-jest-26.5.3":"0.1.1-beta.1-canary-c96f4ba-1602448353930","dependabot-npm_and_yarn-packages-store-tslib-2.0.3":"0.1.1-beta.1-canary-0c1a65e-1602448552513","dependabot-npm_and_yarn-packages-store-rollup-2.30.0":"0.1.1-beta.1-canary-b5c481c-1602767725686","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-jest-1.2.0":"0.1.1-beta.1-canary-33e7e8f-1602797113994","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-2.1.1":"0.1.1-beta.1-canary-7b553a3-1602819032151","dependabot-npm_and_yarn-packages-store-rollup-2.32.0":"0.1.1-beta.1-canary-e710c02-1602919234464","dependabot-npm_and_yarn-packages-store-rollup-plugin-typescript2-0.28.0":"0.1.1-beta.1-canary-ce8d42e-1603093098559","dependabot-npm_and_yarn-packages-store-jest-26.6.0":"0.1.1-beta.1-canary-58e42d9-1603181165470","dependabot-npm_and_yarn-packages-store-types-jest-26.0.15":"0.1.1-beta.1-canary-a425c62-1603293285871","dependabot-npm_and_yarn-packages-store-rollup-2.32.1":"0.1.1-beta.1-canary-bf93fbd-1603391418573","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-2.1.2":"0.1.1-beta.1-canary-7b79242-1603546472380","dependabot-npm_and_yarn-packages-store-ts-jest-26.4.2":"0.1.1-beta.1-canary-239c3e5-1603634521222","dependabot-npm_and_yarn-packages-store-eslint-7.12.0":"0.1.1-beta.1-canary-80e2987-1603653130583","dependabot-npm_and_yarn-packages-store-jest-26.6.1":"0.1.1-beta.1-canary-fcbb76c-1603666226712","dependabot-npm_and_yarn-packages-store-ts-jest-26.4.3":"0.1.1-beta.1-canary-fb2522b-1603826835054","dependabot-npm_and_yarn-packages-store-typescript-4.0.5":"0.1.1-beta.1-canary-1c50815-1603839106313","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-16.0.0":"0.1.1-beta.1-canary-bd589fe-1603955408835","dependabot-npm_and_yarn-packages-store-rollup-plugin-typescript2-0.29.0":"0.1.1-beta.1-canary-73f3b6e-1604128189160","dependabot-npm_and_yarn-packages-store-rollup-2.33.0":"0.1.1-beta.1-canary-6f4bb5f-1604256854854","dependabot-npm_and_yarn-packages-store-rollup-2.33.1":"0.1.1-beta.1-canary-d69cdc0-1604309878676","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-2.1.3":"0.1.1-beta.1-canary-42c64ce-1604313682126","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-jest-1.2.1":"0.1.1-beta.1-canary-c238ba0-1604314075192","dependabot-npm_and_yarn-packages-store-eslint-7.12.1":"0.1.1-beta.1-canary-858fa64-1604321035138","dependabot-npm_and_yarn-packages-store-jest-26.6.2":"0.1.1-beta.1-canary-5250c51-1604322562496","dependabot-npm_and_yarn-packages-store-jest-26.6.3":"0.1.1-beta.1-canary-a1c04d2-1604480739664","dependabot-npm_and_yarn-packages-store-eslint-7.13.0":"0.1.1-beta.1-canary-1a49b13-1604731276512","NO-TICKET-remove-project":"0.1.1-beta.1-canary-c1f8c87-1604843150437","beta":"0.1.1-beta.2","NO-TICKET-store-v1":"0.1.1-beta.2-canary-9f897d5-1604844864243","dependabot-npm_and_yarn-packages-store-ts-jest-26.4.4":"1.0.0-canary-3978b38-1604847790524","dependabot-npm_and_yarn-packages-store-rollup-2.33.2":"1.0.0-canary-c0fec3f-1605482157044","dependabot-npm_and_yarn-packages-store-rollup-2.33.3":"1.0.0-canary-9aa4f57-1605687851778","dependabot-npm_and_yarn-packages-store-eslint-7.14.0":"1.0.0-canary-6f8acd7-1606086831199","dependabot-npm_and_yarn-packages-store-rollup-2.34.0":"1.0.0-canary-f400b25-1606691727983","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-17.0.0":"1.0.0-canary-9a000ac-1606808921917","dependabot-npm_and_yarn-packages-store-types-jest-26.0.16":"1.0.0-canary-c4cfce4-1606854771115","dependabot-npm_and_yarn-packages-store-rollup-2.34.1":"1.0.0-canary-89f8f42-1606984144060","dependabot-npm_and_yarn-packages-store-highlight.js-10.4.1":"1.0.0-canary-3f0a65a-1607112463965","dependabot-npm_and_yarn-packages-store-eslint-7.15.0":"1.0.0-canary-77484ad-1607156251673","dependabot-npm_and_yarn-packages-store-rollup-2.34.2":"1.0.0-canary-fd620a1-1607242686255","dependabot-npm_and_yarn-packages-store-types-jest-26.0.17":"1.0.0-canary-bc4cfca-1607421291219","dependabot-npm_and_yarn-packages-store-types-jest-26.0.18":"1.0.0-canary-496d087-1607461191330","dependabot-npm_and_yarn-packages-store-types-jest-26.0.19":"1.0.0-canary-6f52564-1607640035089","dependabot-npm_and_yarn-packages-store-rollup-2.35.0":"1.0.0-canary-97fc170-1607945149539","dependabot-npm_and_yarn-packages-store-rollup-2.35.1":"1.0.0-canary-905f286-1607957930160","dependabot-npm_and_yarn-packages-store-eslint-7.16.0":"1.0.0-canary-ca2ec15-1608592601058","dependabot-npm_and_yarn-packages-store-typedoc-0.20.0":"1.0.0-canary-c22ce68-1609181449264","dependabot-npm_and_yarn-packages-store-typedoc-0.20.1":"1.0.0-canary-4277c88-1609219419948","dependabot-npm_and_yarn-packages-store-typedoc-0.20.2":"1.0.0-canary-0e05c60-1609264778879","dependabot-npm_and_yarn-packages-store-typedoc-0.20.3":"1.0.0-canary-34f1387-1609272408823","dependabot-npm_and_yarn-packages-store-typedoc-0.20.4":"1.0.0-canary-bb2364b-1609286730276","dependabot-npm_and_yarn-packages-store-typedoc-0.20.5":"1.0.0-canary-f213f77-1609363135444","dependabot-npm_and_yarn-packages-store-typedoc-0.20.6":"1.0.0-canary-f7b8a66-1609465237193","dependabot-npm_and_yarn-packages-store-typedoc-0.20.7":"1.0.0-canary-0100fcd-1609492864296","dependabot-npm_and_yarn-packages-store-typedoc-0.20.8":"1.0.0-canary-0883853-1609541255340","dependabot-npm_and_yarn-packages-store-eslint-7.17.0":"1.0.0-canary-0363764-1609557109409","dependabot-npm_and_yarn-packages-store-typedoc-0.20.9":"1.0.0-canary-8b416cb-1609564185832","dependabot-npm_and_yarn-packages-store-typedoc-0.20.10":"1.0.0-canary-bbbcfdd-1609638823716","dependabot-npm_and_yarn-packages-store-typedoc-0.20.11":"1.0.0-canary-c986ed0-1609791552981","dependabot-npm_and_yarn-packages-store-typedoc-0.20.12":"1.0.0-canary-6c6d256-1609806743713","dependabot-npm_and_yarn-packages-store-rollup-2.36.0":"1.0.0-canary-e942ee3-1609888652343","dependabot-npm_and_yarn-packages-store-typedoc-0.20.13":"1.0.0-canary-e5c109d-1610061508520","dependabot/npm_and_yarn/packages/store/node-notifier-8.0.1":"1.0.0-canary-7ffa224-1610446103166","dependabot-npm_and_yarn-packages-store-node-notifier-8.0.1":"1.0.0-canary-b12bc0c-1610446212065","dependabot-npm_and_yarn-packages-store-tslib-2.1.0":"1.0.0-canary-3bef17e-1610446611431","dependabot-npm_and_yarn-packages-store-rollup-2.36.1":"1.0.0-canary-58daf38-1610447029596","dependabot-npm_and_yarn-packages-store-typedoc-0.20.14":"1.0.0-canary-ad4ad96-1610447299963","dependabot-npm_and_yarn-packages-store-typescript-4.1.3":"1.0.0-canary-e0b3f53-1610498582516","dependabot-npm_and_yarn-packages-store-eslint-7.18.0":"1.0.0-canary-2a72046-1610752204951","dependabot-npm_and_yarn-packages-store-typedoc-0.20.15":"1.0.0-canary-f92e403-1610820648277","dependabot-npm_and_yarn-packages-store-typedoc-0.20.16":"1.0.0-canary-429f445-1610962429004","dependabot-npm_and_yarn-packages-store-rollup-2.36.2":"1.0.0-canary-a86cc65-1610964044685","dependabot-npm_and_yarn-packages-store-rollup-2.37.0":"1.0.0-canary-d9b243f-1611045873380","dependabot-npm_and_yarn-packages-store-rollup-2.37.1":"1.0.0-canary-2ea8098-1611147839098","dependabot-npm_and_yarn-packages-store-typedoc-0.20.17":"1.0.0-canary-1bdfdfe-1611433257912","dependabot-npm_and_yarn-packages-store-typedoc-0.20.18":"1.0.0-canary-8954eab-1611530086839","dependabot-npm_and_yarn-packages-store-rollup-2.38.0":"1.0.0-canary-300cc04-1611565391346","dependabot-npm_and_yarn-packages-store-typedoc-0.20.19":"1.0.0-canary-147e9ee-1611586337970","dependabot-npm_and_yarn-packages-store-iadvize-oss-eslint-config-2.2.0":"1.0.0-canary-3a8e373-1611616541373","dependabot-npm_and_yarn-packages-store-rollup-2.38.1":"1.0.0-canary-3ae21d5-1611843821490","dependabot-npm_and_yarn-packages-store-eslint-7.19.0":"1.0.0-canary-9a48105-1612069270179","dependabot-npm_and_yarn-packages-store-rollup-2.38.2":"1.0.0-canary-5ac5dc3-1612079845273","dependabot-npm_and_yarn-packages-store-typedoc-0.20.20":"1.0.0-canary-c8b34bd-1612125375058","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.0":"1.0.0-canary-15c5be1-1612171126259","dependabot-npm_and_yarn-packages-store-rollup-2.38.3":"1.0.0-canary-58a302d-1612221376598","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-17.1.0":"1.0.0-canary-0caef8f-1612271125996","dependabot-npm_and_yarn-packages-store-rollup-2.38.4":"1.0.0-canary-15f8d3b-1612281582369","dependabot-npm_and_yarn-packages-store-rollup-2.38.5":"1.0.0-canary-1313a5d-1612531250097","dependabot-npm_and_yarn-packages-store-typedoc-0.20.21":"1.0.0-canary-a3b401a-1612548395102","dependabot-npm_and_yarn-packages-store-typedoc-0.20.22":"1.0.0-canary-f427017-1612628824209","dependabot-npm_and_yarn-packages-store-typedoc-0.20.23":"1.0.0-canary-0dc4175-1612775142842","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.1":"1.0.0-canary-10abdd0-1612873602980","dependabot-npm_and_yarn-packages-store-typescript-4.1.4":"1.0.0-canary-dfbda9e-1612912591368","dependabot-npm_and_yarn-packages-store-typescript-4.1.5":"1.0.0-canary-ea3a500-1612998945824","dependabot-npm_and_yarn-packages-store-typedoc-0.20.24":"1.0.0-canary-6ac1ae3-1613057570212","dependabot-npm_and_yarn-packages-store-rollup-2.39.0":"1.0.0-canary-34d7388-1613344475382","dependabot-npm_and_yarn-packages-store-typedoc-0.20.25":"1.0.0-canary-793c4ae-1613378779278","dependabot-npm_and_yarn-packages-store-eslint-7.20.0":"1.0.0-canary-3f9f1ac-1613391751158","dependabot-npm_and_yarn-packages-store-types-jest-26.0.20":"1.0.0-canary-892730b-1613395699386","dependabot-npm_and_yarn-packages-store-typedoc-0.20.26":"1.0.0-canary-481c081-1613791337573","dependabot-npm_and_yarn-packages-store-typedoc-0.20.27":"1.0.0-canary-0fd1a82-1613865690349","dependabot-npm_and_yarn-packages-store-rollup-plugin-typescript2-0.30.0":"1.0.0-canary-e829452-1613984333023","dependabot-npm_and_yarn-packages-store-rollup-plugin-multi-input-1.2.0":"1.0.0-canary-d70dd1d-1614001736375","NO-TICKET-Deps":"1.0.0-canary-f10fd64-1614002828692","NO-TICKET-StoreFixDocs":"1.0.0-canary-43621e5-1614014751171","dependabot-npm_and_yarn-packages-store-typedoc-0.20.28":"1.1.0-canary-2740533-1614045907300","dependabot-npm_and_yarn-packages-store-rollup-2.39.1":"1.1.0-canary-7ffecdc-1614074763892","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.2":"1.1.0-canary-6977b0b-1614118741398","dependabot-npm_and_yarn-packages-store-typescript-4.2.2":"1.1.0-canary-93e17ab-1614184334069","dependabot-npm_and_yarn-packages-store-rollup-2.40.0":"1.1.0-canary-b3aae1a-1614355844238","dependabot-npm_and_yarn-packages-store-eslint-7.21.0":"1.1.0-canary-85a0b17-1614589310125","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.3":"1.1.0-canary-c8f0e70-1614847061112","dependabot-npm_and_yarn-packages-store-typedoc-0.20.29":"1.1.0-canary-201b354-1614851177942","dependabot-npm_and_yarn-packages-store-typescript-4.2.3":"1.1.0-canary-fa2aa79-1614899903195","dependabot-npm_and_yarn-packages-store-typedoc-0.20.30":"1.1.0-canary-1ecd0ae-1615193548552","dependabot-npm_and_yarn-packages-store-rollup-2.41.0":"1.1.0-canary-15b5e29-1615301036537","dependabot-npm_and_yarn-packages-store-rollup-2.41.1":"1.1.0-canary-ba4ea6d-1615458999549","dependabot-npm_and_yarn-packages-store-typedoc-0.20.31":"1.1.0-canary-f40eae5-1615693922466","dependabot-npm_and_yarn-packages-store-rollup-2.41.2":"1.1.0-canary-3bf22cc-1615799778810","dependabot-npm_and_yarn-packages-store-eslint-7.22.0":"1.1.0-canary-3d25e74-1615800420662","dependabot-npm_and_yarn-packages-store-typedoc-0.20.32":"1.1.0-canary-850afe2-1615800819347","dependabot-npm_and_yarn-packages-store-rollup-2.41.3":"1.1.0-canary-44ff3c4-1615886606779","dependabot-npm_and_yarn-packages-store-rollup-2.41.4":"1.1.0-canary-62a30c6-1615906787265","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.4":"1.1.0-canary-7e1168e-1615987984527","dependabot-npm_and_yarn-packages-store-rollup-2.41.5":"1.1.0-canary-adcea0c-1616045280440","dependabot-npm_and_yarn-packages-store-types-jest-26.0.21":"1.1.0-canary-a17cbf7-1616063819474","dependabot-npm_and_yarn-packages-store-rollup-2.42.0":"1.1.0-canary-35f3055-1616142592265","dependabot-npm_and_yarn-packages-store-rollup-2.42.1":"1.1.0-canary-9b02e0c-1616369055186","dependabot-npm_and_yarn-packages-store-typedoc-0.20.33":"1.1.0-canary-025b1cc-1616404000766","dependabot-npm_and_yarn-packages-store-rollup-2.42.2":"1.1.0-canary-1371bcd-1616404620931","dependabot-npm_and_yarn-packages-store-rollup-2.42.3":"1.1.0-canary-f983f08-1616428389669","dependabot-npm_and_yarn-packages-store-rollup-2.42.4":"1.1.0-canary-751c1a4-1616663077877","dependabot-npm_and_yarn-packages-store-typedoc-0.20.34":"1.1.0-canary-53d6f16-1616663267891","dependabot-npm_and_yarn-packages-store-types-jest-26.0.22":"1.1.0-canary-ee2093c-1616695687737","dependabot-npm_and_yarn-packages-store-eslint-7.23.0":"1.1.0-canary-9be62ac-1616793453518","dependabot-npm_and_yarn-packages-store-rollup-2.43.0":"1.1.0-canary-d1938e2-1616823812069","dependabot-npm_and_yarn-packages-store-rollup-2.43.1":"1.1.0-canary-269053b-1616912553695","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-18.0.0":"1.1.0-canary-22ed9a6-1617008363456","dependabot-npm_and_yarn-packages-store-rollup-2.44.0":"1.1.0-canary-74d58f6-1617105479651","dependabot-npm_and_yarn-packages-store-typedoc-0.20.35":"1.1.0-canary-720b4ac-1617694405399","dependabot-npm_and_yarn-packages-store-tslib-2.2.0":"1.1.0-canary-a8c599f-1617697953962","dependabot-npm_and_yarn-packages-store-typescript-4.2.4":"1.1.0-canary-04a6624-1617833675244","dependabot-npm_and_yarn-packages-store-rollup-2.45.0":"1.1.0-canary-52ab90e-1617946100231","dependabot-npm_and_yarn-packages-store-rollup-2.45.1":"1.1.0-canary-e745550-1618265732891","dependabot-npm_and_yarn-packages-store-eslint-7.24.0":"1.1.0-canary-43e64cd-1618524862711","dependabot-npm_and_yarn-packages-store-rollup-2.45.2":"1.1.0-canary-f44badc-1618784025354","dependabot-npm_and_yarn-packages-store-typedoc-0.20.36":"1.1.0-canary-bb9f2a8-1619146233977","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.5":"1.1.0-canary-1d54d8f-1619164071224","dependabot-npm_and_yarn-packages-store-eslint-7.25.0":"1.1.0-canary-9c02e36-1619392987083","dependabot-npm_and_yarn-packages-store-types-jest-26.0.23":"1.1.0-canary-dac043b-1619552675331","dependabot-npm_and_yarn-packages-store-rollup-2.46.0":"1.1.0-canary-44a7887-1619683171224","dependabot-npm_and_yarn-packages-store-rollup-2.47.0":"1.1.0-canary-542a692-1620106048019","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-18.1.0":"1.1.0-canary-9e3d2d3-1620166550486","dependabot-npm_and_yarn-packages-store-ts-jest-26.5.6":"1.1.0-canary-739172b-1620252842400","dependabot-npm_and_yarn-packages-store-rollup-plugin-commonjs-19.0.0":"1.1.0-canary-11a2d7c-1620399290226","dependabot-npm_and_yarn-packages-store-eslint-7.26.0":"1.1.0-canary-91f2951-1620599066954","dependabot-npm_and_yarn-packages-store-rollup-2.48.0":"1.1.0-canary-6ceae53-1621206639549","dependabot-npm_and_yarn-packages-store-rollup-plugin-multi-input-1.3.0":"1.1.0-canary-15aae89-1621462509245","dependabot-npm_and_yarn-packages-store-rollup-2.49.0":"1.1.0-canary-230590b-1621812251395","dependabot-npm_and_yarn-packages-store-eslint-7.27.0":"1.1.0-canary-6b47da6-1621847774214","dependabot-npm_and_yarn-packages-store-jest-27.0.0":"1.1.0-canary-09f7513-1621934485417","dependabot-npm_and_yarn-packages-store-jest-27.0.1":"1.1.0-canary-623b193-1621938473734","dependabot-npm_and_yarn-packages-store-rollup-2.50.0":"1.1.0-canary-fdd2ddd-1621940616250","dependabot-npm_and_yarn-packages-store-rollup-2.50.1":"1.1.0-canary-a9aa0b4-1622031121648","dependabot-npm_and_yarn-packages-store-rollup-2.50.2":"1.1.0-canary-5c726ff-1622114876095","dependabot-npm_and_yarn-packages-store-rollup-plugin-multi-input-1.3.1":"1.1.0-canary-08d7c87-1622203140498","dependabot-npm_and_yarn-packages-store-rollup-2.50.3":"1.1.0-canary-0744e13-1622207966846","dependabot-npm_and_yarn-packages-store-rollup-2.50.4":"1.1.0-canary-b6301ee-1622263942276","dependabot-npm_and_yarn-packages-store-jest-27.0.2":"1.1.0-canary-509db69-1622292625339","dependabot-npm_and_yarn-packages-store-jest-27.0.3":"1.1.0-canary-1593446-1622312698242","dependabot-npm_and_yarn-packages-store-rollup-2.50.5":"1.1.0-canary-395eec6-1622414493520","NO-TICKET-DependenciesStore":"1.1.0-canary-3c5f93a-1622469718313","latest":"1.1.1","NO-TICKET-DependenciesFixStore":"1.1.1-canary-79c9348-1622475046540","dependabot-npm_and_yarn-packages-store-typescript-4.3.2":"1.1.1-canary-c6ed13b-1622499845898","dependabot/npm_and_yarn/packages/store/typescript-4.3.2":"1.1.1-canary-9479aff-1622538531622","NO-TICKET-test":"1.1.1-canary-e6cc5bb-1622552057967","dependabot/npm_and_yarn/packages/store/jest-27.0.4":"1.1.1-canary-be8acdc-1622793779431","dependabot/npm_and_yarn/packages/store/rollup-2.50.6":"1.1.1-canary-1ef0af5-1622793963125","dependabot/npm_and_yarn/packages/store/rollup-2.51.0":"1.1.1-canary-15a216a-1623055409393","dependabot/npm_and_yarn/packages/store/ts-jest-27.0.3":"1.1.1-canary-cfb3e0c-1623059323124","dependabot/npm_and_yarn/packages/store/eslint-7.28.0":"1.1.1-canary-de34657-1623070086232","dependabot/npm_and_yarn/packages/store/rollup-2.51.1":"1.1.1-canary-41b11c5-1623204125265","dependabot/npm_and_yarn/packages/store/tslib-2.3.0":"1.1.1-canary-3bc6e5c-1623664308588","dependabot/npm_and_yarn/packages/store/rollup-2.51.2":"1.1.1-canary-26896f2-1623687595587","dependabot/npm_and_yarn/packages/store/rollup-2.52.0":"1.1.1-canary-ef86f58-1623895388474","dependabot/npm_and_yarn/packages/store/typescript-4.3.3":"1.1.1-canary-e7a5de4-1623917845252","dependabot/npm_and_yarn/packages/store/typedoc-0.20.37":"1.1.1-canary-eb24f2e-1623918066671","dependabot/npm_and_yarn/packages/store/rollup-2.52.1":"1.1.1-canary-f7ec6d9-1623919731522","dependabot/npm_and_yarn/packages/store/typescript-4.3.4":"1.1.1-canary-d18ee20-1624003274563","dependabot/npm_and_yarn/packages/store/eslint-7.29.0":"1.1.1-canary-5c0017d-1624262553577","dependabot/npm_and_yarn/packages/store/typedoc-0.21.0":"1.1.1-canary-31aa68f-1624263448597","dependabot/npm_and_yarn/packages/store/rollup-2.52.2":"1.1.1-canary-33a4c11-1624358730494","dependabot/npm_and_yarn/packages/store/jest-27.0.5":"1.1.1-canary-8f98b03-1624413719138","dependabot/npm_and_yarn/packages/store/typedoc-0.21.2":"1.1.1-canary-f0af1ee-1624880367591","dependabot/npm_and_yarn/packages/store/rollup-2.52.3":"1.1.1-canary-29c10de-1624884299465","dependabot/npm_and_yarn/packages/store/jest-27.0.6":"1.1.1-canary-026e962-1624932103016","dependabot/npm_and_yarn/packages/store/rollup-2.52.4":"1.1.1-canary-a0c26e0-1625104982062","dependabot/npm_and_yarn/packages/store/typescript-4.3.5":"1.1.1-canary-c87127a-1625131293699","dependabot/npm_and_yarn/packages/store/rollup-2.52.6":"1.1.1-canary-64bebd5-1625154280714","dependabot/npm_and_yarn/packages/store/rollup-2.52.7":"1.1.1-canary-714cae9-1625471947816","dependabot/npm_and_yarn/packages/store/eslint-7.30.0":"1.1.1-canary-57dab38-1625472807345","dependabot/npm_and_yarn/packages/store/types/jest-26.0.24":"1.1.1-canary-dc8fb96-1625623309137","dependabot/npm_and_yarn/packages/store/rollup-2.52.8":"1.1.1-canary-fe80256-1625736427078","dependabot/npm_and_yarn/packages/store/rollup-2.53.1":"1.1.1-canary-c1c3e4a-1626055334303","dependabot/npm_and_yarn/packages/store/typedoc-0.21.4":"1.1.1-canary-4bf046d-1626082692818","dependabot/npm_and_yarn/packages/store/rollup-2.53.2":"1.1.1-canary-0868351-1626435344673","dependabot/npm_and_yarn/packages/store/eslint-7.31.0":"1.1.1-canary-6977596-1626660566315","dependabot/npm_and_yarn/packages/store/rollup-2.53.3":"1.1.1-canary-8c247e4-1626919318122","dependabot/npm_and_yarn/packages/store/ts-jest-27.0.4":"1.1.1-canary-7142b3e-1626942114395","dependabot/npm_and_yarn/packages/store/rollup-2.54.0":"1.1.1-canary-c1f0c3c-1627292766135","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-19.0.2":"1.1.1-canary-479d536-1627371654622","dependabot/npm_and_yarn/packages/store/rollup-2.55.0":"1.1.1-canary-2f8e72e-1627548240189","dependabot/npm_and_yarn/packages/store/rollup-2.55.1":"1.1.1-canary-4c7308e-1627610523533","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-20.0.0":"1.1.1-canary-d67a93d-1627869757476","dependabot/npm_and_yarn/packages/store/typedoc-0.21.5":"1.1.1-canary-d67a93d-1627869730106","dependabot/npm_and_yarn/packages/store/eslint-7.32.0":"1.1.1-canary-d67a93d-1627869826934","dependabot/npm_and_yarn/packages/store/rollup-2.56.0":"1.1.1-canary-d67a93d-1628215329590","dependabot/npm_and_yarn/packages/store/rollup-2.56.1":"1.1.1-canary-d67a93d-1628474541305","dependabot/npm_and_yarn/packages/store/rollup-2.56.2":"1.1.1-canary-d67a93d-1628647374373","dependabot/npm_and_yarn/packages/store/types/jest-27.0.0":"1.1.1-canary-d67a93d-1628647416742","dependabot/npm_and_yarn/packages/store/types/jest-27.0.1":"1.1.1-canary-d67a93d-1628820146865","dependabot/npm_and_yarn/packages/store/typedoc-0.21.6":"1.1.1-canary-d67a93d-1629424924912","dependabot/npm_and_yarn/packages/store/rollup-2.56.3":"1.1.1-canary-d67a93d-1629770527825","dependabot/npm_and_yarn/packages/store/typedoc-0.21.9":"1.1.1-canary-d67a93d-1630288992072","dependabot/npm_and_yarn/packages/store/typedoc-0.22.3":"1.1.1-canary-d67a93d-1631498536717","dependabot/npm_and_yarn/packages/store/typedoc-0.22.4":"1.1.1-canary-d67a93d-1632103335135","dependabot/npm_and_yarn/packages/store/types/jest-27.0.2":"1.1.1-canary-d67a93d-1632276172025","dependabot/npm_and_yarn/packages/store/rollup-2.57.0":"1.1.1-canary-d67a93d-1632362590782","dependabot/npm_and_yarn/packages/store/typedoc-0.22.5":"1.1.1-canary-d67a93d-1633313104910","dependabot/npm_and_yarn/packages/store/rollup-2.58.0":"1.1.1-canary-d67a93d-1633313170273","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-21.0.0":"1.1.1-canary-d67a93d-1633313238263","dependabot/npm_and_yarn/packages/store/eslint-8.0.0":"1.1.1-canary-d67a93d-1633917874410","dependabot/npm_and_yarn/packages/store/eslint-8.0.1":"1.1.1-canary-d67a93d-1634263416385","dependabot/npm_and_yarn/packages/store/typedoc-0.22.6":"1.1.1-canary-d67a93d-1634522578034","dependabot/npm_and_yarn/packages/store/eslint-8.1.0":"1.1.1-canary-d67a93d-1635127385784","dependabot/npm_and_yarn/packages/store/typedoc-0.22.7":"1.1.1-canary-d67a93d-1635127483466","dependabot/npm_and_yarn/packages/store/rollup-2.58.3":"1.1.1-canary-d67a93d-1635213795404","dependabot/npm_and_yarn/packages/store/rollup-2.59.0":"1.1.1-canary-d67a93d-1635818556855","dependabot/npm_and_yarn/packages/store/eslint-8.2.0":"1.1.1-canary-d67a93d-1636337051787","dependabot/npm_and_yarn/packages/store/typedoc-0.22.8":"1.1.1-canary-d67a93d-1636337035855","dependabot/npm_and_yarn/packages/store/rollup-2.60.0":"1.1.1-canary-d67a93d-1636941741885","dependabot/npm_and_yarn/packages/store/typedoc-0.22.9":"1.1.1-canary-d67a93d-1636941809282","dependabot/npm_and_yarn/packages/store/types/jest-27.0.3":"1.1.1-canary-d67a93d-1637287414464","dependabot/npm_and_yarn/packages/store/eslint-8.3.0":"1.1.1-canary-d67a93d-1637546673364","dependabot/npm_and_yarn/packages/store/rollup-2.60.1":"1.1.1-canary-d67a93d-1637633032745","dependabot/npm_and_yarn/packages/store/rollup-2.60.2":"1.1.1-canary-d67a93d-1638324179129","dependabot/npm_and_yarn/packages/store/eslint-8.4.0":"1.1.1-canary-d67a93d-1638756271849","dependabot/npm_and_yarn/packages/store/eslint-8.4.1":"1.1.1-canary-d67a93d-1638842660136","dependabot/npm_and_yarn/packages/store/rollup-2.61.0":"1.1.1-canary-d67a93d-1639101819806","dependabot/npm_and_yarn/packages/store/rollup-2.61.1":"1.1.1-canary-d67a93d-1639360978527","dependabot/npm_and_yarn/packages/store/eslint-8.5.0":"1.1.1-canary-d67a93d-1639965825466","dependabot/npm_and_yarn/packages/store/rollup-2.62.0":"1.1.1-canary-d67a93d-1640570950160","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-21.0.1":"1.1.1-canary-f39ec38-1641482194561","dependabot/npm_and_yarn/packages/store/eslint-8.6.0":"1.1.1-canary-f39ec38-1641482193379","dependabot/npm_and_yarn/packages/store/rollup-2.63.0":"1.1.1-canary-f39ec38-1641482256591","dependabot/npm_and_yarn/packages/store/typedoc-0.22.10":"1.1.1-canary-f39ec38-1641482256234","dependabot/npm_and_yarn/packages/store/rollup-2.66.1":"1.1.1-canary-10271fc-1643709824511","dependabot/npm_and_yarn/packages/store/eslint-8.8.0":"1.1.1-canary-10271fc-1643709797463","dependabot/npm_and_yarn/packages/store/ansi-regex-5.0.1":"1.1.1-canary-76b1459-1644906996486","dependabot/npm_and_yarn/packages/store/types/jest-27.4.0":"1.1.1-canary-0c81dee-1644909277662","dependabot/npm_and_yarn/packages/store/hosted-git-info-2.8.9":"1.1.1-canary-08d62d2-1644909464446","dependabot/npm_and_yarn/packages/store/rollup-2.67.2":"1.1.1-canary-08d62d2-1644909528605","dependabot/npm_and_yarn/packages/store/typedoc-0.22.11":"1.1.1-canary-08d62d2-1644909527325","dependabot/npm_and_yarn/packages/store/eslint-8.10.0":"1.1.1-canary-08d62d2-1646128890920","dependabot/npm_and_yarn/packages/store/rollup-2.68.0":"1.1.1-canary-08d62d2-1646128924634","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-21.0.2":"1.1.1-canary-08d62d2-1646128993154","dependabot/npm_and_yarn/packages/store/typedoc-0.22.12":"1.1.1-canary-08d62d2-1646129026963","dependabot/npm_and_yarn/packages/store/types/jest-27.4.1":"1.1.1-canary-08d62d2-1646129008721","dependabot/npm_and_yarn/packages/store/minimist-1.2.6":"1.1.1-canary-08d62d2-1648344650694","dependabot/npm_and_yarn/packages/store/rollup-2.70.1":"1.1.1-canary-08d62d2-1648807400819","dependabot/npm_and_yarn/packages/store/typedoc-0.22.13":"1.1.1-canary-08d62d2-1648807382208","dependabot/npm_and_yarn/packages/store/rollup-2.71.1":"1.1.1-canary-08d62d2-1651399292964","dependabot/npm_and_yarn/packages/store/typedoc-0.22.15":"1.1.1-canary-08d62d2-1651399399898","dependabot/npm_and_yarn/packages/store/eslint-8.14.0":"1.1.1-canary-08d62d2-1651399434032","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-22.0.0":"1.1.1-canary-08d62d2-1651399454564","dependabot/npm_and_yarn/packages/store/typedoc-0.22.17":"1.1.1-canary-08d62d2-1654080673706","dependabot/npm_and_yarn/packages/store/rollup-2.75.4":"1.1.1-canary-08d62d2-1654080695183","dependabot/npm_and_yarn/packages/store/eslint-8.16.0":"1.1.1-canary-08d62d2-1654080746531","dependabot/npm_and_yarn/packages/store/typedoc-0.23.2":"1.1.1-canary-08d62d2-1656669712623","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-22.0.1":"1.1.1-canary-08d62d2-1656669728078","dependabot/npm_and_yarn/packages/store/eslint-8.18.0":"1.1.1-canary-08d62d2-1656669811670","dependabot/npm_and_yarn/packages/store/rollup-2.75.7":"1.1.1-canary-08d62d2-1656669823295","dependabot/npm_and_yarn/packages/store/terser-5.14.2":"1.1.1-canary-08d62d2-1658281566112","dependabot/npm_and_yarn/packages/store/typedoc-0.23.10":"1.1.1-canary-08d62d2-1659348081554","dependabot/npm_and_yarn/packages/store/eslint-8.21.0":"1.1.1-canary-08d62d2-1659348162304","dependabot/npm_and_yarn/packages/store/rollup-2.77.2":"1.1.1-canary-08d62d2-1659348187111","dependabot/npm_and_yarn/packages/store/rollup-2.79.0":"1.1.1-canary-08d62d2-1662026514683","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-22.0.2":"1.1.1-canary-08d62d2-1662026567494","dependabot/npm_and_yarn/packages/store/typedoc-0.23.13":"1.1.1-canary-08d62d2-1662026600440","dependabot/npm_and_yarn/packages/store/eslint-8.23.0":"1.1.1-canary-08d62d2-1662026583829","dependabot/npm_and_yarn/packages/store/eslint-8.24.0":"1.1.1-canary-08d62d2-1664618478727","dependabot/npm_and_yarn/packages/store/typedoc-0.23.15":"1.1.1-canary-08d62d2-1664618519286","dependabot/npm_and_yarn/packages/store/rollup-2.79.1":"1.1.1-canary-08d62d2-1664618506651","dependabot/npm_and_yarn/packages/store/eslint-8.26.0":"1.1.1-canary-08d62d2-1667296908891","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-23.0.2":"1.1.1-canary-08d62d2-1667296963164","dependabot/npm_and_yarn/packages/store/typedoc-0.23.19":"1.1.1-canary-08d62d2-1667296977305","dependabot/npm_and_yarn/packages/store/eslint-8.28.0":"1.1.1-canary-08d62d2-1669888874011","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-23.0.3":"1.1.1-canary-08d62d2-1669888930533","dependabot/npm_and_yarn/packages/store/typedoc-0.23.21":"1.1.1-canary-08d62d2-1669888962006","dependabot/npm_and_yarn/packages/store/eslint-8.31.0":"1.1.1-canary-08d62d2-1672567251540","dependabot/npm_and_yarn/packages/store/typedoc-0.23.23":"1.1.1-canary-08d62d2-1672567389564","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-24.0.0":"1.1.1-canary-08d62d2-1672567433421","dependabot/npm_and_yarn/packages/store/json5-and-tsconfig-paths-2.2.3":"1.1.1-canary-08d62d2-1672608187797","dependabot/npm_and_yarn/packages/store/json5-1.0.2":"1.1.1-canary-08d62d2-1673120756019","dependabot/npm_and_yarn/packages/store/rollup/plugin-commonjs-24.0.1":"1.1.1-canary-08d62d2-1675245719544","dependabot/npm_and_yarn/packages/store/typedoc-0.23.24":"1.1.1-canary-08d62d2-1675245753523","dependabot/npm_and_yarn/packages/store/eslint-8.33.0":"1.1.1-canary-08d62d2-1675246015945","dependabot/npm_and_yarn/packages/store/eslint-8.35.0":"1.1.1-canary-08d62d2-1677668266932","dependabot/npm_and_yarn/packages/store/typedoc-0.23.26":"1.1.1-canary-08d62d2-1677668371867","dependabot/npm_and_yarn/packages/store/minimist-1.2.8":"1.1.1-canary-08d62d2-1677988516446","dependabot/npm_and_yarn/packages/store/eslint-8.37.0":"1.1.1-canary-08d62d2-1680346625012","dependabot/npm_and_yarn/packages/store/typedoc-0.23.28":"1.1.1-canary-08d62d2-1680346698641"},"versions":{"0.0.0-canary-78e185b-1593792635481":{"name":"@iadvize-oss/store","version":"0.0.0-canary-78e185b-1593792635481","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.0.0-canary-78e185b-1593792635481","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ab325bc838595fc396438b0f095605811ab03aee","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.0.0-canary-78e185b-1593792635481.tgz","fileCount":7,"integrity":"sha512-tWKY6+qjzqYCw1hEiW5Mb1ONZLz9nneIXFUXcCEUoCy4pnyH3m4ihtxsWuWeMQfiu6eH+VxdN3ZMHlnRcAaDTQ==","signatures":[{"sig":"MEUCIEYWxxnK3XKFXeLSYczLtdlCyQBRr1lBJQ0Pd92brI9wAiEA91PHGbBBoof/BGhc99kDshrNk5agqKRDJy0lfc56hWk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2644,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/1iwCRA9TVsSAnZWagAAk2kP/3n8032i2WHAvOdFapVL\nB72XUrx78Q4KMwUcwSYKGpI5+NMVeCd8slQmXkATCHUlLmd1ymzSc7dpkvfn\nq/2f4z546BlmLDaiSmO1HPWzCfjQwHC59v5ER75/OP3F/HGGFZ8c5Cd9XaL0\n0HjjeUMPaAx5eKooXBS/pLKy22SO5Q/B/8SvbOfdb6BmsKDuMzO5dvHuei5D\nLcsfd2ax5YHhrHNRlLmmdQnxKhweJvk56e7UyQNETpO87fqklKZyuIfnWO93\n4DEfK1ejCf5iuFI7Waz38LixtvSkUnYtISLXwZxDaq66pk7oVJGsrby9J9Vn\npLW44BSfnQrneAnsrrZbILyzT9eHLQyu/vKkUsvz8NpOfAQori9pvNAWjMw6\niaiAjL4pOZtb2xtFRhMam5z29gDKcxOMId83RBzxc7Kph5Q/WjKGQ0bBO6oj\nXBkgM20RLDGjDE/J3iLeEdmd35QO/zwMMeElKi+0BORWeW9O4XptHABxpPsp\nv3cMQ46dFgQpdgWx9l5tQIUPR6u/pfr8H8SMivsT6OEcXegLJt0Zx5jh0O7H\nEMhhxfN1Ct+MULf2lEUEbbs81UYZ0D9i9Ab6Ax0+tVOXWL500KL6vAyPmKHU\nf7Tmxm7i0sGyoBXukY2a2gfMWSS8QNKD2R4fyZr6ZKqmpK7D10x77yplpu8g\nYs1s\r\n=FNZL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","typescript":"^3.8.2","@types/jest":"^25.1.3","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"0.0.4"},"_npmOperationalInternal":{"tmp":"tmp/store_0.0.0-canary-78e185b-1593792635481_1593792687985_0.3498431112931599","host":"s3://npm-registry-packages"}},"0.0.0-canary-78e185b-1593792638910":{"name":"@iadvize-oss/store","version":"0.0.0-canary-78e185b-1593792638910","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.0.0-canary-78e185b-1593792638910","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"03a198748ce251156678e35f6774791985b0a2ad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.0.0-canary-78e185b-1593792638910.tgz","fileCount":7,"integrity":"sha512-yFV6Ru6yg9s3iCl5YTVkOxbGaVcqJ8IHVv6VdirrKuI53IDcASGuQB59FMRn0qEOrVu6gCfr2t71I+cPzTP7OA==","signatures":[{"sig":"MEQCICdyEFSTsMYDgcznpjN/rJz4+Gh4HyULavyCF/IJ6SxfAiBIZ7hOelnzsB8E8i8TQS/o3rp4NjKj1JlxtnmHpOJiAQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2644,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/1i0CRA9TVsSAnZWagAA7I4P/A7aSI6u5Njv0dBeTHs8\n8DFigq9YHn8W0KVQ6WwIsHEqFW8DkBWR/nehKLFsJm/FObWnqOzzaU1SYigP\nDHPCMgNYSs+0qIokGq7S/H2v74JAndqGwJQK/cZDf6z3mf1jFg562l/whT8G\nUTeLHj3+BCXoTbFNGJ2tDCWC6uv4ARVfgp2nVYTGfpxGLX+kXGAiSVuPJdNU\ns1IgpUgkYuAjeLQqNZByhApTJLIMq7KHtkbRu0rH8cKDrYTKjEmPhe9y3BaG\nifunm1ZZfSeKmZXvo1HLEIuSXAPMvdaX3l6HPF+HIzfjVy1Tq2JsRs8icDGc\nlOD4AWazmRHfvTvgas5TcjfANWu70jBiTkUYT0HoFGsMRNniQ+j4VQid0hXB\nayyC1tROAZEV7Mgy7pJZHI8Zch4Yjoa271UBfoHk4rG0jHlc1dRJEGX/FDpY\nmABEd+groU/CphAMO5uqNHNGe577ncwKlUsgrzVWHk8nH1J8hJhNcjkvKMcO\nc3OJiFlqXPuZa1AUJNW4p+JnMD45xWpu5Nr4xq/vKUlptzGBfjYN8ERdpHJH\n59xBvZDZ8N9QoUTWV036T7Rtk+OByq8srqlbbXczLpagsXf5+cogh/YXu8Vm\n1b21M7++vVchDclMK/ReMTk3w50w8E7i14g9Vm0OdHJKArJ4u0dCfho5sbrR\n6+ik\r\n=AHuF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"Hello - 1\n=====\n\nThis is a test package\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","typescript":"^3.8.2","@types/jest":"^25.1.3","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"0.0.4"},"_npmOperationalInternal":{"tmp":"tmp/store_0.0.0-canary-78e185b-1593792638910_1593792691821_0.5157504200312462","host":"s3://npm-registry-packages"}},"0.0.0-canary-78e185b-1593792885775":{"name":"@iadvize-oss/store","version":"0.0.0-canary-78e185b-1593792885775","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.0.0-canary-78e185b-1593792885775","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"642571905436dbb5ca7b3f4f3394d695aeead2a3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.0.0-canary-78e185b-1593792885775.tgz","fileCount":7,"integrity":"sha512-aNc6i3+lcKByLT6tbhpq6AgEM+AcfEjSPkX4OYiv673eyaJ8ApcVJrZQtXMy2J9SRO2qf4iFPOd1GlbV+NurWw==","signatures":[{"sig":"MEUCIQDv/IO58GR4RkE6oHPAdlkpr1YzK4CHHxrzGdN2nwTUvwIgIiOUCOm3ntRcIgk/+qjXioc8wPIZITvU5g3xA2LoZFY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2644,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/1mfCRA9TVsSAnZWagAAF/YQAKNsyCQ71kpVvW+x3OhV\nrZTIrF2jcbkgMej4vovA0g+BmtcvLlQZ0FAOLPFpRAqsC4D9Srpja/H5KTRt\ngbKvGDWw87lK+qgj2PQhA4pq44XOf3GxDJjHEFflgDsIqkaTG4ws2MVQS4ud\nAYqQuByNxh3tx/a3G3Wma8Bo0gwFIIqEwKM4yWjgmofn4XOIHjty0hKm0o1e\nCIUAUUonEza6NAWctXdTfeE/KqJT2anhOKBZWIBnIrLTPaIuQvh7XDfbn5/l\nQKLqUQDSZv8gum47rell7OCDE2eO6lhIBmfAPq/Jn4bNg8GaRLv7PZaaFvVW\nigP8ztvZmcZjLik9IF6Dx/mb0QnlOkOhAqzd7ZjHRtk1oYuLuK6VZqTqc53g\nYitjDL4bZKsL7ryw5xLo7Nn5mOSOo0ON/a1Qzvobef2V7eQ/bohL10vTyIgV\nA3cM2pNvRB28icUASzs5KgLTt/cU2kuFyWF9sFe8t1AtH46Ktv256O/gCH3p\n52E6i5Jh8eFIdrxvcqgtsqGdNvdkT3veLMzXq/mIev96gCA+MNs7hfHNC/Yx\nWvbd2lzCesTqCpgT5eQrPJyK6AsBjgHMYdD8ghOTuxwY+YMuFvWQ81gJrwpl\nEfisme1MFjQr/IRagaNyC6Ap2CFTMrSf/Gg5r80krrz8VQeUu5KHUP1lqLG+\nPLv8\r\n=0bpW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"Hello - 1\n=====\n\nThis is a test package\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","typescript":"^3.8.2","@types/jest":"^25.1.3","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"0.0.4"},"_npmOperationalInternal":{"tmp":"tmp/store_0.0.0-canary-78e185b-1593792885775_1593792926759_0.9619107281315031","host":"s3://npm-registry-packages"}},"0.0.0-canary-13f6145-1593794403652":{"name":"@iadvize-oss/store","version":"0.0.0-canary-13f6145-1593794403652","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.0.0-canary-13f6145-1593794403652","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"969f3edc6de779d7b12b590103c6df96a5190382","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.0.0-canary-13f6145-1593794403652.tgz","fileCount":7,"integrity":"sha512-Ka4B3AUv1/qCBdyOne5B60/5wWaa1sW9MUDuN/JnZIyP6bkx/CbUS4VG6Wy+ANrpgX1viU4+5NdrPS5CqQxE6w==","signatures":[{"sig":"MEUCIBwkgNv1gxlw+Z4AHdE+TFcas6aIe4ibrRDJ96/E7jxxAiEAg9j8X6zyWR/xAE9w0wxcpjKB9N4aMG1COM+7jVU6z+8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1892,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/1+YCRA9TVsSAnZWagAApnYQAKOeio3PdCZfDSWggFhh\nTlDkeH2MvWQMFYQjtUbXZD/96NxnecIlJX9wS7Qm9ClRcn8rrMBU1Z8dJwVU\nXpUD2PdqWu4FiysSX7dn7qOySMo9i0UPF/qwgeW402Q7bcqqmW8P80gQyZEG\n7dOxVJ4tmrhNu7etdHxvhceUWSpvJ3bzCg/hiCc6oa0TPl3KBYHfPLuicMzI\nrbrubQKWr4ddPHFFlygHmFlJw9UPTrxL9Yc2H5s6/ehPtqiMOUR8MO7ndS5v\nCXweCw8A9+FCNtIGDrLJu/J5ntB7kxKvxejqkXT6V4fGpiouc1YJ3Gz2pIXp\nbaBJrpxuVmQmNvAhV15gasNUjIscxYtki1/BW6Q533dBfeNhOEQkIp/3dCLj\na/ViY7/Tw/ABTGO2m5g+Zqco7DzHxYxFbcBqI+3rYmXoxDw0xbSutwXDCn3P\nhW8ieHaxmupOIwxgF80TOz5mP3cH8l36N1a74puRAHt0LS3QFaXe1b0YVlVN\n9oS4Nk0L3u6qOVQ6s15U3MP+bzfa6DzdF/CY77gLWrN6fFweNteAqu3NTCHl\niNcysRsWpwVgyROAM27ci82M8TmXruGG6/jv4sLLhPdHgR4gvzB2dAOQw+xG\ngd3yB2cqxZ7/U/pv8E3RI8jLgb3OwLTcCqPShQVMPqY/FziqtjUCraucJtbX\nWK0j\r\n=vLsU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"Hello - 1\n=====\n\nThis is a test package\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.0.0-canary-13f6145-1593794403652_1593794456001_0.4506891016619512","host":"s3://npm-registry-packages"}},"0.1.0":{"name":"@iadvize-oss/store","version":"0.1.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.0","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e749269c398850684e4acfc107facb33cd20f86e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.0.tgz","fileCount":7,"integrity":"sha512-f64rskJ37PoKG+/tAjbjFxPnftGKo3mxNFlvc6VZ+Urd3XW+DtEZyrCmR9w5WgosmlVwdbx3tuWLQ9kDX3GpmA==","signatures":[{"sig":"MEUCIQCtz0hALRFEsERo//PHhOezcaZGrLKA/nMJqr0L4/aHJgIgDatUSmaGWqXWEl9oQVJIBAt6iT/hNwaFi0Yx60XPWjU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1874,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/2AkCRA9TVsSAnZWagAABsIP/idgN4T5fy7PfXey8u8L\novfzjC2YJuuugcwAeU54786N7oAn+XYS0wJn/7MEmZERldFnDbBh6O+GxzDa\nWVQOoC0WJyWZfalB9iXgXqRqsdR/KhC8NCcQVut/3XwlFUKdIOVQjv4u1qUS\no+BOug/pHHw3RidHNNtJF3Sqx8lQ0VRdksoLGwXKhBX1fY8N47Uupr7gA6In\nWvp6pFP1A66DenWGqwJIWhpyDD5cSr6cJEzcRQ728P2LZDwZZPtt5pT2Lqrr\n4G67c0Cvymc9ZL+ZIRZYTGwJKS2t3LROsDCxlwQnZGdvMQdr5Xhwd4lv2XO9\nzMnzdHABU9Gn/jvGFsT+l8KmywYsAHB3oZNOCleYGiRJI4vis9m6MGSYzDvL\nhCU7pqjFNKQQRM8IF90lOzOU0N/Ilwjgi3l+ox10lLqNB9JfjeDtiPKM3hRb\nnwqSzhXNykpkf4LiIehvau9cpqEoh63E5xG+z1k4CBpewDsm77NgQfhxZJLK\nzTyC2ZLm5h8ikRsOKEVOWXNcmR1CsvuyCR3ypMA4e5DInc1Y1ctaF2gXZNAi\nrEmVXiXJsTuPSL8K7gKNKr29FB+ARw/lzhu+uc0m3K3+kgeC2EORgfg7PYIl\nbk63bntL4Wo3S/reo2T7wXWkFuSgDP0oBt+bxp2f958O3ep940u4106A9kzQ\nIWQC\r\n=7Q1Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.0_1593794596303_0.9280192088559447","host":"s3://npm-registry-packages"}},"0.1.0-canary-a6c5fa6-1593796920106":{"name":"@iadvize-oss/store","version":"0.1.0-canary-a6c5fa6-1593796920106","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.0-canary-a6c5fa6-1593796920106","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a4fead0729107aef60def0a4638c66def7a7217f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.0-canary-a6c5fa6-1593796920106.tgz","fileCount":9,"integrity":"sha512-A0MLuRrqU7Oplg3xa7xoYKQiMBC8xh9G2CQX/J0ezESYdhXwv2xgjNAKh9M1GwqAac/prsWX9CdQZDz8WIFkNA==","signatures":[{"sig":"MEUCIQDSSmuWyLZLe54VZdNGXsGJkg/zz74+osnOxhdMysSzpAIgdWxh3YSM5XwDb+Jh5BAqhcAPxUT8LAasEYsVTGkYkvk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/2lhCRA9TVsSAnZWagAAfKcP/1lLVuomUEdWDsEAMHsk\nem28toEgcyhxFRlbirFoKwBHLklzYboNDD++mDa1k14EKj+1ZRPUBoDLr/19\n1J0bjrin7UKVZhwzyR9tRVk22BqkeFsU6FTiO+D0wXsl0VFlprJh+T/0vRdF\nxt+ekPeuPzIPTPI3arxdZRu6X+0MxWrjb3+ppvv9/BCMLZ2bb9sF8CRkMw5v\n3qKzaGwMJcngdCnmduqNQy3+1D2cpZUc6LSa0PO6Y3mO0tzNalXuxNgLL7bQ\nE05ssDWJhBzJfmb4mAZhC6bss9bKxNSWCB21YJY6uc45Mnti8A1VLvDkTMW4\nJcRN+JL/AVPrg/qvHlq5ebCTWdFSdNLBtvYlRWX1/asB0tCNHHTR9MV5AOSZ\nlKSIjOOpsOvE6UY2x9+kTFeUGRCHtWwu/QLpWT7Jxz2thFkHesEHh0hzKl4m\nB9h72gFZinPmInVJ1Sy53FSV8SEZ7TJAo2E3E2F0A6fUK0RWcpxaqwQNLeCh\ng50PE2Uz8OgD0iYKPXXwrMG3mjMOhgkguK5Dii1JdmY2UFSMWEEMiiDz09T1\njqiKXIA0u4aNeKR18ozwegdyavI2r5SWUBrSlRmBr7pWEEtbNQfy3q/Y+5+l\nTW+qK4yM5CeD3PK6OPI95OT+10fxLuvy2HgAp4p5bqRagasK9Uu5t2csgIGb\nwJzz\r\n=Vmqt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.0-canary-a6c5fa6-1593796920106_1593796961269_0.698841474069313","host":"s3://npm-registry-packages"}},"0.1.0-canary-a6c5fa6-1593796920964":{"name":"@iadvize-oss/store","version":"0.1.0-canary-a6c5fa6-1593796920964","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.0-canary-a6c5fa6-1593796920964","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"26e234c82455cbf337cb257f67f637061b8269a0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.0-canary-a6c5fa6-1593796920964.tgz","fileCount":9,"integrity":"sha512-c2WLlXe9gMwB1JPUipUyTgjATCeU0F0/ZWVRdCLDJNZ/H5va49lfRquAjxLcW+tJDCilRZpTFdDrtvn5B1xAOg==","signatures":[{"sig":"MEQCIEKIMIEKlAKukAY960rLsow49YJIsO1QoeCeS3fPU+eVAiAVyabhS4Nt0PX7m3NJS6LoCMx+tuw2Ryp1/XzEBJKolA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/2lqCRA9TVsSAnZWagAAMeAP/ijzatQgpiDutpDbd3Vs\n+FfyG/cUtRAIExFoqKca9rm+dsC21cy5G+RmFqGQT6jUuWmn345A8qHwA+I7\nCgNk++wFXdHe+2ywcscB4U0Yu4QfjziMAUOdTNX/0ZAsiWy23MuBBmKHKQX1\nYkHTu2Bf2OS80ZBQJ2dhKKdCFd28QdeKeguBam02qLAGIB+vVFD51O3PdPZa\n02NvfuvtrMnC0I9boFoBHN/rjgbXVERIK6qR7/fxaYa2NHMPrXjmtG7T8anP\nyScOnfRkurA9S+PNbXfuiPiOYl+MUFwZQgLti5c35pluU1wBGormWZCUx7Eg\nrM1FUz2At6CxB4TVgiBR/bxn5oyIQEy0d7eCfxjxlrsfXstRkmbm5BWob6O7\n0h87o4ergHLIvJnL7Kow8AaHgKozqDlbOa3a4SLXAPB22FqLUGKoqvzKHHvw\nwf/tZ1m9yHrfptbeaF6pr2owgMm44UqpjPuWoWLVtzNU2r+XPehKQyGYmIf5\nLGZyEgzF/FkzSEceUj9p/v3G4UKLak5GMHYZd+0gL1D97B1esd7A86X7HXTe\nZECgr+pan/GqfyFJ+mkC8BIoWE5wd597muwSZstn1WyOCwlS2ECA5ex/QV4s\nz4IpRUBFNGEwGzGrhDzV0HOtsF8jimx1hy6fIiZsUWSNhO/apKMJZWSYnSMv\nQqlF\r\n=BwHf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.0-canary-a6c5fa6-1593796920964_1593796969554_0.01626490586890128","host":"s3://npm-registry-packages"}},"0.1.1-beta.0":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c11374180c75836924c5e20bf8fa4a3a77203351","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0.tgz","fileCount":9,"integrity":"sha512-78u6C+CsDETSLQcwvV69UibXoJjYN0Aao4rHb1203lrP0npI6VnyIb2PysS+bXEUqJ+m4j/0mRJJ0weTQi1tTA==","signatures":[{"sig":"MEUCIQCY2irS/kGVCGsLd6CPI0ApaiYPkjUfLntF1qGxZVcNPQIgRN+jClpDm8fDGCyC9+RVUh2pCT6HTP1gDDhm33MA6B0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25643,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/2pLCRA9TVsSAnZWagAAVQYP/R+68XjzwwBXade+lmT4\nF3hAf14jdyNuFiLRW/IfbnXU0KtcA9zZBl9acHsUz8rv3vDj+ytdAK0c/SCL\nVJ3aWueYvaGU3VQBjirdZheuKU8Qq5pZnkcBQbhJ3jmyYDnaWXFY0T5zLREU\nPzNn5t3KziW3Tjvph1ciGqXBJWlk1g1EkNiqc1Ac3bs8cT7BXHrci+r+Hgpd\nzMLys35/gOsQ4AtbqM7MLmv8ft+VBq0NZY2se0WPi1/FxONZfu16VO6KiWuq\noEbPibJvfaxOCS0ZbhvY/L6X/DkLAoVm4AaK4fNNnb9Wx/lsWje7mSlCSU7g\nktHivvYsT5K96wRDVyJH/39va9VUj8ZGq0BKb/+9nkvOQeonHFHO/PfC4ZDK\n3scN+O/+Sxx4mNF4oT06fE4SDD09IvHbt/W5lKVoeQkmUL8kocezVzvNGn5y\npa0S7gQZF3Lmz1w8aLj9cotbtPFuUVomXi0qX332AhiH6hgnZmZZHDpdB13Z\nMuDh6WS1fsnOi6GpmCdTuot4qhRfkIlkpexQRAago23ylu7JtXfFZh/fcWbq\nFb3V3YLYhHohKKm1EGBWNbcM2RWq1ofHgdMyNNeK0uPntcJzjFAYcEG404TN\nTkdtX8uoG9HOwMTc9Wk6dSeUryrYz4gSQ9ti2+Gl4asnSRQJHOAPd0cUFW/r\nYlEB\r\n=FPIW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0_1593797195266_0.0725759182942074","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-73de7a8-1593798188999":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-73de7a8-1593798188999","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-73de7a8-1593798188999","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4fd953243df8301615e1b12317cd850281fb688f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-73de7a8-1593798188999.tgz","fileCount":7,"integrity":"sha512-GArMUCAghGo5vIn9nhxAjT9Bmv29LbjQXkt2dZabuGOMUe8GHWITZV0dusey4Xn4nLJTPEm0VyNwWG8jNqIJAg==","signatures":[{"sig":"MEUCICii67h8QUjcsOLu7+ZOIHMYdeOuppYHy2KACwfodmLmAiEAsOXwVfPk3c7w4DTgVrRNJ7ZPyjz93fkcsC7O9nzeXoM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25648,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/25ZCRA9TVsSAnZWagAA7MMQAJl5/hlZDyZ1ca7OSHAY\nKbl0TX8IplIxVTQBoUj0AILAV2NKBgu4XicdRrbimf+iP35DlbY3TUwHeDp4\nfELtowE9rvMNqgZXl0FjLVgvb6Lv5hao1YKBVMCyZTJ34IwVB/aybsNY3oC4\nFcjJ+Ty8eReHdLJbEdz64KhLT1/qcGrQBTXL26XBBql6LNaZ52KvOX6iKDMf\n2bT/fLMk4kZxuEdYTqFCPp/iWhRztWvV89x6GzoKX9mPhf+cTSK9XudI+gaS\nhC6XJ41TQOm5YgwnX/LfS8fGlFCOHW/kUnSy9jSlwbDRtv3Ht2CC3//Xv4bx\nQt2NenMjrFBmt9MOj+vXY2XOKGxR8cS3v1B9weX7kZ1PWheuprwfykzQs3EC\nqLoLbF4QJ6mN/X3VoiNxrII+mvz41i5O3MCk9PvJpnU0RhDl29dw0EQ8Kx93\nILamUDbLabKhn5xskO+veFHoWV/Cx1N3zjM6PTPUuTEbDqior3/mgAUtt73m\nkHEJP6P9rSdiPiF3PiU/4Zx2aqCRM0XA9dh/LerhmaHW5bNP834PyOaebxff\ngNdqF+rK4p53O7Op9rsnsLM4oOOV7nXy8Tcnk2yxnj0wxM45/GnEMCsB/UHw\nYHxaZmC6u/IK5uW7g6ps7zLnvQ6sWvFN4BVXAAzBT67TuSlPnIqJl+JYAnmp\nfcW5\r\n=V9W5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-73de7a8-1593798188999_1593798232962_0.15730312158461413","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-73de7a8-1593798226665":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-73de7a8-1593798226665","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-73de7a8-1593798226665","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"70530fbc6d0e4ae52ee811083903786035356a96","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-73de7a8-1593798226665.tgz","fileCount":7,"integrity":"sha512-9dFv2HD4mfr53GOGxKNvSC4iKIfFmXuRsVJq63QH3sNV17jUkDZymJEtN84HkfeImilJ7aevDfUQ4shSfnBw6A==","signatures":[{"sig":"MEYCIQDSppMgGe1OCZEzVTw/5mQ0D+IVSkq81U3CFQrJOtw0NwIhAI+f91uY5FBcXchdj2OkURHWSYP6e/t4YTXvC3Q6EArc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25648,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/25/CRA9TVsSAnZWagAA0fkQAI06/Ul1gahikU8GB7cM\nxXjCdSF7bcZAThNy1rEBFE1TEx/Fth+q3iJQoMpIjU178j7LsWxIZNLcFg4Q\nlguzIjp8b94UjEPiI2vI8KNKIOi4zv14a1/wJue2tVLXLVBi7C1RwvebCkpz\nIu0kH4+Q36sJs6LLsn6qBRC5Z5WMU70xoy0hx5vQHSaPWAMPNfuhd1ysPheO\n17XCWSJOtysnHYU6DT+fSlAcK39CDyEFIBXgirRNliM0JKWNaq0GxW50lcOD\nRv3UyDFxoj44LM+NvCfnCmsyIbPKRl329xGKZh3aiBL8wXDalbljmVFzGuHB\nW901Su7hq+Z8YzA7W1Oq7ha9sgbbcmUcOgeiUFVaPrqU7CaMW5JdWvT/6/u+\nO8pkBip2UvhSpVBQFCbHJaovgysuSGhL21UBK/+0Q3uCGNzZFsQTdgJQgEe6\nGan9ufrVd3bqrV1bm0wlR1CFn5aVB5bF6WVYZkRTHhKKgCRLVGJw2u4jzU8e\n47tc295ksCuV60B2H5YzO2rCHIwsHhdc6GTanELZGWxPZeYywqxSJmA9nrih\n/PJ0guk9O2mItyyITD/21B3pfGhoWtou0mpxtFfCS0zVPWV5whOcC1fO6Qke\nlADEX++tMAm+JI/cceaFSc4imC3sIUdVYeU+TOIgMumot+H5AAm8nm1SWggu\nK9PX\r\n=pp4D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-73de7a8-1593798226665_1593798270930_0.010648926869365916","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-74383ec-1593798750102":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-74383ec-1593798750102","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-74383ec-1593798750102","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"354d7033cfa226bb46999df05a5f3e9e42ec6d9b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-74383ec-1593798750102.tgz","fileCount":7,"integrity":"sha512-VPkC/OjMtUPKarNXG+OqAt6myR/Xhr8hE5oLUGvrsdIPHCjuzEgGmqAAkndSYfufsxzoUXzb5C1OSzzx3OLVCg==","signatures":[{"sig":"MEYCIQDLwMbVQ6tQhsOrOkzRzBukeBpSF6BP5BI6uZ0AdvPldgIhAOe7kjWmebnIQDpt8MtSV19MCa3yoE7T8IZF1yugfOMb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25648,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/3CJCRA9TVsSAnZWagAAoy8QAIHenDP9KLsZMUhMQ96Q\nsbKUmEYIQbRPk30W0OS+jaMfs1tQxCIT0+AqBwdZTeIM8qbsjgZS37eSuicG\nXSQ07rcvF/CnJnabA40ZDPxniIcBSd+SjjcxxZ60YSuSWVEJ/O6prhg3lZOL\n0T0KVsH6wHIOufyqpLDGFmnOIvfSic7HOSo420r7l44XI5s6igc/jKdtupH9\nF+oMkAeBG9V3mC1OeIwszfy3MJS1OPTbhw/lg55TKW7kXBE0ra4ZWHCwUr23\nv1nfVntYxuoaqPASo51hyWV7wPV/19H5SWS1f4YAPXdkFFt4p6+WTCZ9ons9\n+UKU6A6FLQASMLk3+razCGKWqpwNOIwQceT7RsmL4tJw2icy3On6dag9hyPY\ncK4K14vdvCHeyizTmcEGMahK2QxFKSD1KhedbNyn9EnFbcyYARmrryFn0Sb0\n/hgaLdX/AFejIeqBuPcL/B4Ph22mgafmLipyonmZp7Sh77lIUf8bkXL603Hh\nXdf2awOeL+9UVOej8TTg3ROKl8NjoMjZQbKWtog956tZiwWdx7TjzpaJXEzw\nCQXE3HBntfvs5Y79reuTCnYtdmo02D4UVI/Ibkd2ucraSM8H1GgRSNHon1rp\nZPUGDFvOHzF3SKgDneMCkiqIlPcHnPXige1GLYmPApz0utudkkeApDA0KvK0\nH80z\r\n=omq1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-74383ec-1593798750102_1593798792673_0.6308182735916321","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-6077dd6-1593799113386":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-6077dd6-1593799113386","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-6077dd6-1593799113386","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dbe0b739796e4de1b6fd491b6dc469292fc70d3f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-6077dd6-1593799113386.tgz","fileCount":7,"integrity":"sha512-KQzguEc7n7+RrtMZDO6DHT9mexi3XUTOrUPivq9UFZyGapqwyTtuETlN4IxpbpZXLzcwFCl0Yif+4fM6zK74Rw==","signatures":[{"sig":"MEYCIQCg/o6ojU6zb+jlz2byx7IF+VrXQtSGZydGzLzt+m+8GgIhAIBwpxE0Qh0ZiRQXioVYHZKXDlZSlfF+vWk7HYEbjGO0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25648,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/3IACRA9TVsSAnZWagAAOzIP/iGSAu1zIRLPxhbLgC/d\nRxxQTwYVc/SkxpfLo7k0VuRqJq3LCuIGe/Q/hMzBZFF7hTtGZCUcho5eMWjW\n7C1ARQaQw6xFSRT/3EobH99UHsGqEZ0wLgmiT24T5RbmWfgp7FN6DuRq+q09\ns34GygNden+q5WnWIZuhlQnrcVuQ6h22wGjWo17UTPKOMUkTnXAX5il7zALJ\n8sCNT8C4OCD96xe4YgZ3+XJ0a4IslX6UdSsT+Qo4kyu6pBOLWllu3XfaWx0f\nFQn26Pqb+wGYGJUv8LHbTXHtin0L+JFJbCSdhakuBojM2eTub6PBKUmN41SB\nEF6jFSaeKLGeYm1i1Z/OkWz4uME8oGFboVZ8i0m0u8g4BMNwyVjBDAkYWADu\n5AJqWOq/tcnJMzurdr7utrFCdNTmo93VEz++KhEXXv4jSHqNl62w0xqpebUF\nx7ASLtaukcgLYVDhGIv6mYBhWkyJZFXWFQvzO48Rl4JqZl1v5lXelkKY48LC\n+vmiwAJIef9GM0hvUczUfOuePdG3usgewn/ZroXC1S5s17eoREYL0ef4+duG\nCOKICMM+DhXChF6bP1tf3qBxM9hN8fBlaol2j9ApQppI1Ns9+I0eqCkueYtF\nc5m/2z0oxIKk21iRHsLde8zFXaF2K/Lv0YcBwguw4sQcubcToyc2uMrtSe1O\nenJt\r\n=DnxV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-6077dd6-1593799113386_1593799168209_0.7122261583025684","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-9567506-1593803816026":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-9567506-1593803816026","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-9567506-1593803816026","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"43308d82807a857bf1a6d6217e7b3938c895592e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-9567506-1593803816026.tgz","fileCount":7,"integrity":"sha512-QcPi5cWsHsNzfW34s1pdTSSu0N3nfVE8xh55csA58yuYbKTfZriUF+ZtJTLd2NHC1T26i4HvCpXSrnxsUOxeHw==","signatures":[{"sig":"MEQCIEZ+gXIM9up7/mrLlYr2B8oq+1nc9VuEm51E1aDPKusfAiAYNPJVhtcJywKn/StAYDj0BYEoMVhOJsMFZK7YralIQg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/4RQCRA9TVsSAnZWagAAsdUQAJAy7go7MOLx3nuBGqJc\ngOkdMTDz1C5PaqP7/lCrtC9tdnoIwrMrXUgk8bwz7sAVrjkaOYbkIC3JWDzE\nHRu5DXyQNHdtcPkG115w5Y05y3/sItZQkeokm9WTvPFzfk6jxxkMruVcA4Hm\nBuR7FSn06z+MPQEk055wuzhjS8gwey0Vo9RQHFumY71ID+prqJAkG0djRanQ\nQZqlnkPJsnUnERR0LB9+RQwljDe1avvj9bvQOfEsE6gN3lahFUY6C2c4s5Kf\nm5DvzElrbJkeXwulxVCMMWz5QdEbSnMx/UNKgYp+VHSGxRBJmrsKwCBiveFD\nlscIE7qiW/YylfvfIzfrYRe2x82DouCireMU51LaSRAJhnRIbG62MBgfEVS3\nLaXQ4k0FzRU7pp1FeUwM7zYeIpK8xy45sKOOofi0JAs8GcFDP6USCS3ufHzf\nx1vftgB+nua3NWE0Vw0VOXScflN1dzzx9li1i7v3RR7DmxUmYnDYkv3izEef\nG6fKkCjdx/YtNSql+0PTzGbSMnr0/DXValdoylF2omjmlUEqQepBgf6Pg8O4\nMQzMz+DpU8Jp2sYmnOMmXfvAwBuxXVq78t5Dhx5ErHndS3XoQm14WavAQjZ5\nIjbYw6QDS5q/KAuuB9qIHb1UJRLPW9CCUOxg1LsRM5SgyPLr9kvI3aSDooCF\naBwX\r\n=NRdZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-9567506-1593803816026_1593803856418_0.1984788927775396","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-3af8852-1593804133324":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-3af8852-1593804133324","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-3af8852-1593804133324","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"75225a8172f890e507b6620b68766c32a3ecfab3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-3af8852-1593804133324.tgz","fileCount":7,"integrity":"sha512-YDZPmIdtacZmo+OUXzxcq7Yj1laqlSs+fsG0UdQbequihZsRF1n9IJrCuPn51Uf7fiMO3oCm6+ZwINqKT5SBcg==","signatures":[{"sig":"MEYCIQC3+q4kAWjneq5V5jQCVl1t3cdHbKlqJ+NcmPLuBU9qIwIhAKR2oglbO999rtvSEamf/lkKKrZWVCMJVZI+mL7D2cY4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/4WPCRA9TVsSAnZWagAACisQAJwmPoySdbgZbEdSdp43\nsRSfmWw8p/1N+1H4bN777GRYdMVglInvYdEp9qjDx8RziMdCq20wdTT960pJ\neuemSz9RM+ubReGNaEkmfthSjCXofRVhwhMspnJ2dlR0oioUM3o8vJIQwC8a\nB9QuLdpVyuf/rmrkdHuFJzhSH4P2h6jdPiMyyN9lVwBdgRos+mDsjhryz7te\nlbX8fu8xo5tVWOL2Hs1kcd6gsGg3OyzSyhXiCmE+YiOZKFuqRodSjmpaZamn\nl7X9/0DoJwqkNyURRzlfw5l3N9htQAVAh1ojeuYW7vpS80v5edTA+IWTyQMZ\ncqywlvbW2l88pRBfGK8rMV/nfBLkbOrThq9Uw88Pc4cf01jeTNffqf8KKl3s\nFHqhIezn1LDQy44IcwylrBAlLutItyvABQcrijl9j+HMXT8Yai/FtKYhGfRF\n01MrCI5ZNIBQlutgdooGym10VKlnGfQjPsMo9kudi1/abJxctLY92u6VUe72\ns9fK4o7S57VSAx9oEMMux9HIVWKQxLgJ7o9LbLcIQVzFLGeuALxDHw+hFaCO\nJQqQLf7bvhO0N1rI0V2SRyFc82S5uy2E77KvFqIpdtNtM4haL3B0LJHpxfoE\nXndBtagq9N/vk24+BNcbW1wjIKABftIIwjEuRFJOns/I+421yYEzA8APpJcr\nF/44\r\n=A7Yc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-3af8852-1593804133324_1593804174702_0.4808350843696976","host":"s3://npm-registry-packages"}},"0.1.1-beta.0-canary-3af8852-1593804135256":{"name":"@iadvize-oss/store","version":"0.1.1-beta.0-canary-3af8852-1593804135256","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.0-canary-3af8852-1593804135256","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"812f7349067d099888f9fcb4d43518a8a75c67ff","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.0-canary-3af8852-1593804135256.tgz","fileCount":7,"integrity":"sha512-cvIl4xBsK+2iKmd4PNkdXrQ2NJTrF5/KIB01eos6utbyNXZlQDYIrHFrMBHfYcgK6ymmbLPYRWQgGkC6ex2+Cg==","signatures":[{"sig":"MEYCIQD/KU5SobQ+IXRZTTEDaWLWcuKNzbJK76b8VJMXxR1LmgIhAPOusL8bPSh6AsbxF/yxN4fS9LCMMS24faG3s4lhQFKr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/4WeCRA9TVsSAnZWagAAsdkP/3i6Nki1runxFVqwyJNF\n/LGd8FCKOZ1MA2yZzoggs2WN4N5LJzMbw1OweQMD2esL1tFsIJDnuj6Ff6NP\nlStahCKYzrzwHIGYne8r7UNfLanLBYMzy7/3Ncz93W2fGPEQG9iFTO5uLJm5\n6GD/l2rdG1D0o76lpBi9Gf3aOTXS6G3FQcnwgVDz0S3eAtiWX8TxwX3vyZWY\nQscDZJ0NDBS0jjXQivoRgzdmLQKkrYAxs9v+TgaawOEp9FygOhJ+unQRsYrK\nnMahG8+1jr8kxVVm1WcqrbDElyMEL4pU+xv8/g2e4/6elf7RjtNzH34b8erM\nsrPxHsrSSARWaaV9hE8JCXyQqzEL2545FTMdJ90KC4wpVPBgrk5lZAvkeRXs\nqljl7I1lhGlmHsuzWeCN2SMK6Cl9VPvD1nmy+EIvpGrsByNgqRxURUPkqJA8\nu94bIo5JprooBk/DGoq043fb0ZG5XLe/6Qq3i/+QNw5tV7HPLcSBiNTeuERI\n1WruET7DW38tUl7e1xb8kqBUps9jq21YfJjI7CSJxOQfQ/31cW3G8ljMD6ni\nGTdbKN4mWuJ4qcvXv5O/v76WPQK0NBaKozvJcdoj8+2fblOMXbBdKg0ieSCN\nBTGZiCWby/aTC9OwLMueYR7SJGFxfh/H8JYluWvsccvmneNZT0lxCQmsbf8x\n+cXp\r\n=rWcF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.0-canary-3af8852-1593804135256_1593804190474_0.36816222571436485","host":"s3://npm-registry-packages"}},"0.1.1-beta.1":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"675a5a4b0892c576d63990a1c5894982c24a20a3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1.tgz","fileCount":7,"integrity":"sha512-oyNh+aeW6PN/e83WQvaRdwZ6vctS63p7P+xoIZp/+ZOxo3AdtF1W9D9ctAZCG2mrhUbd5smoTGqcE2BpP2D9Dw==","signatures":[{"sig":"MEYCIQCIaSEdp8ugPYwkcncvIAkREHfCEzH6KWl5yr3+SzfmXAIhALeyBXXZbhhNltJCjXOx8/1E69+Nj2FWbNH1QVuGsbF2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25696,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/4cTCRA9TVsSAnZWagAAGUwQAJiUgK6T875tDm3J5W4A\nIHmCtvS5C0JKQKPscj2HXnS+qUBkldGBPydakbUmMSUnAcm105YyjW4FlkSL\nylfn9ogrEUJthybrzWaz6+IcueH4BAZuIFc0NfoNaQXlHIWFTgaq9zYETJKO\n0ZddHMjlp5SvGZiepXQFkWZxawN5mijsdBLCoNvqJ3jv5wWvYDKmlNKya72O\n1t6UPT7xFNBM0APUr0hoDFr8wCHx1+f7+sJ+jwB9gdcQWsTm4lVNVo7KVEkL\nr1Ea6Qjbm61g0X1/nWjrno2ub50TZ8nq4G7LtJ1z5BsShmA5FQBHjCaNu7Wd\nhVLfn8pNn/sF9Sv2/I2hvF0q02+OOF+FKv99JQWn3LFR3oolTRRfNRT1WC0x\nJN7vM9BEFNIEuI+lOf1bHvlO0Gmf7RDN80g+KPoKLmrDBLJ8dIgZm8atI3X/\nQNS01Ly1Lyut17tdcF/CjCI/DLj/CiX4eZAzH9tWZrp6cJnkPMS8QGaYIk+s\n9xyPDeFqrlxu3bHAoGq+NjdSjtWO/KsRryeVxi+4Yox3Ao/whX1inPXymj3D\n75j6gV43Jd7amywZbyfAcE3rqUs5BP3brI+Y6Gg8hA2JGsEZ3gueaY1Z6R2L\n7G9Yz5T9vKbRZ61ivoVPT+IUHpw7Rd7vpP7DDWc+owyIHxG1B65KjdTPmMPQ\nXXEY\r\n=csd5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1_1593804562994_0.8935487844830652","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1531df4-1593861446694":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1531df4-1593861446694","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1531df4-1593861446694","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"150567b7d00c61e14944b4ca5f326f7a62471f90","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1531df4-1593861446694.tgz","fileCount":7,"integrity":"sha512-Phnd5q6Gdn4ZxcuHMqfmz3LG+kArsOq0EQuHjlDnIfOJaaeouYpHWPkUx5wGRWG9QxfWEaIS3cQ4clYEyKDppw==","signatures":[{"sig":"MEUCIFbZQJyyCcrO5ziiKtn9TnpuWkWrwbfPNDgMNy4suBkPAiEAvQnnoGRKHVnKc+TGJ+9unbJKdGE4kJ/bA9Kcx/99GFg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAGV3CRA9TVsSAnZWagAAheIP/RbZx0T0QDQd1uch02IA\njgSPhfJIOiw5MBgOtgK7vv0NiEBWwyJvfFuiyE3p+/MydLZYkCNCfw6Dd4gH\nzEdpcWbY8zJB4d+PyoeRJE6S67PLvF1J2IN4z5owwdJ7m6eXOuvu/mkdUgKW\ndkN81EfrHkfDOkNRhOaeIw/JGfGKEEobd+IZ3eqVimJbVUkxHT4nsSP3Gg26\nsJ6XRUwS/MtOfOVrKg9e5lVVDE8/eNTwEt0mMO/lqLf5N50wKXKnw40apuVW\naWiU4/BCX3erDQ3R8Fdj5LGMcnJwlQfOn8Mq7PU39WAenzk8vHfZM13N5XcI\nL9UwEfa6+EwEKTqux/Y+n6xTv8s0LW3z9BZ+Q0IB94T15XEdcvRPqHhINFCf\nxBEUdO0Oz5wgn0822b1gMaMSHmEQyPRPv9J9t70jEYpKc6QRCUClwCQYiq5n\n4ELRTULI4O0VBRzpRmqid1mUr9OH3o99sFEcH0s34lHfJ4QqAxpuTv7+h5ME\ntKs7KftjN12LjebSGPm4bh5NepWe2QK1WQAyb3Z2d2L4AV51KopfT0xje43h\nkvFAiRZwAEAlE4o4cDHPVz9mH9oxlSqgr5m07Z7B+aH3VyvZYT1Dxi/8Fbwd\no1lkHv6oWR1nRBMZnz+M2e7ODzKofDpSHeoyl9ebRqV29/SAVWBH3GH1Qres\nnBHe\r\n=P1cN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1531df4-1593861446694_1593861495282_0.1570993774703402","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1531df4-1593861440069":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1531df4-1593861440069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1531df4-1593861440069","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7b95bc3bce4f62ae5e4247ebe6ecb91c177cf2d8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1531df4-1593861440069.tgz","fileCount":7,"integrity":"sha512-Anj2JRmZVGd4yxMUc+gI3Nz258/+6vGTxllyiOUfuM5pX8KsaONSlR7lHrs6VIpzkSVH5sf8jeiJTZghHqJkAQ==","signatures":[{"sig":"MEUCIQCBLIUAtxaF6gQBcElaIrPFCY8mgVzG8fz1y2glCjTPEgIgNuq7BFUjN4aWxEl3t8e6DYhPLwDZt0QSNVdjlT+k1ew=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAGWOCRA9TVsSAnZWagAALWgP/2l4fGexW4UAY5kAgBgA\nwJVN86tb2DRXqXF/tFc9CvxMMy9iFCTmwm5BFg59kgEtsue2HdPcPOhvZwIz\nCAQz4cDwi33rvidB2Daq9xKxurm3BqHuzOdJhmP5elpQ8f+rrZ1JaLfhII1f\nxbNVy5jx/f+zy3R5I18ocbUBemGF/LWXKBlhwP64Q0XcmE5PupcP9syuIHXm\nzFVYmI4D4kkuFlEPIAITVSCjhHcAt8XRpUslmWQcFDOW2TOiw8/NY3HeDD2n\nbElHLBNE28h/dlx/9K8vhfbp14EWLUKHaDFUdS3iE1wBt/abEban7331gCDp\nadWnVvBqJDKFLq49lLUaLKPvLlE5gMjke/CX4pOnCoWcBOT3OmxR4Zvachps\nUtac/JjM4v4XlfyewgZJnBOVAuEjIgp46lMk3+g0e4avNa07x9gKfb5b/sDz\nOVYZnEk1zIwy+ZfscHWBxmlcETMHAtStjELwatQtvyPnVGKgKFmfKHUPGCxK\niIlly91R6CI7GW/sN6P0zqGhgCcFcsHt9Ydqhw+5aqwoXE3oaE3X7Y471ddi\nitXW3ccuU/j2DwAC1kOGx60YMYtCbWmLQhylktAVJz7XNxWqgifx4xKS0uUH\nBvRgiiv3m2KlAfW0F2agIQtHWMzp2cB1oktbEVV9qch0LgpBNXJzd24KUOc4\nvgch\r\n=N4Zu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nThis is a draft documentation for `@iadvize-oss/store`, a lightweight Javascript\nstore library.\n\n# Why\n\nWe used to rely heavily on Redux at iAdvize, using the library as the defacto\nstate storage of our frontend apps.\n\nWe've started to question this systemic use of Redux. We’re not the only ones as\nwe’ve seen actors of the frontend community having the same questions and\nshipping alternatives that :\n\n- want to respond to scaling issues, view-binding complexity and rendering\n  headache (React useState, Recoil)\n\n- want to respond to architecture issues, where the rule of having one only\n  store for all the data of the app does not make sense (Dan Abramov's famous\n  “local state is fine”, Recoil and the ecosystem of small store libs built with\n  React in mind like react-hooks-global-state)\n\n- want to offer a better developper experience, reducing the Redux boilerplate\n  and the reducer / middleware duality\n\nListening on these discussions, and working on new internal apps, we started to\nunderstand that Redux does not match all of our frontend app architectures. \n\nSome of our apps rely only on GraphQL and do not need a global store. They will\nuse only a few local  `useState`. \nOther apps follow a DDD / layers architecture were we would like to have a basic\nstore in the infrastructure layer with no functional api bound to it unlike what\nRedux wants us to do with actions.\n\nOther apps cannot rely on specific React-only store libraries like Recoil\nbecause they also need to access this state in other parts of their codebase\nwhere React isn't an option (legacy views, low-level code, etc.).\n\nThat’s why we created this new store library. \n\nIt’s lightweight. A store will only provide  `read`, `apply` and `subscribe`\nmethods, in the FP way. \n\nIt’s composable. You can take multiple stores and combine them. You can select\na subpart of one store’s state.\n\nIt offers a React binding library à la `react-redux` and a\nRedux-devtools-compatible debugger.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.18.2","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1531df4-1593861440069_1593861517570_0.01910539382214793","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-57cac7c-1593927162716":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-57cac7c-1593927162716","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-57cac7c-1593927162716","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8417511220838030ee3a067d88c1a4913b5a778d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-57cac7c-1593927162716.tgz","fileCount":7,"integrity":"sha512-AFF8mUmysZLto7C5AGKD6DpsXRB/PAA/rZRcvBbnP+dAj6EO0udfsBd3ufKNO1l/EhYXBdOaiaUSoxMqVT2m7g==","signatures":[{"sig":"MEUCIHkvkUwMpU6xQ4h3bNcr+urchUaSTJeHeKcCOuWKjm+BAiEAwzHGcR2WkJbXB6EZf51tg/7nKhf1BnGjxmpgHGZaZ8w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAWYvCRA9TVsSAnZWagAAJPsQAJ6VtuKIgZo6WfdC5d2/\nVaTCKR1fI+cf/RKHZdJidNU3D0GL7zaWwCL8GaB7kixe9daJcViP6z8iNUA9\nysj27Q4nodJXTH3NojYsTTrCqJ03bjWh7M2/gRsrF9SlH82x4XWEoMCwT1lC\nP5nOEdR/Q1DSqnth7r52IG6SPbbY33c/qMc7MbNW7dO7i3SDOxQ200LB8rFU\nhXpvvKICWqdb9GLOKoJh0lkNuOVyhQzVSlPl7DWCJV40HgZaDFIbedK+8Dm+\np5zaz5XeY+qY14SBJiN0A38vL3FK/0qFsSC/Lg8jn3JlvxHPPVJyFHZs/1uO\nyqnw+sVC9G8GQQpRupdLR8+Vy/dD9dIBrmrp2h81skjD9N3V1m95S56feDLJ\nHAeIHDN/JF7GaVo/JQo4ljSDrf/uIU14Xvu42Ot5jZI17DK49NFO0u0gDqap\ny+7UIwe06+n5tTwXJAIigeCCQap/8nSho28AdHPkzasjn2hJzFMiFFswiyw8\n3Eg7IWaa2Z0A8uyqeCmaToc8+vnQXoh92TBapDtNtSoIvE7LB90Vif5GADi3\nXXlxRYkVqjradR4qZraOdJ08RcGrvYz5YLZyUGanlGqLgYNyUDsNdpM9kPer\narggFG/YGISa9CQbi0GyFP11DafCc2sidKHvdynGFCjWCREOU4mPkcAh5OYK\nl9Q3\r\n=8LSK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.19.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-57cac7c-1593927162716_1593927214486_0.20508155217065704","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-57cac7c-1593927167449":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-57cac7c-1593927167449","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-57cac7c-1593927167449","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e072f5a0edae562d73ebdf342cf0fa6767cee860","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-57cac7c-1593927167449.tgz","fileCount":7,"integrity":"sha512-KiGGyo9cFyosbbTxkdkeinOdJB1fU1sJWdiPhgJJ8nvJtvRjmE4kU+DuKhXKQDpy/tjmFecQ5wkM3LIN909XPA==","signatures":[{"sig":"MEUCIQDEmAcfIWq+qsNUJXpJONOn5qbSJk/KpmiF5S5Yg2igzgIgOhHwYOL8vS8WRIS5Vu9lN9kCtDvP3jLYARM4r+bOGRc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAWY9CRA9TVsSAnZWagAAvD4P/ArYEgiJB9r8PguJFUuC\n14yW+vPWhT0armFlWvrHU7j0Fh7CQo5W+jUVy5yYz7XNDrR8SVw2e2DhrXjH\nj4tvCHSsh1lQuDGybYqmCqDXYp7RL5cHakdPVAQ0l3cz3pyPaQsDKWxOYk39\n5biGOJV2Iu5l9xQnO/zdUJHRTOJa+AIA6SYW6zsi+XYlUCT8dLNo77k+nypq\nU2VXbq/Uct8sUT7LkrTUJio8ZN7NIwDqZcLoPiNhzLhc0YUbMCS/1/WQ6tJy\nTHgkaeLaHYaesMHrY8oAi8JYB48NU2PVXmER4S4HKmiWKVdoVjGKry7szG5s\nTjrU/HB9/LgwFy+5j8euR1m383wdiTv6uHd73H4UuEobGEu+MDgyEw+da6A/\nU2eULKFcjh0cYOG8K8eWbK0Zhozgk+1oPCs/mrAg815KsNEmpwiZHAeCx1dP\nh5QoRlLrVZ21qYhMKYYIfQpfJdp08gzPFsi/7Fmh8AyZiSM038wx2y839Uig\nXT76LHl6dKQsMJN5BFz4nFT+ft5caETicx1XEZLUoS8CpNdQ3PMRmxDWrj1j\nK60OpKRQCUKDm54E7wMnwlLIjdjGYWCAbqjt0AFvBBY7sfTY7SPo7A/tdU8o\n7G0S55xtBfTc3p7G7r2db6iFf8xhWqD/xMz4T4UTU017dmXvTjX1W6TzfdaE\n+T/B\r\n=Sbau\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.19.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-57cac7c-1593927167449_1593927229249_0.07853348699586449","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7904260-1594063602125":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7904260-1594063602125","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7904260-1594063602125","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a524f6c2b486b8001c6faafbb9b74cfca542e249","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7904260-1594063602125.tgz","fileCount":7,"integrity":"sha512-+EQMZLm7xqZXy5wdC/VidRVO7pGRwNV2ohnDGYVx+Fw36RuuHrV087ZJXRHFuM/G5UEys6QYmCsTCcyy+afNQg==","signatures":[{"sig":"MEYCIQDglT7KQ0qDNZeKIJneLX60pBx2DkDGEhtxtnsYoxO1VQIhAN029fy/MoOXuGD3urR7MWPodLdWZ6cftf4DHhfrw4J7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA3shCRA9TVsSAnZWagAAWEEP/Rl87g2mx+DbhEZmRqxg\n1C/wPQY5P0rXmK85OIkKxxkcufOSNITEOJxdA+1nIXzvvG+rV1/11FRMsaR/\n30fyM5aZNHDYwEmK0CYmEWZzXdRr0g2WCVv78mtAYw5FpDlLYrMRw574p1hg\nagYniZJYDKusxpCAkld8CVEjGLRiE9KiWS/iJjG5Bq9cCAMbSt8dQ/2w0qxU\nrjaDiDkm1TKr5ETizmeXz4gc1408YDTtAloEQ0fohX4h/pDVVa/JabOgW89Y\nTlzoNewEVaqbteABwDs+GiFVNOujzIC5x5EjClJVC/YpUHNNtH2H5Y+tx00f\ny78+95bUJObGoPy5aPL1gjawlm3d1xZEgGkID5njcmtCxarrozhepVHdJ8+n\nDy/YwBpkLZybxeBWJP6f5bA2+MPnZTPy20rplWmAWN1aWp35tFuZt2JUSNuq\nPrQsKsgq0wO8wuM9ImFYOFl6ztjVtuXKNcmicyXB1zBAGHyDaYocGiYAtVyt\n7bD0zT/tWonI/q8rBYJ8yOAHqwBrnCq80x+6TYk2Rt01Bq0e7OsDVDJIyuf3\n+eYu31TV4kyKtQm7boFkiATIha9Qrtir3nYgLb9/T+48DmQUaK5pubFxXPGh\nCwBYv+p9QLDxZMWo3k3zDK5E3rcPuswWd65rm/lxZU30zI+cX4G6lQCFTdLT\nDAza\r\n=h17t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.20.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7904260-1594063602125_1594063649493_0.6554612516390748","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7904260-1594063600692":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7904260-1594063600692","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7904260-1594063600692","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7875870e71a0889fef7346cbca83d192f3d5cc3f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7904260-1594063600692.tgz","fileCount":7,"integrity":"sha512-Y7Zo3tninyd+a3kgrSJSlxJTLmgW+sdVoThdB8JF0tzPqwjiUQokoZnG2hpfOpUFH7OoFUxa7zVd1xQOsN/aNw==","signatures":[{"sig":"MEUCIBvrriYQaxU8JZQxEb/Q63K/bfMJObCT8XNMWOSEw0MGAiEA4Cttz5Yxq/dobmM4wJzFWKT31XOR/9tVbgPLJgvAuAA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA3swCRA9TVsSAnZWagAASooP/3MFsjsvOuU3ZbgE+3/R\nCqoeENP6rxvz7lMNP01CgDKVDDAyANpgjlUVqO32a7Bi90zy50ElhdL5nWF1\n9WMeoyozDo687fytELAjMvgWcs1PZb9Vo8cAmS4O2VNphLEDeIlLNeu+iEdL\ndV0mucHLH0oxhBfmvmsYjWyfcXOfkpaOInbzFF9KGEUi/fA3XzXggP2fLcAT\nZZWyTNWslbcoVF9Tidrbp0iooeQlQ4TDYo78yCJuSAAhsYH9moFpH2tKGtGw\nhplLjV+2vPUqMo3FMOzXOmttNQugsoJEViZCHRodHNTxwmVpbgYdTEUb9XV7\nv/sfS2MU8rcwWhtmvtkon55UKNhluoa/Z72BdqRkE5gCvI5Ya+Pz7tJ21tSz\nuPxcT2Q7EY6BUCPhibwrvR5t4RyFsHcAm62MWi/yCV/uQUGohPu3N7Lq1dg0\no5EI+zEFTXZKf9Qk2rWiUg8x5xvKzhRPi6zQeWDqAtsxWBhu45SB8dasqnRZ\nDtti91n2oyhdNXtq4InlALEtuvCs7LMbB/8io6tcwGKeW8ypl2rGH5vZiSW3\nwaNe681w7bFzte7cc+R/46IqpDTOwmVoPQOoUTRmL+qB3XIuAYJ8v15B7yHl\nlVZSHqkUfV4pJVj3JRbW9Z50yOrnBk/cUyJwAZrA1xdW2ekyHF8OVgH5ZTja\nbATI\r\n=ABQl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.20.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7904260-1594063600692_1594063664237_0.017228398064492723","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f56cfed-1594069922695":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f56cfed-1594069922695","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f56cfed-1594069922695","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"083d04d8f2cdf6efeef285b657c627a771cc8902","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f56cfed-1594069922695.tgz","fileCount":7,"integrity":"sha512-B0voHNdFJWJ2j5TkfWS7xfLV7I1HDydmnYi5XEsOS6u/Pvx1/jXLf5aMd5oZjQXDInBMAQuQLyhkMATGI9sfzA==","signatures":[{"sig":"MEUCIQDJpGVb7yJw42NJGa9crkM0WXB+apK80CbIbfpdOUtBzwIgeOw43QiHd9VTuy5By5GKWvGXMxWZMaGyMKtM52kKZ3A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA5PYCRA9TVsSAnZWagAAacQP/ir4U1P8/j+7SnB93tJf\nvnZLQnn4DFcAu+LHsna3Z5uybOTL5eNuXVeEcVG3dq87fltxzmFQBBkHRO3r\nfVj4DSLDIoWSS7pgAOd3LZGyk470CKTvOU4Xk1+iTItcrUqtqUdy212h5MS2\n7UvDJSU7UzxG4P88yO3/sUQ7WlI7l1miBQMK5l8fLV1q1yht+ZBzIRAf/Zq0\nV7ADDtRJJD9ey2QUqatHyrlOzcYlzyHvZ1iUQSaZ71CzC1oyjNm4hkRo1hL0\nk1mGfVqeYstXvrvVqrW0Is+eZRRf62LfZ3ilE1YWjlyxXQjxvtPSahND54BN\nAiKKpYR8a3t1Unx9ra/xlhdRQWj0qn4u0QmY5gbIoWVDBbBxirH0Ckz+16Tb\nV3BD13+2a4xaeRZOyqCa4DbZPQ2k2Ptquw2rVeU1mujRysS81jKzX78v3UYF\ngYl7VyTa5ReudV0MPYasnInWTDhPBaQtbcuGzx8JZKP/uwkCAoWkFn7HH2jM\nbZ0Lb+Wr1Hz+bz9nCjQ1x2wDLfc1/s6eMDOx2ozB3h1bPikQGUDFvLm08FBG\n0mtq+hlrIzZC2TW0r4fgG8hZe4YGRqDPovB8zl+dRSeb7RZiGKBxordSVolx\n3IaimmP8D0Hq6dnUXhlzdxDbsa1Vb32+zQNS6vM4ZN/5VtYkC+9LNEqXIlyG\nNvv+\r\n=45vQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.20.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.4","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f56cfed-1594069922695_1594069975940_0.8868080833096266","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f56cfed-1594069933207":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f56cfed-1594069933207","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f56cfed-1594069933207","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5b45ea8c739863f7eb8e9ffa3378a74579d5f622","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f56cfed-1594069933207.tgz","fileCount":7,"integrity":"sha512-MiDhw4mNjkBuFNsIJDPaVZdm216tlcfyFKEsKZF7U9UI1pyF62ZGdUvBXjzlPlcChZkg+u85NY+VOowd+mmPOQ==","signatures":[{"sig":"MEYCIQCcT7udIMt9TjIQEB+2me1n3WoYA8sZj/aeQdnckTHkrAIhAKLzQhHqtgQc1mjmDwx3mDqdPW9/HhuZKX5IH3grB4g/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA5PgCRA9TVsSAnZWagAAm60P+wR3En8E969WmANjZR+L\nsRAQiGLaDwTQcXXKhIJY6/oa4rb0flriKB2rlYUz7mdAAWy3IQ+ceq+6wt1b\nZ+8DMPq6cpac/CxGwjXJs0Pt1eKjjwjnZEAOViZTcyYLz3k+mVrnhFzTLQdk\nP515SxPdclrH7Sh7QEzcJ8aHDOjzzhDum/xW0G9oj1YvCTEoooBXlxvHcBRh\naHx9baw7Lq2KwrwYJCYE1N2kXXMpxLIWAPVYgYqGyKGJMLVeDqoZxEuQRlNY\nrcx2Rnb3rSIfl4MnloeA9a/uNmeQMoICldQrDZ2+EGjUezOw6C7BYteR/HiC\nQDHOsLz8isup+18KCrVxJ7H42ZFBgEF8Yy2fH4Diap9SBcH1Zhhqkp2O9fAO\nZYiPGEY/RsNKmXmpAKjNhoK6puKEa2KoHSmgvP7wxoyFt9bopOdxjxS4g9x2\nvuPnVj0vMiRKpl7a5id2mu9gVRWsSWrJet6wrXY7to30EpBXKqHLoCJknSxG\naoZZwGTA/2NEnla3JsdIoipw9gJsqXMjTfeExttrZuQ66uWEEwuStL7XFCqc\nX3X7ScmdmAFx3kR+8ClCvs0QQVP+PtjQNVvkjdaqg5WayUC07c9ZZ+pc5scZ\nKJbdEgVN3Aht49k5QHpNi27u75ckC3E6smC5430/p/WdnfV4kdJhB3Rv/GGU\n9Qyx\r\n=8spb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.20.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.4","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f56cfed-1594069933207_1594069983604_0.011405165762672365","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f56cfed-1594069930240":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f56cfed-1594069930240","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f56cfed-1594069930240","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ae9bf001a6a656a04472474a2e29c8eec4d0e12b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f56cfed-1594069930240.tgz","fileCount":7,"integrity":"sha512-+UsYCgP/OIZlihxJteFGN6n7fHxuXxnwE/EbKv0ftwLXsx/WY+GsJijFdILsu9Wf3YasC3g6EyTSLh88QjzjsQ==","signatures":[{"sig":"MEYCIQCZpBQfP5+8zfkq0iz3D+xJuLzQBY5bUJQ9QnTgs48/qAIhAJ6ill/6XrUa643M/TMtHaHSGLs2VMoV2SFI5lUEup+D","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA5QWCRA9TVsSAnZWagAAZ6AP/27PY58Sn4wD0PDQb1hG\n4nclib6W2wp8HDJEKd+T5Lrtfk1z0dB/TfK6a+nbtVMK0Yj/Jr6WVE2+CMpc\n0iHarnqyy+L7VJdUuQJkelZVFNxcYcNKWqdwf16Af/DROEmjuIpNK1S9qZzk\nGnDJTQzUj/UCHvpAI0WakVaaNIkbmLbk7thnVJ96n/vnJ9l7uTEwS3p8N+Tf\nfbqlecYykFvBRpMz7bF3fk223ARMYZi9LLFFN3Yss6WKckBQkOV6C9mtUsvb\nyw8w5URltKDwCgDpLMflneQVo/yEJI5lIad6GKXu63KUuSoKWE/JO/TZQrOG\nhEuEKuBcn6utmfO82qM+t2hHjdoGE5goCoMeW3HN629EKVj6l3VjcHJSv2sf\n5B4cPAJGiSBbSl8XakCz1Vzpfjms4iqIe/cyJgF9p8xKaRZ379i6ROHwpB7e\nbt2F0GnDj4eSchBGaF3PedF0rFWvvFctrNqnFQkfb2Rng7nX0CkH1aKtFVnO\n6ZsVgGCst4VRwJXG2Hvkrf9dd3eQINt0PN1q/XmbxxsA28gwapqa2Ghd+UvX\nabrwUcTDj9ll4jdydq5KVeIjZPJrGBwWbjSoWaZ22MUE3JIhRaIXd0Yk2Ocl\nQ9TM0y0xfTQ8mwy/h0sa0tKEfukTCveZ1P9LzGO3rdjv1ul9WfQAkUBmFiXo\n6Fdr\r\n=vDi+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.20.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.4","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f56cfed-1594069930240_1594070037886_0.9989448283765623","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-384a133-1594150944060":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-384a133-1594150944060","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-384a133-1594150944060","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"05abc8e075799d31f2e83e64fd554fdc7e7588ba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-384a133-1594150944060.tgz","fileCount":7,"integrity":"sha512-euUUgk7A8Hr50jOOcLj8w1sY+LR9SPYyFyL9wauLblDHAG03yqNcqmyD3FOgS4tonC6l0jjA0DqK1N/jW4VdcQ==","signatures":[{"sig":"MEYCIQCUDS/XqQQ2BqW9++CQBeONXjfGCBllYzNMvRMtutv7cQIhAPrPtjzvCzGwk/s7aHLmbwYnbXXNu+qjiXTiGqax/Cqs","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBNBYCRA9TVsSAnZWagAAp+oP/i23p/zI/QQC8ZPWGUTh\niPubh6qW6zkzhcQadZB6pwLgWfFxTWLnw59llkyOPcQK7D8InCkIWCubdDb2\ne3mZuIx1vXYovK/Z1g/STO1HuIFNZxw9x97Op8pFpOgeIZxvS1g7sZtHeCSQ\nz7qXYuwmUqJDe4nkeAQRDSGW8Bp4OvEX207EeKdQ/zyvIt9e/PQUmMzmeU9b\nYXIgZ7jkJuEnUvWQqk/+F9OMKA/Kl+qCdTkamHrAmonVZ0PXaCiFX7h/rKMJ\nCJ1Mhxk/vWVIcsgv6pa/4QvTgoH3nfiOs7BnEHoPQYi7M3NTESrKCZFttYSU\ns5UVk1OB6jW/3Ua9yJQ2EMf/auWCluQ1ahoGBYKtdjoCeDxf5rXMkcdOQatf\nWppFVsm976q8DlryK0PUbKE9L2vwfTqebj95/gQEY+7kXgO6j+/0AOjg9lEX\nAfyPBK1TNRVsLwuZwwwizoI9boylyks6e9e98kaN62Y530EeZpAwN68oo9nE\nSRkOKEEpLKLmBu4PEP0eVYj5Bo+BdwS+wMy+bOLcuaHpANmEkCbgNY4frKDK\nUYfiovajKNvQWXH6Ck6OaFAfphqBDAsaIZGPp7we/34llbvNLw04BX1jjFyt\nWCzl+IhkSNuIF+X22eRBrqtu6J9ZzdIZtwG4n/CLJa23/dsnfOJ0oq9My4CS\nhXOZ\r\n=/xTc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-384a133-1594150944060_1594151000571_0.03748932579072317","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-384a133-1594150947511":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-384a133-1594150947511","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-384a133-1594150947511","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e05fd9a2ff2c95925f5b58aaeb23c368ce6edc57","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-384a133-1594150947511.tgz","fileCount":7,"integrity":"sha512-C0G55AuKx7Ohlwv1ZWe2tWAb2PqFEeXKHF7kc0EiVGCAGB1YEpKj6H5lKwHRdEIt2/l099MjjaBpXmL+zueYLQ==","signatures":[{"sig":"MEUCID9aGJ3YgSAToDMFas0wLLIkwnEBWdzUvIOKMWQJlcaPAiEA1wG/fYZQfkS6UM6EPSAkUYZq/fQXB3YlKl7pHxvzW54=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBNBnCRA9TVsSAnZWagAAE9kP/2uIYhybA8af4ccJen9U\ny/WiuQZ2UJ7tkLjiN6sq7NE4VnRAe56u6qphjkaf/zwVqxyH/JPVLOJW8XlL\nOhnwJvU1jYj71rDeCANI4yaFmhOE45A0DREisLVAs/SWzHDBMwAxEthNYcg5\nsZlyo2nGVNvRZ5VZRoEy7L2tbQgwJtPnAZcUlRI5/oTrSB2Dhd5EFDzggH9l\n02SKckaR+lKvZRbI5WbZ7K5geZn7cCtWDsdLLWJFExOTDS7uulcElyYvpJN7\n+hhDxF7njIbFpeYOGz0Yn3UL2M6gxQbkAeroChIfCEyQRxdyHUU9BGuhkFet\noqROAqSfHxlb95SB1uaNLfPgLwq61qmNY/w+hKW7G+p/P/2UEysiBMxtE5Q9\nAC/VXUZHjpLZMV4NUjlICfpPJo6moQlgQGGyYWerwdhpMHMmKI/6J1udz+WA\nwu4GxBKsawJ/OfpnrDCo6XEVMKtApqhkDlW5og8pp6naSOMVXkP5SBEkM9H7\nOLF7jUHgQs2NKk0NUcPIkJAOzDa8PGbQRSZacZHCgxX7pBF9IDt2h8b2uuy6\nEJcu7Zx7GzEzFAnN+EBhW0GKHdbfzn6f0+wm2kTgacd8qMYPr4fAFY5cJ8b1\n9qG5LBKNZDzVdTjSSStnEv4QtI2IRjUsWtNwwOkbpt3iW8LqeIbBjFb3lNJ+\nUql3\r\n=zLNh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-384a133-1594150947511_1594151014783_0.32991824484903365","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d607ade-1594151271343":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d607ade-1594151271343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d607ade-1594151271343","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9b18a2aee6d319a6ff71ab875dcce877133b572f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d607ade-1594151271343.tgz","fileCount":7,"integrity":"sha512-Xv9fvbwtDY3bn4bemWHAlPO7TgrQLdFzicW2kIiakztZX2+aXMo47Dp4bdeZr/x/AbV2Sh9SKUpWl9Q30WwEwg==","signatures":[{"sig":"MEUCIGiVELilmAu4lVlNPCRczVbSEYUZJqZyQHQJY9rF7JDsAiEA4bmdcAiFi8ivIXcyujUMZUXTCdaxa7ddscDc9dfIWY4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBNGVCRA9TVsSAnZWagAAU5oP/ieWypi3QiC1y0f+u+8p\nNP77qiBCuOC5LYjeJrzbYefU60VS7IxfoFsr3Z3Nzm9SKKaenhdviD/JjPN1\nUS0boG9jYXcg1AIgSPQpfBm42ZKOFCYGYaB/f67IBas4sPaxPMP7I0BdWftC\nK2wTvBeLYZGyuetq8LdtYBFZ7Mrrsep5uJGg/ejz0l7Dyh01/HV0Sgf6D217\nd10hvHE629Is+RX/yz7Lysdp3OrL+LzMEMdJgRs5QDtM+QJPlJru7J4LgHhb\njrmAbpQ12rweciQFislcWIZ0MJBHPreQhdmkoNrEyOXuOHJtmxGR6EpXo8YT\ngOJRsa6xSnP3LG+yrg0yCmlrAmsO3FcPo9b3kVd3jf9C4t+4RhkW0x4we7aK\n36M/ZUhO48icFMds3HqgRf6gEJobHGvzj12j+QHhxzIELEpEXvohL2PWRyQp\nfmydS8cJiOQea90JwXxUKPy3HLsf1J94okLr/gCtTj97wHQu6AxQq50a4lf8\ndOSGCPHYGhF2aIaJwbwNdmYUm2m2jU2Bz4O8trh7owNA/+PoL4999t84DFg/\nQXmLSweZA86ce9gaPThmHUnXIEKG3YFDTUutdKulwVVZnxqdtzR3Qc24KiNH\nUD8ihs3Vdt8q13mwdn9l9tkeiukyGUQ6A5hGxIwuC1xOigC+9WLl51lA/uR7\n9oU0\r\n=hZWf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d607ade-1594151271343_1594151317352_0.558255056866714","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e44d33e-1594587835409":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e44d33e-1594587835409","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e44d33e-1594587835409","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"624f580fb9ae9adcbb7968e58274a99b73a258e7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e44d33e-1594587835409.tgz","fileCount":7,"integrity":"sha512-TwbzHQC0Ea4v5TyzCjNO8q6p+51ThF/JmRwmCxeyjTkDw5i9HHmEygzMTjRcNIusnPVHvNnReIS11sRiyHNcjw==","signatures":[{"sig":"MEQCIBHiLxDJmdHjo6bo97T7dZByIEfvEMCuqD/PplVP8ZIPAiBFR0L1Y2/85p1OC4CawCrQYlNbdy7tvZjBow9Har/58w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC3r3CRA9TVsSAnZWagAAAE8P/22Wxz1IZlSR4XoeGCSw\n/2Q7WWTmHTTzPU0Cb3NIVXlwFrn5HhY7KhfWqPMqdObgP/BCD86USzYNudci\n2aucsihOKr0wKvRgsZFQ6guXBlVCse7rkMkaLEiH6M3oCz5CCLqQ3jB1ufqW\neEU80rqhZO6h86p9HihI7aXxSex0QSatxE/TupU8rW9w9/vq+CNCxtmBgwAo\nCAPJ3b8SUrQSol9a+zq67SEB57qaFjP/FOHFU5416kX0+gIqBREdvOO7rmPs\n3UtMEd0VNdo07ibrGmSVgJa/UI68KXO6Dr8bwXoP/d35HWBXKCMB2w4Woqf9\nSEOc0nEu3oZ85633Ny14DHLPH5DUKwdWsm0ahX23RppRJzd87V0/EdGLIh50\nGEdyVuL2Rcj9p6nCdSLkE0WnPCVwhA57Av+BN0OdDCxc3NKTu6o8R5TroqpE\nHnPJlUoYtntGjeVneRZSpWU1sjm0hfYnFxyWZWoxN6uejO7ScQepeQovnOdJ\n2UY2Fd6Q24yro/nJSjKUas8yRe3dEBSIuldZjPk0V+d2kM8bwR+npSLKlV3k\nJwbVGtl36BbiV2NmzOEYIrKAswvbAfGnFuJt6HAsK/jQzEsEMVEa4ro+iPM6\nW1l6aRQj3DtCZCCiN+Q0sj3eNUjP9IAPbaFIHglhhp4+SAqq9Tsyi6WaG0MF\n8wmZ\r\n=GfGy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.1","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e44d33e-1594587835409_1594587895058_0.7983174736939924","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e44d33e-1594587838184":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e44d33e-1594587838184","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e44d33e-1594587838184","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"997a14d0def9d6ce1b36f44fb09eeac663dafa9f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e44d33e-1594587838184.tgz","fileCount":7,"integrity":"sha512-4qShoZRBxW1Ugdc2YoWWZu9euoHnm5zv9Sq7uzo+CODvtdJO+NgaK9XzAYgx8bc9/xENW8q3CEYy54rZoLxF5g==","signatures":[{"sig":"MEYCIQCyUAOPfP9boYSZXK3AU6mzWic3AtNkCfOMNX9Vi3Ue+gIhALR1agfFn/yjA1ouPSLoOIQr1hXuArIcRIro02+zsfuf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC3sFCRA9TVsSAnZWagAAUiwP/AxroGIwKvQnF3wKcQiv\nNxcgO8p0xJ0irj2NWC+8cdTezND8AFYGSZT+0AAQ7YbG56iIeCSNeK8VyMRj\nur6FDiBgUBHd2WH+nBgTnJ7LmjLzF502lrvTrxZKlkQDaA+S0CtWgpqcD7Sm\nVb22qVVhV5EeWBAXwgi1N75yJrbbTzIxqmK4ceK62BqVuHb3iXg12fVZD57c\nkRhFVP43ajpCB+UP8gqQjWzXDLOn/XUj4zzITOJhj5Gou/BGMx681QnIENHH\nASHiv84iy4YMoUt9rJt8eUfieuvSOT1lZAzmbIMZyIOJ6Se7SNwQLDRmQG2u\nD0uijAZBYTDZit4EfZQXC5KRpfJIunOpinnAEKWrdXprP2RDrl6fsmKNvm8I\n1M/XvlFGPVzj7xkn8j117/E6UjLymMjCxFvp0UQRKoAUHW/HcP0iTUwujnE5\nNF7ySWeSag1jv05i6Jo0KukFXDqEIOyPdAfDrx6YqhT1HyitISsOH6IqQAT0\n2K1WMshjRgqBk30dYvt/aBet3XZ8tRA/290r52mMElSurr53kFxz8WozU/Hg\nbNSJGLOm0raPRPLzedQ0/YuNZlFXb92cKTodRRzgQ3KB0uu1UW0QuoPMhsza\nVsrs8XG2piHMpNkS19JTupQx960dywP69XX2EJQvxTovSFDP5ieEBA5wPGrw\nMymT\r\n=RD/b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.1","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e44d33e-1594587838184_1594587908898_0.8236524417439113","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-88edb19-1594594071665":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-88edb19-1594594071665","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-88edb19-1594594071665","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c50e783a45a01b2bcdf5a518acb9dcfc01817f04","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-88edb19-1594594071665.tgz","fileCount":7,"integrity":"sha512-YiQVQ/TL9ud2lFviakSE3QFQGw9MFQFTWO5HpdfFX4ItQWeMouE7PoeHnOsIGsHofNQVC+RYd950MnYPd+wwQg==","signatures":[{"sig":"MEYCIQCd1eqho8uWWlt7x4hzlr66QaiujlLGQLQ8y7p9wAydCQIhAIRy1H9ZJO5Sj+Ub66SzsNc8NIl/0ZlAEcxYyUs/W9YA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC5NSCRA9TVsSAnZWagAA+2UQAJ3HHtyH2CpZz9O5Yb3H\nMyXIGAZ4nAleYy5yNdJDwWek9gM080madbc8cIYIvNRdkOQPKDePAbTUJqfX\ncG38kk5N3ypOo/wq5Cl6Tr8Hwfskhd3Mqa7RInH/1LKscPOIU7U0uxd/0Rrt\nhDiqakU4qgVPH25GIFrDq+75GlR7qAQIrByEyBJpVUXdZ4WFD+MIUalb7Zeq\nAKdegg8EO3jCDvuuMehOOpwD/PVk5tlsD3vGObKp3WdDdw25aRxIHjBPpgBW\nIuwQtOK/c8F3vzYpvFR+1PdGw8h5a4O0KwwyeBpmJSdDNHY0dcKTd8b9im7Q\nPRrNKXz1OL6ysem07Z8xDwC1/mGc9SWuricImdPZrLXi8JQLe5gk4pR7PjLn\nqdUn+jTgLenrfuHu47rItjTCkYbnPsBl+ZwLwdDAVJRdz3Bc0iLKSX3CjhTd\nv23/bF4hA/2o7VlyDixNw9luGE1E5pQqErsYIoBd2x0CiVtZBtTLGtr59biB\n+p+OSm+aYiEwAki443K2SFe/hm6+bPuji96ZDg/479OAOMJtKxk7M/uZ7YcM\n8KlJKbZ56XZ5Wt/t3ppAdRK+eYEsnnI+ljENByO+MRa59clwhPi0cje4hxzZ\nhQqAcI3LO9JkZVfpHXzkvrfN46988rN4J4Q1RbGQ8hCO9HRYwndP4VxPE/ML\nP6dP\r\n=Tf2k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.1","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-88edb19-1594594071665_1594594129996_0.4200427348779556","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e9134b2-1594637375619":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e9134b2-1594637375619","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e9134b2-1594637375619","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"40a4583e3f4fd1d8e1747470cc3a9bd287e0e9ff","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e9134b2-1594637375619.tgz","fileCount":7,"integrity":"sha512-c2PBtzCa33GNoQCwtTh58sdJBumSySQnruiBACQMm7sratDWXiiT4e62TqbK6yuTUcg0d3ITVzq73up4vo7yTA==","signatures":[{"sig":"MEQCIDSUYOqt4xNUjxz6UdJycaNvmeilE8zWaY1XPlBhad7NAiBnEQhwN8+FrXIpAZjKkcqbpUPtJmcQWLXWe3AJFd9sAg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDDx0CRA9TVsSAnZWagAApDQP/3LTD0zFnl16r9fRjcpC\ncOKUVtYhIK5cg3+P325y3+wyBveHPOj3Vw8c+1FSI1+HPgYcvnxXPQUEKLad\nQLjUdRdCFtXs2+ZhPKBs1Z9c2DiTbOI0IClpHYZHvq54mz9Ai8zrRiMskQv+\ns6IxhdWjuv2hdgzLDLh8zvFnTnOSrFPFx9wB65hv4SfyBctPohnaxjMH1TBT\n09VIIexiBEh3+PxASBH7GQwu9LCd0kYguBy8GL9j+oqAqlWqdKVlj/TqRYy0\ncM1NTUYMLpMBG5DSZWfrrk/mcWChAdu9ZkWoN/jY3hJ2FNiZt2+MYkkxfcwq\no+W1SZVGiL5FWimSaTjMFqaCNtO//N8mWkN7TO8EomcUbaWzdwH47WgwhFNB\nrF/oDEHsl3mWA1ZnKvev04sZXKNRuGLR0EmAJxJFwrjO5BpgurkkExlieqc7\nmb57oPrYnuMUgKcC0u3v8qfPDz+6CY0RbiAuwMwYpW91C+RvhaLaOxZldXmC\nX/CPs0pdxW92gSK98b5oIgjGFVykkLPqWtfy0lkzoJ71aNYaiBuMjmQsrqYI\n9PXEBn0E0bkPBYnaEUVKFON/iWC957A02R6jiva+Orkv8iFy5X0HdSc/J7Dy\nK/C3Btks5L52JeJkVIaQDMZ8IHxgK6fKFw556E/84u5SR1arQ8UoDykRmSTl\n5s22\r\n=IxfY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e9134b2-1594637375619_1594637428240_0.5848820203259038","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e9134b2-1594637375609":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e9134b2-1594637375609","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e9134b2-1594637375609","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"183ba3e108e7b1e5bff556e28a60f664aba7bfd4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e9134b2-1594637375609.tgz","fileCount":7,"integrity":"sha512-Da6p1vg8s71LFbYZ0h+BLt4t1hheCh8JAww6Sr+LLQE7FAe00hkMyOOYUWDw/g793ZJAzO2tBt2uvdM4qPsSjQ==","signatures":[{"sig":"MEUCIQCcXowOu3tKN8YizMlxqcQo4KSXZYMZOLOfkfYLjvXVBgIgHIBS4SMPubxQpIpJhN4z+tqH6RBDow726x941kTEeds=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDDyECRA9TVsSAnZWagAAWq0P+wUZSLhPneFmgcenxipV\niruGsoqqOeVWS5rrfT36Yf4eqOxQuqdUhsRLmpaMbfQ1kn0wVKcDEUXOfBbd\ne0dRrtWMu6Xj8weo4soX1Ss7H/bx6PnqFellTm+1peUVsAtu4a/fVmGd4/zq\nvYR7JNcdj5qVuaSEpT38RS5PthHv4MQGtnQmrImfFUl7OdOZq0TFTIcIJAk7\nBVKpFZ2k1dQ3t6TSOokWqvsNIdw9vs0mmGLw24DhHh3RNgTm5iYYYzgGtTfH\nY6kYIkPC24rO9bULUM2fSr4QDjBI5yFBpSt9xKWJevO96UkXiquA0gIwB0ax\ni3BgJ7w6nCmqQwd4jv95BF6CoYKKZ2lAKEqVuN9bPa0rJZlq/fdQR2E/okxB\ndQBVg5+LYHboEIIBqKNuZ6uPOwOkKjG0zlvBYbGyaqQ1RPDyaYlk+Kbh9l1m\nUgwITvM78yyI/gsUXYy7p9amlek1g23UpCOEdhhpAmsSWd1k7XHRe8C74vxT\n1EBvLHX13Obu5CxeZxaeh+u5QXXUNgBOnrh5rWpRLp3bA2OqnoGYnFCfSrmi\nyoFr58QcL8BKqspKqkUkN5EMqJ6cP4yQ6AMCBm9nQEglEng00cjTGF636wAL\nJRGwGHqZZ+l7jxZ/sspKE/u4M4lfg+2C3rpLxsvDeLlEJeqKKBlXQpf0Jdbz\nbmCi\r\n=440K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e9134b2-1594637375609_1594637443582_0.9523783562928285","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e212c6b-1594683871709":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e212c6b-1594683871709","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e212c6b-1594683871709","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"646e51a44f7fda8079ec07d504376778eaddce27","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e212c6b-1594683871709.tgz","fileCount":7,"integrity":"sha512-DbFTslVD3F0OUbuvpEKEa0b3nKn3rhpjG0cd0glMQfjNx+uqxciHXhOpMHzuD5rlz+VjYFQT6ktYyQZ4i0LImQ==","signatures":[{"sig":"MEYCIQCgA1LGoVvQWR8VNY+WulXHz9HvxujVhBUYQduCiIiEqwIhAKPzFmsjcqx9xK97erzXG7hsIA44U1S48MMz3qQ+e/uQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDPIVCRA9TVsSAnZWagAAyLcP/ix2EtFF/TRdGJKvnyDl\nO14ZVNVDGCTxFSrouTd8QWHx2cFSMStIfMXgvYvcRiFrPKxx9KF9tt4ZUyEI\nQO86n2UPP1QjFEf3ED/+5IxZYCxzo9+L/X4Ldtst6drEFTQJPHlI2CDylGRJ\nULIwWxS0FrQIZweS7fndeeL8Zl+mKA64bn079XcfRaqzFxgCKFooub7JQXXt\n4IbYISpqgJp/pEKmmpCRhBye9WxR15F+Fr5fEfqotbkm1e70oUC8THyxZSsD\nMkhBGRMOn7PvP2TQxuMOYJ36VcYLQ0chqoyp87G7kTe6Lpmv8KFOopwuWkJq\n0Lvm1gO2bkXXnmgYO84bebAxUAkpiPTRFWjVA3FWHFQl8bPe53IGVDYZFKKV\nDv/5m4q3y8N2uON6mlXL8c5dzlIwtmc8IBqS9FQCamGnoZWjKGhy0lMJBlht\n+cQ5dgld/+KMUA6HUQ1wZLCd86mvuS0vdH9HJFkvF4t7/i488FOzokzQfhmM\nBj/K03miAldRfU9fAH0IQiacXertR5wfhZP5m6b/aWhSP+hFmE068TNweuxK\nfFqhk9yeirsbxbvL2BY+YtwgrhFtiG4hFgdhkE39IFL6/0MbWc23ezSZ2ExL\nixeoqA0AS8aGL2FRGrW7tMQKCT7yDOwoL8d8Kx03x7sUTcaOm3pl0qUeIYdY\n/hP0\r\n=7YDu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e212c6b-1594683871709_1594683925121_0.4365075411244326","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e212c6b-1594683870301":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e212c6b-1594683870301","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e212c6b-1594683870301","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"97fd86cc0cc6414aced7182107e61f96ed23c6d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e212c6b-1594683870301.tgz","fileCount":7,"integrity":"sha512-cjsxmljJOkCEkARiado07fvGbaFdsmh39Fkk2MbffF0TDT2Iw26OVriTqEsTcbSEpfJBVQIVv+Tvsh+FUSTh7g==","signatures":[{"sig":"MEUCIQDWXOB4W+KvPdRl6yZxELCDhJ0PHJCoKbHNUOkUTB/YhAIgUijennC0dF3Udz4O6uJEZM85MtzdYoQ3w20S8XgjeiU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDPIcCRA9TVsSAnZWagAARPUP/1vEihfURGhtwL3F3Mnf\ncNBOG9FV3ZylONYND9Oi9MNxZVdGjupQQ8XYpeLh2SCEPqyoDa4WSZ3X8xtd\nX1bpKSFq1AM6RskhnzwBmaO50WlJDh9fvEull4cz8ZLzKYXi3gKov17G6Mlq\ny6CRL8DC2etTQkwGeZc7EEwKhwHy9q+U98LPx1dYIatqx20OsE5CC1kcFP3O\ntT3iqbuujwFqhIpOR5ACHWQ+3Yr8SsXeIgqM9qXMb5nCPW186dTSwfUHnF7F\nPMgnz5SmKR3fH0LJeC1HcvNZM3ElXNPb+srZgf7w4IDNYPHwZ56tiWZzNoUW\n1n8pR7vPD3Nfh/8KoJPzjJa5Y3sYU4P1Vs+seHk+eYwJL06N8QQ65m6wItzx\n5Bmh7RdZe/cc7G6QZi30ZtxTa60CQP54M8NNLR1Z1GCvnX3v9QEyjCTHb4J8\njXGOaI1MXOU/omq/udQdqAWT8gAw+x2DIHHh1zu10BfaDYdOqOKoUpkRLemC\npk0jJNHPWCCX+BZ+occ0tshosPL/v2G0DXT6Bv1cyPnmK1NkiDDgMWdB7iME\ntjp2HqoQXAkFluWX2wyLT/0qieoLmL+QyDbVX8rdX1hTwPhPCFgLy6f8PRxe\nkKIVG5cUmctIjW4Sf5Br8Ea/QtWFI+/ZZf03Zpfp9PcF+Kxkr7zRdKjeh0z6\nCPZ3\r\n=OAjV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e212c6b-1594683870301_1594683931537_0.11646511018463301","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-2977a54-1594684461938":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-2977a54-1594684461938","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-2977a54-1594684461938","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c229f69a94d58ddd0f7ecd073a37d8fad15867b5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-2977a54-1594684461938.tgz","fileCount":7,"integrity":"sha512-gqjuFpHijlL6bR2PXaGabX+KW/MPgid5Fq0SRutW5vTdRU0ASwsJ+f2cp6M3oFBV6kGsUEdiHF9PsbQ+Sc3RmQ==","signatures":[{"sig":"MEUCIQDvw0uK1HaFz9c1Jtj5zIEQcNoQIAj29zSTxkeVPPBL3QIgQZOLAenksuDvEBBAs3JH7Pe/g0lTSRJg/dwOWLPWVY0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDPRfCRA9TVsSAnZWagAA0mEP/ilpDgWIk4yoKizBC/sl\n6hFy/PsCfDf10cC0jaAMVBVodYGmwiWzCGYPdhIVh/+Hg05LK/l3TAsFamKS\nJQWWTf0nglIfnO+Shedv13QOxIDHrEM2Dl+Sk0EUlcMkM5ia8HqrJu7aIKhd\nfZi6YCIgxeKp/WqhLoi2oysB4PqkAeKU3KkjgbXFW5eLCsQFsyACur02Cv+b\ngtUQYJCsrensZnC5D/2jwSWkba13ouSlgBvrBOKVge+xDLi+VpQyAMfP4bj3\n2ex+WXVO4cTu1WThcm4HTiuNWELGzou9zfJjUbjLSVfz00Dfkx1MFVLNdkQE\nQKJG7aYV0sd9ZVhEAFv72p9aCe7kc3aYiTWbuSMZfJUQifuKbtMyz/36LjvV\n8scpAGVh6dezGibRSgGycswkldj1PQD4HH6SIS/G3v6iYdPcJmsMNT6LZ5CB\nNdTnWIRDaqJMbbB08nnYD99xo5/X22zzlzRJPOVWcsKeWgoj3MjQyo/DHIoQ\nYxzlaR5xl/1j3w09GWOCn9/BNCjEMwtaBh5pjf/lbIP1Z852GY7Kja9Xzl7+\nsdO7eBxfSzF7W/zLsBbFPJ4WAUhAdnCEN24/pwU8gAsLqVhoG/WdBM8Qf9qP\nblcz8U9a1idM6krQ5P8+fshSEP1K+xO4Hn+4BrmDwyHbntAOi6+cQ2US1WNc\n5URC\r\n=Fl33\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-2977a54-1594684461938_1594684511051_0.4556618715188123","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-2977a54-1594684462812":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-2977a54-1594684462812","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-2977a54-1594684462812","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0bea8e0e871dcc03dcfc9df530fab383a38d1b44","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-2977a54-1594684462812.tgz","fileCount":7,"integrity":"sha512-qqq1QFbGPtvJSHiHCmWutj4gRmfWt2pH89dKpk0h5O9szLTAU+Bt7cMXxREsHM6cZxKZ0Jlrc42yh+ln99JHOA==","signatures":[{"sig":"MEYCIQC7ijypZuHqYLGu2B9F1eBbT9hZuMeDSJ6qbxijmwiDtAIhAM3A2jcG7ubTte3o5RXYIq0G+ZE3v0NY9xRaDxkjpepe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDPRsCRA9TVsSAnZWagAA5yQP+wXYcYKdR0qPd7wX6Xjc\n+Rm/E0OKiU5+0HhnGxik5o2QfckbQJM4KLICtyRr1dgJ2FpOh5FeGlxuN3kh\nGMfXyieE8Yyy17TVreB6pkuzyy8aSB224ZV/bhOQPUTI/m3U4e3ceyGfQFxh\nMoLcProkPXu97DHQtYmhfVwqs1hPNaK5aOtRggM+mMC+JJyozDOdswYhUgFn\nO/MoEPVMV4R/iJdugFRcrEF9qzsdjMzxjLbLZLUxaMNa8eltole8VFc2CKep\nNWV5awIUdsl2jG4Vp+7odQobqJPDjMZeJkJFo62HzhQ5HWuQilSfwrPLTyCq\nls2zNDEcc8lneV/g6yNH6LI6cG8NiY+pmkMB11Pp6jylGBOBG/9kSo5maCy9\nfgQaRnlaQKfgzHEw8xzyCCCY5MRGPrxuZ6d6rMQkpDD4aiZvSd/rjE9KLgNk\n930sVvcbDiREZIivaElbDlV+pUbrdo74Ev3r6SKfyU1FrORfH9ohLifiS2Ca\nx43r3u2j9qtDOflwiXtv+r71lXSX/BweFuSomsUZS1sOg+0IL49hrBVMuN1o\nF9Q++48PCuLTp3j0D49aD5WiHYNoMmMC5TJ5Kc4s6EwJfU3Zt6Kav/zul67J\n5r7BFaqgzsnsnKDWgzVa5Edf0GyCD3c6++wSFX08oDCw5YwnGh9jgzXmF8yM\n1/27\r\n=DbzD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-2977a54-1594684462812_1594684523670_0.9890620714007434","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-33c8496-1594712079540":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-33c8496-1594712079540","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-33c8496-1594712079540","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3dba19f8d38ac86fe61ba153a10c197bac8eeac1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-33c8496-1594712079540.tgz","fileCount":7,"integrity":"sha512-Sv6WMVAMLfP3U1zlzqir86wCKISfdzHc1FWNYD6M0A9eRXgTsX2KzXQDwINhcxDrNUOFGHqJ+/EjsvrXCveIKg==","signatures":[{"sig":"MEUCIQDrLc3QjjlSf++/mm1+jiJjS7DjZVvM1LCgrU4uo0OQHAIgGjAXW6tr8y+wax+oqA0pTWIEz/YJhI1bW3dAyr5zjgw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDWBOCRA9TVsSAnZWagAAioIP+wac1y4KmhNcv5DEWhXJ\n2KWiH0uNkfD2PRJ9bakF/xbU6PXWQAmhU856HSRAeQWIniM2AChUBY+YBZH8\nNcrRs3PP6DiH0QBoWtKYshCYbvOI1sBdU6ry7FUnhyHrJ04uk0DevVlHt/kt\nElTzJiLt73qITHcPqR17fGMZjeZ1d/oWjEyAD13ZHu9dUfVIOIYrfAYbN0je\nxhZ8IyGMNUb8HoGuwVwEFD3bxZD5b7jJZTrsHTKTn47xbbS/MSTM1TIi4UbR\nbokwWw1ozmPZoa8cgtiC0yr3eDeg9DQyL7dxSRDtQrPXQpiYy0IN6OOcLAr6\nGhF7jkYmUkbwcNk8dZBNo8ZlMQjAk3Ww46o+QdMOt+ilemJv8KuCqDEMyWOW\nA3qFCk6vfp9L0IPfWbaXb0IMzd3M4setiQnN+6p4jmz2fR9EfZyIZduT5L9+\n78wmxcIO9oe3zkQGtE0i8v/WPY8khyUdAcuT02l0IBt/1f/vqP+07SbY/Asr\n8BSF8Mc1kdktwRqgxdKRvJGL+RGD9WGDArYaOsBnmHVxlgZaOiRLqG15cPwp\nxERBEJAlqZ1hg1zAu4XIEXCz+pU1j71J2SUYxGxBbCrjHBjlKJO7Ph7aJDvn\nut6dgqV2b6cq1yEyxKBiI5pgLq6OtCY5dkQapMjEWOcSXk//uFpDAfpL22em\nveJU\r\n=AiI4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^13.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-33c8496-1594712079540_1594712142426_0.13434977858946073","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-53bc6f1-1594764933441":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-53bc6f1-1594764933441","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-53bc6f1-1594764933441","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0ef89529344deadbcb0f301161f05dabd46c3849","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-53bc6f1-1594764933441.tgz","fileCount":7,"integrity":"sha512-o094GeQXgj4Zxj4NqCFdDZ6LCrV9Gobnfsa57io1PlnHEmHsCiYoKEUPQuEtNsdtIuD5FoM3FjF1qMn7/wyoPw==","signatures":[{"sig":"MEYCIQClmg1Nmr/vLr+oiOfvylDqdrTaXIgIVAov+2+Pu02h4AIhAK6CDg5CId59yREDXSmpGqpQg6/Sb+PJAA0BvxNxQ53h","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDi6zCRA9TVsSAnZWagAAgtEP/RrdIicz/dJGlIXmORwN\nY233mQtavJ8tPsN1u2Ul8ySvm0s6/zrEorjrZroHY9ESPp9n/zRjKPdBSyqU\nRMklf5hwbDZabrOQMG0ETZo3ZHp5qvGYKXWDMe7cLmyXN2NZLt9ks+Snw+ur\n7WmEaIz3UO/06UxQMS9etMk/GEJjx4UL+bDZrvLAQI2uQuRcuRp68q9//7ox\n6FmG7ElhBcAMQkFSuQ6jm8JykusJUkDdJKZWMLOrjjgK4rH0aoG+8mfV8k17\n3znyF7a8WVWw2nCJ1zn5LKxQMj7OHQg2Yigk1MQpacvmSFEn/xbAWTRhJnAE\nWrkWkRq/BI2kIXRm2PjI45l0qfhxduqov/kwBbEIaVH4K4Fgsl/jzriSKf+J\noE8ik3HrL/VoF6Klh6RMYFnUNkrG+QqKxzuMDE1VvIrIKopOjdzF6dUIixZX\nVF//EqzYkQZXhp67SkqKSHyIYRDlNiKul83bUu8S2LllqMoLsCE/3LJyEKtg\n77SXY0kK0Ek6yKlxNlHcFqPic7E9xbsF3O/YLqRfxB9UGbgSnxn21vTOR+pw\nm+QXZKfaSlxWwQaXebOZ39El6vdm6j+Ai7ry4RCXe9xvsbuv2W8aRGrp4Xkf\nj83ehYgB22nHp35r8c6hoKsJ8pfPrMdYyD8Ek2iprCIn1oc1gp3y4iPj7QMs\nCICc\r\n=WQTU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-53bc6f1-1594764933441_1594764979376_0.35192170400440226","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a6e3fd0-1594851515219":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a6e3fd0-1594851515219","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a6e3fd0-1594851515219","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b4f3bffc4445fa58e65071952922a648ff645e79","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a6e3fd0-1594851515219.tgz","fileCount":7,"integrity":"sha512-3PKt2xRmN6VFUs6saYwFh69luAsHQEo8ubPVO+2rYutwKD0q/4+IZYnxz5H+1DIxKBV94UWZ/wDfcnD+cB9mAw==","signatures":[{"sig":"MEQCIEAztRp+GZoE6iuPisiPRUVWpySLKW8DAvAVzQzhFvccAiAg41FJMFJzxpsH5W3R9RsSSAgqG9Y3RRJ+Sn2AGngsHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfD4DoCRA9TVsSAnZWagAAqyMP/RSPIAP9M2NiVBgXukM7\nZETd4K6Mite7mV8ASRYe6NAhXgc0lv1N+ziMPn0FLjIqF0d9R6cHiJBJxwh/\n6iJpL53/X+MYUozexFfn6fKwzvWwgWftWzH/9wtuARHUnZJiP7z/qBOJdO8T\nvk6bdmUSVVj93Ux3mOuUz1RUcj9BGMyayzsm6MFxeqc1pVNnRUzMPIzNWUBq\nCGV+fHqMtd5WmHT22xm0B66xa+h908PpzNd1yWh1BVV0bnooMVlpsrh5v+HV\nBhccdprICbUncKTJVEy6zzyfMVJFgdWythu1fM607gPlwGk7dDcMZPbKCxSv\npomukX1Zyox0golNEev91H0lk8h6EsmgaYfwq+m6GulM7k50HZhXd1jIZALp\nhXPBRjlmaiGccx1w+StBVmhHfu/eH7G1KRZWuXkMqSpY7RBPA257Ympct6U/\nhwYwvS41FdsWif+swZ3BP/ypCn//VNOdgZ4O5PTt1PQKyZQBNhufu0fsCWAB\ntmYc1BSif+rKUbatbS/Jd3D323Arbj5b+wQsfwMlA0/+F/h7dPBpFYQOLz35\nzGnGRLdHlC8vp4BgHUn72560v7Sy/o6EpIKmHZvaZAApUdP3avY2rLsmqCcW\npv1rRN2eudh3lscZ/Cnb41Zmy4dFVST+ZToQJzuoBL+tgn77h1h35wbt/LFY\notMs\r\n=bxij\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a6e3fd0-1594851515219_1594851560230_0.0753299564170915","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a6e3fd0-1594851513160":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a6e3fd0-1594851513160","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a6e3fd0-1594851513160","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9cf55b75fb0433b01867317e9e4bc74f35f5386a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a6e3fd0-1594851513160.tgz","fileCount":7,"integrity":"sha512-9tiCOPpkCP2J+uDNre4G/2evaGIO8fvm/yzf/6aDk1T8Jvuq021tej1S6Hbez+6Y1w6xHclzB4ygzY5JjIaX1A==","signatures":[{"sig":"MEUCIQCiP2cn30GceMMesHW4KI6SkpmH/2tw2qbIUTXGpfP69wIgMuVCe0qpMqFEfhNbMGW7hLLHGWpYEEkurP/MZ+QWMco=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfD4DyCRA9TVsSAnZWagAAk1gP/0+W/oDQ8s2s3Ov+RblJ\nFjR0F4exiJ/jXdELLpaAJHt/cx+r08oC121LcoQ0MANyMJMCa/Q86k4XSJUs\nD0Xs5T1vLPOZ7kbuWTMY2/a9EfAlxqjssjyvu+Z5J7WJOG+DmIKIxXaq9j17\njeyEyIMqGOY5//W3FHpvR8HdermSHUyZMbfetu/lwk+EY8i8KKwapQGXz/rx\nR3wPS3H6XRw/k/kcZSwZ16YEm4y7OzQF5USDh3yXxYYXFxa6BDhX/keiKLBr\nthANqRBJHngrPO7cb8SefzpKycHt463K+dN6o+Hm4Oq6Jz7hQRgtQHUu4lQt\nZSgVK4DnRLGvvaUSvU/zHtY1wb9V585usIU1PpjuBPMj1/7Hi7UFxnmPv/EZ\nIFCpT4AEv7guVnyO57n011Z03beP6LFr5pYWwtVHIw65Jck9x6VDaBqFpMxv\nU82AlPd9G9hg8nZqDxvJ+eicNmnKo2UpUJnxMYC8HojCY9mqXXTUko3oT2Th\n73BPm522vWL6fO/ASBRZGbs6IRjXaZW9ZuQQ1Z9XWAnQ0/dASPcDM4MXl0uf\n2920LeuNNRymb+5VSMCfLXDkYs23adfGI7xBP426AsqIaYwEvHQXcPAVLINV\nZPIuQSFHq0Vsik5pEAx/YjAY+Mqqcvx2hJDDyNvg8BisnAyB8yPVkwVsE7QO\nfBaM\r\n=pO3p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a6e3fd0-1594851513160_1594851570497_0.4232432982897545","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a6e3fd0-1594851512413":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a6e3fd0-1594851512413","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a6e3fd0-1594851512413","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b0be69936cac19601584890d96c3f21b3373fce9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a6e3fd0-1594851512413.tgz","fileCount":7,"integrity":"sha512-er55yRhTvZdEgVCcl9ePMZKJhPpk0lBhWwvWWKBprAFdxhsTbEJO/VUHV9oGzW4Y3VST4iEWMZuHbPUDypfIyA==","signatures":[{"sig":"MEQCIEhVqWstZwNN4OIjI+N8xvFWzv7D9P9WiOaqX3Cu2QBAAiAgUuW3VjchVl15adC4ZvxFucZP4q1YEfFTnzD4qvvzzA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfD4EACRA9TVsSAnZWagAApyIP+QEMP9iTT12uBDHiGdNc\nXmCMh5qL4xLMqCa5nCWovxEtFhFRpf5302/SxQVXH2CYmJLMdcQE8KhSrLSb\nfzfOvrg1qOLvmGBTVtplvNNEH0VWu2drsv6HqSsAvlikKT1htzJEeOJCakDb\nEqA3HoXuudSBQhwhE9rxUj3w4lxXvyDCpFHTDI56Q8eFGaZQ32fHb1PRaAxk\nKMdxpZBScmPtaABkJw6rMShx5MHHTRmylWLSZD/C4Icy6YtRVjjUXsfbGkmR\n9PG5TMnV5iFchRVjrzVZuSZeT82aNSveHFdAXyzdAPDKCXtcTH5+zjkU1RY1\nGdhUM6lWoOCGSDAwdOeKhuWwHZ+w16Dg+uRTRiJh1Ix3oGpkKicuuhnG/VRJ\nt81g/OEivSWnAn6yyDPhUsYAlPNao59PhRMOTkViJyKVjYpKm8BQWFvvN5Ck\nAIyJZ2Cx4uRSFhZYbisVF6EDYCj+dxw3AtfggUglf2Uy2Lb5yVhgro89hWT4\nzeMkpHiMmuG6fbdNyoNq6/C1Lr6y52DQITdSDa5aHwbTQamofB9FirR8Jls1\ndAtG+tFYj+4Kzy2bCIsMbyMKShGyQ2uAwl7iHsbiXXs2noSx4zP+tGHKj8pm\nOI+NMm+5a767Ucw/u58uEmFW9/ZLOHnCzU6WAcZlSCS4U4VCzk1+x724zz4I\n4FnW\r\n=ujob\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a6e3fd0-1594851512413_1594851583872_0.6551994309379587","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9cb04e0-1594888633620":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9cb04e0-1594888633620","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9cb04e0-1594888633620","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"98b4535c67206317808983d9c12720a572f8353a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9cb04e0-1594888633620.tgz","fileCount":7,"integrity":"sha512-FuVolEH6N1HNesrwM+YaxRvSnXThtNSzcKVcGG7xqmxhdbCjBnr9R3s9WwcN4VM2s4BAsu8iLB17Pw6Fv/d4/Q==","signatures":[{"sig":"MEYCIQD5IYmouQVMfBlkvRNd4Kgka8ov9g/ugYSJbkBoudBnJAIhALZx9jZClLF9XX2+EE9WEw/m6c975Oq1jub27Llo8G64","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEBH6CRA9TVsSAnZWagAAprAP/R3DO+CSMYW6N9bQ9iRB\nAmb1wizYs3bSDPDHyN/55TRKsuo1qjIAt0jANUATSv5xy+rNigJtu9VCNnc0\nrujMSTacf4J069bTdeVYavrn2VYl/Ap0NfI7JZV97Td9JSQhh+NEMkVdTlD7\n7Z/t0AZrNr61oQcgYb+0NZEja94eZUyuFYSIxoBAYrqUajk4mWSWgZLm77Fx\nlpyeTnmqN5hGxOLNX1BxGFbs4mJzzBZgYRVvr6MkAtQq35ZbKXv/MN9YcmfF\nYFam9s7CeZUpbbNjufhNv3iB1jf1oD7unkw/E7Zm0IxE6H2pJuXtOVxpAMmM\nZzA7vx7jVQgHTcAr55lUxxUb98plNgN/K4kPwWhjl8d5k+t0mabfH5c3R4H6\nfelh7TpHyr9SSqCrpYjvxUDB6PdjEN2m64eOMXgYnd8Yg2KGu1NL+i/GAM2/\nwOOv6qgcGUs7TeCFsY95qo3DKFsRGMkieMwPNKXzFC/vqeadzw/seJyvSjMJ\nC9Yrps8xccaV9y7gbfUGtLY4tSnp65OxuXl3Ovbhg3j7gWpKDr5x5QASB6zE\nm4bRkKtR2x3mZQqhNccjXHgoGSL5HfQApL/HqrtEQqc+qZ0HtmS4o4Os0n9X\nrMvXgIX4h61sVUX/OpPjVMagoWYteOi20o2v8qtKWzIo6AyYcCmrHeAuJxpn\ncl9W\r\n=luVQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9cb04e0-1594888633620_1594888697820_0.5705111395817235","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-379e9b2-1594888650110":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-379e9b2-1594888650110","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-379e9b2-1594888650110","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0d184db1a53107be5a8f8c20e295270ba5d92e48","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-379e9b2-1594888650110.tgz","fileCount":7,"integrity":"sha512-Zb4lxdJiZxAUrhxTnu28/IP6ltx1GtdFen45d0BTo4ZTGIh2mDVzAuewsfEO+oavpkFHkY3oWak/dtBZqrZ5ZA==","signatures":[{"sig":"MEUCIGhwh7hiquvmdoUqGq8SUVqgSI1qXWBqv3XYVmuCdNKnAiEAxJ0MxJ09wrsQeBEmaD3kQjjW2Fdbv+n2IXAj350aJlI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEBIICRA9TVsSAnZWagAA124P/05TzokP6stLnaFfVNbW\nG07a4Fb0qK/wcHW8mSJQa8T/p0J2ThAh43v/aco9zpuETRBYaT1wzD0zGbux\nFv+d+im7bURgDFX4eRmR+axGHNOfhBv0nGuVKjP0ThILH3bLqCXaPLOdUruf\nXSaaBT3FwUlMt+pY+2bRkKgcdMEIHkPyB+3e9/H9+PzID7SF0EfthfEgTOeT\nln8qywzkT0Pn93Gp0Yv4CmBR90RUFBsFv43tLwPKEPD8lbL8QT7B0Qp1+D3r\njsZIbrJT4QO/uZKz66YyHiwHx7/zBHAwzO5omOUTfWt6j40HCdOgM+OYYJET\nAYfG+Ltf9M+mflXGj+eyyc9gn+R1VmV6u6/CiQeeApApp2BXQaYvjD5yuhTr\nPg0ao7fF7xllg2I6ptA5oJPBkDvAb9hRfUCq2AaRKSKns5Q1BUKqsQOpbuOG\nv8AI2VtuSRXG3wG9YscS1JR1yk7clGizkSGTAjf4h4YPFqDNTrF+o/3B8iqF\nu2E/qSim2CEoNx0L03uV2mnwJJLiiC+diUX1sU/Skir3465xoTsn3ZlwsNVE\ngclLQE5SxOv4ZRTQzt9fTMMxhjxKX9tfFttiuiL2WvIIZR8384D7U6yJf4CM\nd9yztZfgLYqkkSceLAwHcILocQ1LjJrUJEqAcDXDD+2ze52tLwu8IoryZAZG\nDQEr\r\n=yC2u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-379e9b2-1594888650110_1594888711637_0.991486249521885","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9da445b-1594929200743":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9da445b-1594929200743","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9da445b-1594929200743","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ae3724dfceba3eec2c189f8124cf55c499687bb4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9da445b-1594929200743.tgz","fileCount":7,"integrity":"sha512-29QYtPAA+AN4fmBsornpOxYrBDngDLR7NSWUN4zoOJjyYS/6CuHlAgQXmK/yfCD2oGXDeZYmMW1BNEHr5efoMw==","signatures":[{"sig":"MEUCIQDjnauSDSziWxd0COxW2O8ri+2RtziG6K5l37sI/yqyEQIgAqncobFP2qCv02bYjDACnr+PaNS6i8/1tYbbFf+XHXA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfELBgCRA9TVsSAnZWagAAWJwP/0ekvzhSDuQ20Ykmd0Te\n9kLRFgCPsGij59AnevwtC/BFxMc3oE+lGZQNIe6RNR4ytxS5U6CFwgwBRO+R\n+09bXMFWDiAQrt4InxLoBKF56g4OVcwZunOiXEy/J7fMQmOkPyIJpnRpttLo\n6THPQ4BtQXNxQHJBcLN8spZ6xFk5pTxLFKBs86qx4Bop1rUjny49tXEG9B5A\nlWWKFOLAlhRDzlwgykR7B4xxfiWZ/TxfmfwXPGA+ydx6m/MG49LYueIt0kB6\nYRrZ4OS3bYwegdeuoPYds4MUPvxrYKB9owKh+0QXPL+4Dgne9DWkY/ycj6Jz\nVzmVmfciIzY/Ep1h5S2ZYRalvdIjEcngYTqppNzCwDebFfs4TxXW46PPDQb8\njmy7PCOowFhjG5HMjcWmvBJw/f3EhcHO966Scj/l33ozzvvxwp3R6UlSmNoO\nP5qGUwO/4FmlbRnNedmBG+An2a5yfYSGmkN1OcfVteNwTDCs8ZEWoIatRgoy\nMxUd45n3xujhkVskNqHtAaQYTk/KX8mnsqRZbb++L/wmLz69W72aJgt9osvO\nmgunMxUxrCvDmmThR2Uh9XBl72dSe7hrwnhj+lSb9oSwbn5igHqWCcReagNH\nZ+E3Ssv8G38cjkVy7Qu/qPOl6GkwyBbvMqA5i4apvVhptpBnKADvw4eded18\n9KK8\r\n=4skR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9da445b-1594929200743_1594929248226_0.8848775365550512","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9da445b-1594929201253":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9da445b-1594929201253","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9da445b-1594929201253","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5bb42a878f456ce7cd5db0ede31afed139affdf0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9da445b-1594929201253.tgz","fileCount":7,"integrity":"sha512-y3ZNU8/NlUPxeP+a43ByZKZknAOYvhTIBVg5Q7PXRnB3eOUZSPXD40RFD+LpGYS4Svr1uz9Bwuc38PTF2QsATw==","signatures":[{"sig":"MEQCIFCnNJ2VxINi26i9Lf7rLHDIoScb0l8NAjumXle6Im5FAiB88iLKDVmLOxSWQFPKuI36ktp22bdOPyvoFuirmmogFg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfELBvCRA9TVsSAnZWagAAgE8QAJ56DGP3dZNKCAaQTrDg\nqb359x7y9HB8jSmlWtqVH7tfrNXMNs1l3meGyUSMLGuHNn8Kg8YkyMLGyTnX\nco9wtqfjiZm4wBurSLNCPfNx+hBB7DK569iIMGFtEiftr0ZWFnIKTHRv9sek\nq7C/hPwo8zffw9lWOREc+6SPJoPYvIsgI30+D32FGuXxbt/8ze/w3VbaCL1u\nmzohZA2YhWqI349FhMVHQix1euxWZqKXYTSZ0w+rgFkZL2HlCNSjoV8M+OaQ\nvOdg774i2YgdkELypayUA6CXjVHO9f1coO4xPMB3xMxLhoVoziktnX61iuRF\nOLwBQsqNgdyS1jj+dhsQ1MFgIxcjBfN/eqgeoulrMrtD0dup2OIa7Fe9XDgQ\n8qqYm+p5m0rWOZdtRUoCWodIpAINOgSb/6TGK3Fqb9BcVxq/8/UjPVNiAhim\n2G6kLiJimQ632MEH9bzC15GeHkEG13tsUsrgHQ0kVdhyW426AINdMfMB2mA8\n3SiglG8YWtikUjVOY2nzUAnqX3W5af16En+xEbySeDxYPYwyiZKljTzoN6x4\nv3I6pft7FpHWyWLNfA+krWBZyB5NqLLL3JA9oXuqe2Z0UepC5nt+7CTjJgsp\nTrMD6c348M/IhAQXvLwa7ur12hqn1Hb/u8zDnWyGZeUxZiWBsc5v2FwuHKRR\ncVNS\r\n=64oT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.2","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9da445b-1594929201253_1594929262990_0.7922622214983333","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e85d998-1594963537461":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e85d998-1594963537461","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e85d998-1594963537461","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"64b60a6240fc8f833f4b93160b3dd3af903cbdf9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e85d998-1594963537461.tgz","fileCount":7,"integrity":"sha512-9qBDSyo+J8q3hB+RmgzGLorAkhugJiRWUlYvrkz0RX8cWsy8AIeJoY00kCORL3oPSMguHh8HIdxpBtYY7roXYg==","signatures":[{"sig":"MEQCIENYS4l5bIp/E4c/QukuS62XzSfZAo/HM2Wuwnxzty+TAiBRifd0M42xdzUutnpZj0L5/DcKPRM2rwodoFZsuVJzZQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfETZ8CRA9TVsSAnZWagAAVWMP/0YrSoTEjxbrMAVsYXad\ng7t0bNQjnsYebI6QyrUSKWA18GYhrhkemdnIPt6Qjd66Xr9L4nvn/Ee683uK\neAYhKYQB8RQ023xzmlsp9ek0jTSuH/S670lLctZW5Kxzf3NLHy3S6DVPC+eM\nicbWdKZ2xbgjCrjX8Jj9rxD0klh+mNYsYLSSprNP/R6dMKiwsE36Xn4q1J/R\nAyCRx7tE515Ox04NBrm8TYeu9mrM5ANseC0B3qY/V421J7RDISIskF2WdINb\nCgNHqnXLn3LiAuqhbgPr7nFHHOIKYxs7rmeDdeW0uICOpeVU3lLpW6Suyz6k\n+JMST9h15z1q7Xvyei7F351xa5YFKAm+vHlbr0ipK5NDgyKni1Nr9c38izCZ\nNxD464arjEKpCsvSETBAsYAZgQr5si/cIsIZLMcON1MmbUO3GJs4SdMHiYOg\nMetxdcYLVSXSN7yFLiRWgSIuftd6j9TCqHodzfJED0QgdfWu7bTqLdeX3qK5\n0sCaP/v3+xxsgTnZi8VmZ792cMP3aeZSNzQRoFQfYLukuhupcUl5PR7K4ABZ\nwSAAfr88vR7abOcj2ddQkfY9EMAk6+mOjc9O9+mULYxAnBZu8F7mSZ/Jvlm4\nfJsETazlM4+37kleLCsRK2Hitg2plrGg1TMmoZDviWc75bpYzTlLyV8LqbYO\nKIqM\r\n=+MX1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e85d998-1594963537461_1594963580037_0.17573867156990008","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e85d998-1594963539813":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e85d998-1594963539813","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e85d998-1594963539813","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"044ee4204f30b6775922555595117c7eaefd41fa","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e85d998-1594963539813.tgz","fileCount":7,"integrity":"sha512-2DWIq7YIXa9Bn/U/r6Ehfe9oR2wIxYwmy4dR3QuSzTigU9gO3WBfP++RQcb/YqdQG8wxmjOubGM8XXK91iKfsw==","signatures":[{"sig":"MEUCIQDM2kSykBqJO7lsyAsH1zjAXkvWsmz4THg7RlCM3gOzZQIgTzfZvi6DDRa5d07RJx+pbYKMvcHZp0GA7eapYiTz+LM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfETaHCRA9TVsSAnZWagAAA2YQAJRHamNW6hgp8jR/SqQa\n+b5pvN4ABbqGhJPOihj9Vkq6QBflobXShv5MoxqPXN5UVs/8d7cwpvJAsHDC\nu6eIzyl3EVCe9LgmdlV/w8UrORoaoj9zVByqq9pkMGMCjNE7zziAmtUSXKj9\nhzuo+DSr3ajeyLjeUssfn6JuAs2y1MG1D622eVxGpF+d3QcfR/cW10xFMYQh\nGAAExtD2VIJs1ekUDCGUEcKWvYvICM8VJFkTVaujKhPafrkokZ3Oi23oORfy\nVqN50DO2XWC1v9wzaIRJmfoxHPTnjRCsMO/WDPXyGZirtw3Nz6ndRmSMtqau\ntHACReH4tGyIMEfgOfRS/GogIedj9W6WZQfOtD6aafUOWB+8N1eIounGFecI\nRbo20rhIBfNBnCNLbT7ldkWfeMm02gVRBaMRdM2jsnQ0Qs+Y9m05tslMsnhw\n1NVJyNcseljH84m1BPNsj67j2fLvfsgXzWXi/HMvv3OHKWnUa2AFMwZg1SLK\nf0BzcxEBbLoTipZXThSvGtTnRDsTMCJdkZeUAC0bwTYdSCcumerWU9IeobUJ\nIDbuK7GnAxXV2hLy4TdEsYlxu6K7jp2lAiQK6ef9h8Ag2Dd+EtWr5KH+XWb+\nwWwS/AiskaYDEyJYGo7R8HAW//PiPn7u6p6qYkmV7HxRe2nvYyIpPRYFXlID\nwEsM\r\n=7zl1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.6","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e85d998-1594963539813_1594963590699_0.3290589331704845","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-406844f-1594968886419":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-406844f-1594968886419","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-406844f-1594968886419","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f6e14d2ff1664c16d5531d82d1d9f114bf40d853","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-406844f-1594968886419.tgz","fileCount":7,"integrity":"sha512-WCUTXB4G5FChP2FqRS7btoVzSSIGlyCbXK21Y8OcUhMDqt+ss1kRPX4pOxItdyt1wSmKD9cAia+UXf7uG3qv+A==","signatures":[{"sig":"MEYCIQDlm+aASyCBFxVyClMITYK729y9MvRWvmf2TscDd456ZgIhAJPFyN+h1dWahdFMABxQ8DP/aypnxDZFFIZKn6qNTD1N","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEUtkCRA9TVsSAnZWagAAAzoP/10fA81eJkR+p1YM9Qc1\nwoUcJSlnuDhSfMqBH2qKFgULJZsjEh/8SC12WYw/fI3lEcfT3rHjvJQIkdtu\ntZrG19MWjgGCHVTSrYV+0/2JwNWB6Tc3ejCx6RJF1C4pJTg5DKbk34SkajkM\n+WcJxOqqP9OSGPJA0o0hYTPt8t/0vA3vkPfj+BsAMAwG470hZmrcHAUETgl5\nfHrM8TwiMZtvyK4N3O+zDPYJedMMyN6k5EUmJOhzrD/QfEOzEe9mTFVsfUEV\nFp5vTYHBZ++jTE8Av5JVtmB6GCJQZou5FaWzBsRNfpEhmWxSknJUovyAEEZ2\n+FxF+7pLxuO/bYgFCNdg2XLNkFc1LjgSnjMZ71nq2eeVt5lLuJZpEhxrLr+0\nfpxvbx+oTVO41gctnbezCBlsFgJ2OtbZc+fGSaBvMIi/ZbO+cMhSnd3++oXg\nCLRDH5cgFC+Cg11eW8zhrAUh7ZPnjzuyALDtQIe73znxaI0YhhpYcvrs/ta/\nZ0RDvuZUEcRQr8vCKRN+RAYEl9J5tW+aMun0WG4X2t7anEoiMtaQkspJeqYU\nJyOIGq9d1fhwz5BPt0MJotsmYpBA3cwljkMyE5mni52lW8CHdjL93Mov1iA8\n/kCQWVsb6YGdnLOGi/3biyQKQK+MVHHSQpB2GBdjElWWFO/5u7ChruU71Cy2\nY6gz\r\n=GZdg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.21.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-406844f-1594968886419_1594968931952_0.3528181543560538","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1b89299-1595047682462":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1b89299-1595047682462","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1b89299-1595047682462","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"02573c282c81f54978c5e75dc3d1ffabc697b420","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1b89299-1595047682462.tgz","fileCount":7,"integrity":"sha512-AG1TMERNwKkLKjG/DjuGP2eIjx/Hmo/k07/iKi4kE/pUt8HKSQzj+NLSU+DjVJD85yIkJhcxNrDgPMSFcO12FQ==","signatures":[{"sig":"MEYCIQCJquru3eZG+kAN988JTYMWwOkrrQPO6dpWRa0IL1QsMAIhALhLfB7Z0+NkDwaiRFrI4GeeaUK1OPKhadD7y6e73bu2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEn8sCRA9TVsSAnZWagAAgvMQAKKDVpWitW+B72akZuzZ\nXPQJIXKYz1qjqvUZegqxgMR7dr21+OjP2O4aYov9WStGcYxaAE0ijkd8AznT\nMn5fWZsexOBCPVDUhHARweczpAZP6USN+7VzMmZVC9O+dH7B+2+AUEdugvOT\nH3y1oZRWdKPWlYlt5fCaduWSa2dbVJVQiNNapgJ4qEx3Aw3uJX+fbzwYHoGO\nXWuvbpWh54zYqeliANKtCuBPUMgosENyRxT4XeH7G8K+0ytw5tlLaoDs9aq2\nSROuA9Vx6ruMm8zHkxHr0jazIdWdszlztcP74M4RQuG08zspIxsDYBw0TtQo\njvEokVEC0b5xMO7xwvBqS+8SYWVmo9taJPJ3bQDDrQ/huQKmjHeVg5NPvczV\nRT+jkDqewWUff/k9Dplp3MK7j/QxDRHSbz0LVP0oKElSPq40zO/bkGZ84id1\no84la8R0116IzPgUXUB3q5/tcd7ZuU93UZ5pKKUAkYZfOlRMNblIhAfQQb+a\nu1JmcvIudT0R9M9HpeLUD9pzST+LccfBINvLXAsKcWEfw1PKrT2igkTbuQRQ\nmnGQXdRd55Hnf5t1ppXqbDH+kUNRBORRWF4lYlFch4kTK/Y793/7PtgmYN7z\n7d1ImjfteJOlyvTyOMHjPbYsUVE2Se0b66+78tL/iovKzS7+cpLdsXSLnr6A\nBFXn\r\n=aN16\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1b89299-1595047682462_1595047724186_0.8824025089768162","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1b89299-1595047700113":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1b89299-1595047700113","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1b89299-1595047700113","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bfd541a42e337c156cc3cd881c5f68775157ceac","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1b89299-1595047700113.tgz","fileCount":7,"integrity":"sha512-Z76bYCbtPC10J3wuCgH35ZVL1yy2zIrXZAVgnjPIIrbL5aahJsoQrQYNHvs3mWkHQyzPAKOdlP6ZVaMECOBh0Q==","signatures":[{"sig":"MEUCIQCN4uidDpqEfAwvpxrCSjK9fw+X4Ue8qV6yOlXXnygu0gIgLXxyGXZpYr5nAkpvUU9MucGxVDny5hj/nLFhHCWL8AI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEn9LCRA9TVsSAnZWagAA2pgP/1AampZW7OYb0hIFS8gv\nn1HAkDLWNTmBqViZkdSjgJ7nrCJuxE+dSCvErgmFy/+ztrk15lNsOxn5d5RN\nQ/9Dpbac5ddk4fJqERhqcxkri3FUuJm3qL5iinK1mSN80IyzuTPeJSI55jHk\n74nnJD4FQSpGIU/GkaanrhivchtNvg0xeLn6g2XGghjUVEn9u8aSZ2+zI4zb\nNHyjq/aT6WYeJ7TIvBf0y65DXYyl+4TVX2MeEH07c7tQKli0gfvdSF9gLdWk\nwbIYh+9nusipHdL81AKefGesboDYFJcdNjdZpSgRbVCpV+tU0yItM9vKqUz6\nuOmBqk1XvIU0yNydGGZgepZFa7LYrW0qWr0gnY+EW5Dk15qL3ieV8Ft2Z5Nl\nuTH6SEHX4ktk0disxCNHFv9CSVIWGGPz0Tb5M+fxtc+01i7qge5ACvNY7IdO\n1B2kGz+ctR51/dSAIyWKdLmO0MuWUmz199BkdRFiSdwBKyqNWhK4ZSDe6EvB\nYF+p/l/VSDCgD8S04yFouuEojDCvWWDbK+CQaxQ2TwP5XNE5RZt2BzAAFwId\nHpPqMjcoSM3+WjUlcRzlXxqUNTdeLC8J897C+nSU/VlzbgABwXLT4eOPT4zz\nE/DJ74WCvxp9n1sb9sABxObosZNwSTkUJ8cszIKxDh2wSTgL/zR/Hxmgcdzf\nzJbB\r\n=E/jw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1b89299-1595047700113_1595047754796_0.6000428357094405","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-15d40df-1595052603714":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-15d40df-1595052603714","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-15d40df-1595052603714","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2bfb838b4db0e0eb27866234bf010c294aee90e3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-15d40df-1595052603714.tgz","fileCount":7,"integrity":"sha512-sEMHE9kgXVAd+pZJKJknUhKfOSMu+suxw96Oq9rxnsYV4yX3LVehjMyP33ksRVpFubgT5+e7ZuPF5qmaXCKdcQ==","signatures":[{"sig":"MEQCIEGkQXfj8SHxFVVsu18qcm6tXcOvMeHMFxNkrImLJSfFAiBba5mKGZb11SidjgdxSqxn/2VwFXcWeCKQgq1yhzFnGg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEpJ3CRA9TVsSAnZWagAAkIoP/2o2TKkk1YNT+E/jdkKv\n39KMDG+vqIy4Mv3pH1XCvkXe1GOHfNLdw5zarmxUjqau9WGPyTxPZp/A3bcB\niBwpP9R8M2Kiatn0gs5wVjWha47jPHaEA4RhY23QKJwmof37lXb61Miw9uBI\n5L8o+qdlHpyPLrz1lvrPV6F/9AgI59XjpQJ7EopzhK6rLgdg5Lzkvi9hcoml\nFtGZLP4ivl6uvES3VTg9qEOH4tdMmJT+6vIUoSAqDZHi38/tXlhTs6g3nJ36\nWJXIhU8cEtFgh3owxk8lkzQv1FDVTh9DCCsSz7uMnyA3CsWYIHIXKfLmpv1w\nIVQQjfoOhTpvzVyJukHSlZe9z4yWtnqEZwyTRaDkyJetv2dHVVufNKf0N+sF\nTxtvLn3631FgRVn3PVAGCRHhNLzDtuU6mZOE4w9zHoGaAy1T0CBtvTBvHil3\nGOlIOOWfFjgYbgGaPlmqL49gMea7qWlxaN/EIMKfCsifVGRf/iZ6pclPxIGw\n4J9UVXbSLbbXPoAdHwsgqSaZ8PskHfMn49VOHlw6SDyBxT+gkF65doECv/YN\nBYLsbIA2D4D2L7fQPNTJBsQWqAWyXtyPjyUKmpmo71pyMD8Zoiy4ZgvSLBJE\nlR9yzrIIO/9aDUpSsEHjCsIPAYqU0VpxUurYUT5tMSB+xs2vkcDuqFhH/Gta\nkReM\r\n=Pyn0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-15d40df-1595052603714_1595052662889_0.6233586916559792","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-4bc65b5-1595052865085":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-4bc65b5-1595052865085","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-4bc65b5-1595052865085","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7c6d14f045a32de15ac6af0555a6bb12096c23c4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-4bc65b5-1595052865085.tgz","fileCount":7,"integrity":"sha512-2eqZO9idtK/0oLPne+ziPgMxY+r2IQ8V3G6f1f7R2gx5KNoylcPFkM8cs513ScfkvAnMVjXeJC3diwHCCZbo3w==","signatures":[{"sig":"MEYCIQC5Hvodi/W3wspoldHmCbVizZEOmPFMt7+C3wYDaJWBhgIhAOerHrVW1ONObCFEH7+hAaKYM2QjUCSAFxtujH4LcQud","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEpP/CRA9TVsSAnZWagAAW3EP/ikoRMOLkkGcEF4xpagg\n3tmvxIgQ8/VNwlkXFAuvFyhbZxstJL3Ff/qjInVoMFSwsbVzrTtQPdcJMOiN\nX74Rn1C2u5pr9BwQGAKVm+ugO2SG75OGDRi54+vBEgZ6f30Oy71UZk5/rFVB\nB8e34Sg72SsWEPR8asmep/Px3aa8dBHDfU8AvXEo7R5G7dNGIl125IWMJQYI\n4PGWt2A2hXyrTkWDfcCMSEdgRn0BuGKJEfO/He+Cy1c9tMy9z6HOCin5eXhB\nf3r7fkg44V/YAGawNxuosn1cat2SiUjLA6M+s3c79UdnIKoRkaAaoe/dfzXn\nBVKdwnWcV39Miadi2xwgs+Km2S0Au64c+OxKbXLx+ENzX5a7eTOAQ6uzntWQ\n8UpQq+UMIlgeUQBcyJ9D29VchxI5gtLoP6qkwQkmFpvJyYgQvUdOVlD+PVNN\nlMNO4+cIlq3+hOGs6Mlc3v1OH5lkAEH09kJmC7J+GHTther5dbFXm22ctK8i\nbfWRoFu6146DCm+iQjYl1vun+bE483b+fV3n/Rt5ZegOrKAUTM5nHIDMeCbN\nMue4Zvo+Ups3EO2WuDsVpssu165ugu8EaBkVtKeA4CPzczb5sSaa3pychIIv\nR4rLT3ZKhGRTHIowcy5+mZI2cO3T/2/ECRTH75UoU98rOqtvgfkSfOVSg1CV\nOopx\r\n=T1Ab\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.3","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-4bc65b5-1595052865085_1595053054844_0.09978585459126688","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b59168a-1595089727762":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b59168a-1595089727762","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b59168a-1595089727762","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9d873149586bdeb3c9bf1707b8a1caf82c2ce8fd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b59168a-1595089727762.tgz","fileCount":7,"integrity":"sha512-Nk5o34bMPeM4/bNZFbSJk9jqdKg1/cKEfDv6GnoL0HBfKVC5tArULIYgzetNryRGvz/R3RWpF18SoeTH2K7Vug==","signatures":[{"sig":"MEMCH2r0xHKy3+TVmY6/wMO9Q33EDi4o8K2gR6xL1JW2L9QCIEMFUZu8cj8M8pDrwf+BaSGJuMKomT1BNpoi8SjT+wRl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEyNoCRA9TVsSAnZWagAA484P/RngkndzjE9gGCLySGKB\nWIGMUl2l3OtGBoMq2qRGR7gbW1E0oYYtXThbvLbeHdzugJ0TrNhBCkSRCZNr\nDYwxsae8q6ysnm7axswF1fPxjjoRhD+xw4MhY9MdDiric6kfA+3QO0jl8mCr\nC8nyhgiA0f+mq2iZOGP6GPPFOM0oDk4shyvbAYmj+TxxrKyM7Mr80VAWW1zQ\nlvrsAAKUj+e+QG1eWzbZIu7MQY0qghHRSDroC04YdDd/gm9aS1ZaAkhkMHbc\nVzqeMNf3L860gVh+wclZthrOAhP3woAvdcEZvJqkTraKTndYisISmZM2AEY9\nu5SQCz9/QAUVcvrSEzUb5bxcHkdZLRH77HfJjZPpcpdl31z5/A1he+Ek9Ovs\nTli4r2Yx5ZTlyc8lBTaT3TLes2Y1jummX/UnhE41F4BTpl9RnprJCw3FFDNR\n8B2ezOfWOIh3NnW3nX5dyFr/on50jP6OUZKXjHCGOgSRdG4TRYIKX9MX9hA0\nYdAXsStoXj8fu/WwCDyG4/h/veuorKnvLon6LEjst7/0jzUJ2hq/skUKjyMz\nNcWzudjtfEKZsGo//zlwYbjt8kKfxxTeta+Pk1diJXPpWQDvDcnQxGXZF4ep\ntCZdZM9+yBBXuBwbohyQrrqeXJO7BEGeI58W+I++taa2LEIKGTAXEha4Q07I\nuD+S\r\n=wrDm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b59168a-1595089727762_1595089767669_0.23519521271446497","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b59168a-1595089729543":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b59168a-1595089729543","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b59168a-1595089729543","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"40542b4c057eb5dfdf5307d4436d71f81dfc6777","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b59168a-1595089729543.tgz","fileCount":7,"integrity":"sha512-GRpii/TTesAxKufzH3YrP2X45JcPsf3rqptUxyoWs4z3fT9hohnkksKnB+tNTsPITkiRpNPJtHfcCPRuqXFumw==","signatures":[{"sig":"MEQCIB5bqdrI4tulwigbE8sOpr5AsmdCN3y8DJGMzV/REjomAiBO2x7YX35hL5KZm6rd9iaNriXB5fUYJ0bMvqTIazQnXw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEyNxCRA9TVsSAnZWagAAZJ8P/irU09lFuTmDyX/labwz\nlVGYZ/bMoL9cpvWI3moMv9HrmvhTYGTGc388UcVQMAlauU+3I4wzV2g5JV+5\nHVWENkltUDQDs30lVDSY/Eikp+9wQZy9lBDo2/sRx5aAto3N/+uQmxRcCieJ\nPe0v6FVUutf/1jyOWlzcaEOZ5rA3Gcc8H/1kQOPwMHO49mrK4A3xDDnvjkM7\nlGHlFu3PDDKV8gDh/KJdimI8zFmH6G7A7ClD1e2Z7rMiS68Hytl5pyyKEDSI\nHGdpZaaEzrZ2aUOpr0RTyRIBsqYm2z3k4M6AKTdM6KLgRMT7t0vKhpzYGTHR\n4ahwqCZENbRtZY3kQdz/aoPRC+33Pue2qIZSyQAHlrV6jTDozz2fvugm4z/8\nv/B/4CxK/gI1wHbExpmwI0g6XC3mGBPXw/AvkrY0f5dJBpcCDHS4vu9aJLde\n9EW/vCXtgN/W5YLZ+kaHUH5VTgC9GzK1CXRjEvm22CEgT4kcYwRtlREZVjy4\nKg1nzotWy/OubIAU0Ka7WMdaIrmpqwKVRKUpNfRk5NQ+f+oi4Yn/Rux4unso\nI30jxthLlk6QAz091xI9AUlObcOfjkGbFKp5L2kq6u3l5n+OuvJwO/LX3QAR\nsoCKSsq+RSopdHM+ijV4BfPE49Tgt7sShgi3OrShcjAmj0ZxvlaqpZUlJ2Uc\n5TtJ\r\n=Pjge\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b59168a-1595089729543_1595089777529_0.5601362117338855","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d68ccd0-1595100102604":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d68ccd0-1595100102604","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d68ccd0-1595100102604","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"af413b465d8dd6e682b1861ddca1e2df583a1fb5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d68ccd0-1595100102604.tgz","fileCount":7,"integrity":"sha512-47Eva7/+XnO06SkVVrqjlxKPSZR5+zl9j8G+QASMYQf78L4SMDRB6hNlfnKabPbDAGag7X5lic5ewa1EsFCgkw==","signatures":[{"sig":"MEUCIHPwKZa60smRDQ9MchRGUE+X9OW6PIxWMFSdt08Y/kFiAiEA/e6GLC+JTQa9NF6TNEUrim6XDSgs87XpBK3ZsIe6eaU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE0vwCRA9TVsSAnZWagAAH4UP/ivgApcTpbJf9iHSTTFm\ndJY5ilbrD4ClyceWamjpH5r6kD7ygipmaIUxwCIh2fGhEdAz1bAxmXmjLVfQ\nJmxqD/2OqJ55J4ySHayw/Qu0C+dLg2iib3+yrOnOCvJb1thvF/57C2N1mBZU\ns8Xvw0F2u6aWvNA1AZZfDUXZMhIODvbfJ0TdjUloCCVkRcZ6IaOkJQ/cC+zZ\n5Zo1AreJsytFuv/gVbkgVvjIrOdSjsyBVcWtrD1sblVAk/laOGCysM8CGQhT\n8YD5+HGxwplc6TAAQMw5aQwbQywFEb9fEWLxpX/3YwJFfaU1/F0SdqcsyhcJ\nW3JcgMObpEFP2FT3FDIWY9OWoCjAGrD8EhWcmUQBth9X7dIJpbGoBdNedBPH\nXQ9Rkaj4uOJspUpq/IT85jWkw0Ypg2B5Jv6dXNupxeFXk4ONnqzoCixWFy0s\nykkm9d+SJOvgCsIZRo22KhhC2FvhM6Tcq1+W4D+UsiNMjDswNBe5caCfubnF\nQHlK2MZwgb3XH3o5VMnxLk3u3Ykduh9ZJpU3v2IDKZp/w8i3hj7KUDcWZYxd\nEmNJaJo0nxJh3B9DS2/06pEx5xCFawVxKH38F/gGVse4Pjno1HQ7TwoFSZH6\ni5dYKEakn9Qmwc5r3IqeFI8gl4RgyO+3M9r4pSxe2YMsBLxIdzQHmn/PsUs4\nbims\r\n=6NqP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d68ccd0-1595100102604_1595100143855_0.46377752484261325","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d68ccd0-1595100106026":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d68ccd0-1595100106026","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d68ccd0-1595100106026","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"523e020ced850afda63c7904da43a83c5ddfd039","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d68ccd0-1595100106026.tgz","fileCount":7,"integrity":"sha512-N5J2H/aY3BOubMHR6iwOFmP+IAz8Q7UMakF/RNjQA56Y/8SPcLv3li59fBHxojPfVtyPLgcUmxW1/BYP/wFclA==","signatures":[{"sig":"MEYCIQC/pi85s36znKkpTdkpGwx5Ev0RyTgNfUujdwfljqnCSgIhANlmGiiKCrAFdhCOQ4feGOPPeZaZJPJ5NwfSc0FpEKHi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE0v9CRA9TVsSAnZWagAAEF0P/AyNwSQmRyVHIXfJu1Jv\n99W7GmgSZ6bqzZzhA9enfYfMefqdc5gOi3kDsGROHE8VZquOHbxmDiAG345R\ndDgvrR39htDRLekrCS3Ik72gwJPhJc9LbydT+VvNpGY4LF5pO98c+wsmpkZ4\nk6h/Z8DLA8y/rP6xtR2QySnQ0cE2CdZs4BBtsK56+ckBDyHd5c6kRjwMdPW/\nem1rP7nKPRkUXWvLsALVDuZT07M+5ZrKZmvggBywxSLcIl3f5P4B0bSRH80H\nJsZf6Iaf/VmAE/yjGG4ZWiRok6YbBe0aUAS74n8nUNnu6N9/lSE+bEN6AB93\n7kLEBe0TriAXI2ZtaqIhKYn727+3uLY4Q6GnB6G7Qf5ywZkLZROyoAN0Yof/\n7OJ97hoZGIUGDnCR168wDZKNAoJtzdV3poq4T3VcIs/3FBTBuKxdY8ZW8AaR\nfIwjL8+c4sxmtSsnMWpPR/pTzMwAqcSAAiYNEErNIPwZDVf+gT2AG1+38gcO\nl0Nu7qwkptVMpeNwCLhZ9lvFA5hxy0CSrwA/A9f6u+n/c2X9G/SyU94zmbCR\nVjVNxgctAWlIuunF6TslAfDHbdCPbfzI3xFig7HlSXiuhwCWHW2+QLCnq/9Y\n0IDBzbpac/XXUwm/NZ6eeCeSetkWnYVXxalqyu3le/laQ881zqONq5XSwm/W\nfxd7\r\n=B40o\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d68ccd0-1595100106026_1595100156777_0.7203865909972227","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c15244-1595100183220":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c15244-1595100183220","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c15244-1595100183220","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"99435ac1a65aa99a8dea1572e008802633930b51","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c15244-1595100183220.tgz","fileCount":7,"integrity":"sha512-jr97PtxEQ4Y5PrE/bB4VdqTbZBddgSHP1yQlqKK9/o/mkxgJFJH9+WKSfTvMlJxvaza5glW8l/e547t7ExqSgg==","signatures":[{"sig":"MEYCIQDCHztzNZhcWpbbYH9pS6RxMgpipL9effmHwNdBHElXZgIhAJRYe9IymIXv3v7C4V9n/aa6vvtsBqsOm+L95h82Nmfb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE0xHCRA9TVsSAnZWagAAA3wQAJoxdGQqDGTikk1EDoI9\nFm9nl9UuJYrZSBsUpXxuDnHjzGLFqGLj5GKGFhgfaXikvkI6Wy/CZj2S7Fh0\nZMtpKxp5TvMtw1xoF1W1/3u0qvh7s7bkEvDpWBAKJAtRLWtpRnC0BL57aQDZ\niRb5ZDpe5veCCxhMP9SHr+sc017C/AOTTbxaE8A6EejJGBAXqZozVL8V8mM7\n/p8HB9SWcIjiQpxC6LqBff6Js5OWDFGKedYo4CzF0mKCvhPp404iQCUYO0Rm\nn3lG6xH3Oqr3zIgr3W7ciJGB7+Hc5j3TTbcxjywWGVcF2t4FUif9FQykGkAD\nsdi7luUy57vEZygzIxOclWbDJKxSoldXvW24ZnaS3wuW/QJCMehL/WIcKeJl\ni940CC+cUHIOG0b49v9bKyWYHNZINilZtXnStrrzpkRaAhiDgjguI/9XCx8C\nFDkjivpVuXp2EAqAmyJJZblWVWzH7HmnX73/+jOY0/Ie+Ha2PblP/AJVz0LS\neYcCDIS272CucmQhIt3B3ImF+Hy5XznufDhYW8wtQOFYF9DDRl30fP2m9L3N\nThW4hqJgEjoy9qH9z4vmC9clJZWfaBXcTy32BwhbrECGwbMdXRxXe9ec4oEF\nEJwzeNh4KhtVCGtTqLqXnMEPsFQLqYJI5D+qWo9lGCJ3ryDwfocO/thpEpC1\nqFeW\r\n=9j+R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.1","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c15244-1595100183220_1595100231445_0.8423443737502017","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c15244-1595100182405":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c15244-1595100182405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c15244-1595100182405","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"156c8fb6dc7fbb37516015869dd04f0fd5dd87cd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c15244-1595100182405.tgz","fileCount":7,"integrity":"sha512-g+nbEo6U+IWmw3sfB0NPzMNLxfzMZIX2pel034Dz3MODThhoL3YzcFf8ts6CR51tFeRd12uvylzd3ZIRPGGi0Q==","signatures":[{"sig":"MEUCIAYW6G4qUqlXWhDm6+SVsylsY7Lu8mKgBu3x+ws2qC8tAiEAhxuZTsCUHJkWN1ROeIBbVsOFExlybRMZl4NDqQ8oJro=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE0xiCRA9TVsSAnZWagAAOnYP/18LXhM9jDI73ln5x725\ni9nUUzQLGMTOLbySf9DBWLKUFo8kxqb7qLqYQNbBf0EcnV3fTs9MkEOk2s+p\nTxmZXMzLgmiy1qoYwKc/rhUttsBNl3VK6Rl27X32umXUsmhiRNyPeGwv1GDe\nMeVl8P2JRg9OVAxObi6NQ7eeUcWc5wdKtooRbM48umlNdvOr0Tz5h030NnZs\n939SoVb4l2Yz2f1NDkdaTu9Fy3f+1cSQzU0t0n5t6OgBh111rd1pVP2C1rqu\nnPPACEqns0lA+I4JSyFXEal9WjT4I2Ton9c1lMoYyfsQKFpEl6Ro0YfhqclY\nA5rHjKvnqMdnBfEdNFHBl+yfPvUtWG7jBUxsw7T3+a9eGaMHYINFH7N3ydRL\n1y1jO+ByU3Y5qsTabq2gxHglGIqO4Wcx0FvlZEHiK/nYRQv6t7EoLGKgIjLa\noxnlLmOKeVBSvumXL/Nxq/Sg1H9PxHBj2qMWKMKCJcOusX2IQ/GeK4wU5HZy\nbhNkQOkOsZWThwAFhu+QVs27ogRw65AJWUEKkVy8cRwUxYiUBG5emN4l58PR\nQrh/muavzTgt9D7xSUKTBPZ7ln6EGqqc3GdnNSHBRoC6sm19acbvrC9Dkr/F\n962cuIrZVoADWSE2odBsZ5I8tX8IS2s9Xz90ofy4Ennx/ChEWPgWCdVBYgZt\ne506\r\n=lOnI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.4.0","rollup":"^2.22.1","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c15244-1595100182405_1595100258429_0.31332465493696215","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7c78c2e-1595100661712":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7c78c2e-1595100661712","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7c78c2e-1595100661712","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d20c93622d8407477c8baa5ad1b1f7a2a1aa1b3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7c78c2e-1595100661712.tgz","fileCount":7,"integrity":"sha512-awuHj0CQrA3orGvpY9uJpR5dnVxh0hBbkYrXRxyZkfIcdt2/DbWOZASTtGQ6Z/nBz8SkRclIMdfbnmSJUje3FA==","signatures":[{"sig":"MEUCIQDAQz8uyFPEJoV28z7gNW1krV5uMoc/76mV+1wBWmgyQAIgUeD9Mxo5Z+MTrOtCl7Sli/NoGv9bsot9tC2Y6s/BPnI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE04hCRA9TVsSAnZWagAANQMP/A5F8k9hqz1UBwys6ylD\n2F4VlUvV5gcfEbehihqMsdKTQrrAWNvB+X1yZJdxmD4s7PGNqXp0aotGA45D\nAePY990U8JnW3nY/ixeq75E4j1cUgwuIyIhkvNzXGn0P9ql8gIop+JiFZHnf\nw04mS271PwttftT4xP66X3Xzjll356BbHnQ4Ilfd8NpXPliXEQE9P6Yuub3l\n/4DfkL0iPNEY3Ez1knGtgRx2Mmn7MN/K1iyhHV9Ey6dkv84ZEub4Osa5nZcC\n0kZM6X1h7LGal7Yi7YpEk5OX9LZBHgN/h4B1JVeMJRCQEOlGnH0AOKsruTkF\n9kKg3hBzcz+Nk8n8rDzXLZUXA7uO/LHSPNbgd0hZXmRGIVmEYR8J3fPisgtp\nlXqr5qIUcYQPIEThvkwduqKs0ir1ixrrxcbhPTvtCSi4lGNX/KZ9rz8VHtuh\nJDbFfOK5s6ZQPF+RGg28ZZcdui8IypenVCC3bMj6nz4KU0MRoRb8oS8YUS8s\nGhh6hRwRMCMf9KknYHuqiEDhipxkjApkPjBwnnEj8/cM/EJeedPN443kSFs8\nC0enIKITh3ijzLY8LfHN+lrhlepRhcMHgZ1g50hTR8yL6qIKHwI9cQih4SfY\nHDKYwRy8ssxk1ZiNCVccvOP+TAiMOPCD6ycl0Fy14pG//0N/TBQAr0iGEARc\n/xeq\r\n=OhAB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.1","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7c78c2e-1595100661712_1595100704715_0.7357256797446574","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-dfd0e87-1595100822165":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-dfd0e87-1595100822165","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-dfd0e87-1595100822165","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"349da0dda23e73f129bf0d7d7139a4828091d238","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-dfd0e87-1595100822165.tgz","fileCount":7,"integrity":"sha512-7OsyI+TVwFw3TpmGDX87ZSMWJC05jVqWFlsBIlqk6kgPKPEGo8lzTv9AasOAfQ6NV5uSGakheK6dW19u2mHX+A==","signatures":[{"sig":"MEUCIGo7fz69KIPPaDSuBFjPp30jHZwsIs6nIQf8BZtA1XSmAiEAiQpxpgk/Mb6OinnCnLHcsiotxx2jbvnM2CphaGJRlKE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE06/CRA9TVsSAnZWagAA5XsP/RctYWOb5z6MhQmkwHRt\nhJ0ecwpYX92Gs5QSJXKO1QJ0PGrwndrlDCJ3ve5rTPVJFcV2+12/kM1ZCrUO\n8TVXLTADy1TG42PRW3HBS8P55cbWPLFg47Jv6b+/qSY0VNbDIQS0HcCQL39R\nX8m1vzbU9Q3NiqVBR9wWi09w0AHOSsckPdPXF2f83yvx6FEKm3hoEqD+A3ux\nqmw1rOH65CqQx9PfHHERifJBeuqYFUMjNLlM6Jb6NEuWkkrheszbxxwC3f3v\nLXGrho2sVQXjHl3WsBm11fz+fC/Eibk1n5OEfqpDddfBeKyU7leUHjDN+hwq\n1+LS0ukrt6JashcgSXFZGy19ogkPoV8/KDZLO0xYBWRQQ4V3wi3eD2Z4AOUB\nFrPdDerQfOdeTfI4n5CXX5JKoa2XtbNAoBcDbYNB4PClS+t8wKwLyG2DwHhx\nT5lEGp20p2l8LDjV+dSPhNh2HTVPzMbicPhqAi7U1NGvmuXo4Jn3sOta4gQX\n1qp3qsLiN9wr4HeGfcO/NGXlISQ0SWGeDJKNnuHKZ3NpiimHQSAn1ShmWNyj\n54ZQD5LkwdQUa+G6Mu73KE6QIxJjdU2ZHOX5o4Bldoxb/isS2jZXeLX2p0G+\nmtBkq8VlAmmrAFCxJUEOd2BA8vlph3lpAEZIJVdkEw4giimJHeh0h5t0qShI\n50dB\r\n=u0eV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.1","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-dfd0e87-1595100822165_1595100862765_0.7279860832108396","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6658d39-1595395283198":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6658d39-1595395283198","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6658d39-1595395283198","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6467e7dd82d4a01eb3cd1384fcf351da2ea2cd61","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6658d39-1595395283198.tgz","fileCount":7,"integrity":"sha512-KnEqv8B52gilTuaqkkMiAlVAGxSo3/w4QoILHlRuLQ0NuuO5V3brMDmQQDTZ/lz1NGiHsrm4/WeRc63my7bQ9Q==","signatures":[{"sig":"MEQCIEeTqEfmzZVcCZ0gAwPPoEDJBrkUr50+50t1f6Iuf12UAiA+7Rn01xgmvKB41uTZ/hWKm0ndAUNkvuzWGu9NfgTu+g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfF8z+CRA9TVsSAnZWagAAphIP/jpgBexn5VPGG+CnR9rg\nCh6He3n7mW2YY3fjKqMrxANSnZMkY3PTLXIBKlYrK0PSF1yopafX3vOiQHxl\nSkpY9KSuZUW7C1TLH4eCPMXX0cLJ+//MMsRcv62D2bGyg1YqByQRZHPxU1z0\nUCxof1Zgndje4wInuRODnyjKswrtK0HSPLJ8JhhhPRyksRp5eoxUvzdxVN1i\nph5wNw3Vvl64Av4YRVxjjz/JuyXdQ2Xpm31jFA/WIDLIi9S06WWZUevq90yu\nV/+Kqkb+kqxCIcO/z689Mw08QQoqjlCFjPfVLy7S6cLC52Y4EsXN+3cqZrdx\nYW8viVxYQjSsSHSrfuPSSAABfglEHWdwYH2Ft07uA01c/exVNjsAsZSbFy1/\nKQgvlGSc2V4MaymCCdeQhxLM7VpORw4OmpJohDCP0BRQ0/dqBj7z/nqByby4\n9xBAWl9X4uvzrGp6WnFGiRFJ0cJNOYroaAU+vzyDI77lZs2/X0PrePVk31gl\n9D83huRHTgAFD/rpjuCsSc0VPZkIneSlQR5q5dgrp2cHvTmQF1uoLmB4Aw/k\nG45tfBSyXQyEdwqfF9eDbRyydLXi0Chw2W3sLTKP35l/CcmpMTZ1j5O2PD4X\nfUr305CyKpIoQuIIieP+1Ef8z2P41R/RnsDGCJ7ygfADNlpEOdlSbiSb+4HN\nqZZJ\r\n=OZoJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.2","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6658d39-1595395283198_1595395326121_0.09410661323500702","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6658d39-1595395296782":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6658d39-1595395296782","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6658d39-1595395296782","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8eb3bd1376ca9bff819bb7712e8e6bb1183adf38","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6658d39-1595395296782.tgz","fileCount":7,"integrity":"sha512-GF69fGzMx6A8hLgbt5u7YcIz88Wm6mqHJ2+6AOYfho/v/zd8gwdANrOMUz4bqfBTwyl5VRgTCUE+9sID+Br7LA==","signatures":[{"sig":"MEQCIBxMLQNwGmjL0q4BX5OZi0kafil8nT7rXU8HljQTjfqkAiAxeZcNVAZTqB31pfm9kLV9hHSJKfGSK/1J8COrBMnTRw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfF80mCRA9TVsSAnZWagAAo30P+gL06Iq7DEvX3RZMx2po\nod4g19RnpNYilGyJsKRTAgKt9mJJ/jXkwvpfX6AcL80yxy827exNu1lIzxuH\nzNRJayVg806OGys263OFK25o8fZu8xPN4vSEUUvGDnAhWmZKF4tZVSCJ26dn\nhRfh8BKcCDUIYRaw0w06NZkC+pSiB0eHXGUth+aRyyaMtxkQHZrj3sbnqRES\n7GhEeW2Lw9YZI9QceetGZs92k6xCikvHY4qwQE7CJpu9I6d76QkTmZJuW9xB\nTTVNODKnYx86TAh/XOI5coIlFCaIFCSEiAquXybtA0znBT1ZwuPt1IB1xYs2\n713OlIV0++rxEHRRK+skIzrtwQ/MUcHbWZjdYntZ4l5da57ycShqRj5CPn3a\nstFKvrQYTa4S7kbhLhSGMbLlKDeUxeIbWswuxeIa0wpx5LUv9kkFn9mnBwo2\n4XnCLW5Bhd0JP9wjnE5EaODaxqVck+y2bqRqbl6x5ZPJTU+d++iU47+Wj+qw\nOZgxlbi6FujYWeKwxcuGQYjHYa0aSl9uuQfD2K/3odYapMr3j4kE0GkhI0nW\nmu8KStQsUuwPeI8xPrsuRPV1/RRoOyXft0emmVvOL701AWLQbFuKqg9fJ4BC\n4thxcwQSwkdH4Dh2z2EoKOJH3cddkJ6KFtyfJolx+fhTWJTSakG4g7FQz8R1\nXf1V\r\n=CDBT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.2","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.5","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6658d39-1595395296782_1595395365667_0.47670933241136826","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-94717e0-1595522684840":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-94717e0-1595522684840","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-94717e0-1595522684840","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"152370a4d8cf08963c771bf47e7ae9c692acfaf3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-94717e0-1595522684840.tgz","fileCount":7,"integrity":"sha512-sGOSJybFvYPhpXSkIOPSa80jOJmb9Ig0++yk7mH4QqLWDzFKye2YHY6U8xOJVmQ0QIHVWy/LaHrAvKu2D62kaw==","signatures":[{"sig":"MEUCIQDWjgcBqHLargqQksh1pAxxndNv5p9oUHCi05w0CnS07wIgPEh67+2J8VxD6fH+51pL8FkH2++i9kscMQDe9TX1D1s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGb6oCRA9TVsSAnZWagAA2Y8QAIZNA118HdVkv5m+6XbD\n0kGRKaLflwoGGlEonNasd4EOMwbQgqvSieF0o/oHZe8dULofeGLHPB/+AwSa\nLdKGudbff4J6Y2Hi2eEtUPHgi5atBSdyhrunB4+dzv18LvGyXq3apGNj5JlW\nXXMFltKuO9TXD9s1H8VYi0HthMQiBtG6UoVBfkl10dQgKH1m5ec10ukruQFG\nO/uqCLGEiWu5x7NaS1kwybfFMcFH4qyPG59OIyR9ECzPUda3eCeXoF5rec5I\nysTFhG7vjWZseRtzUOjucQxKLLaxgAEKnddaagNUXapWWTRrhd9ZcPygBPI+\nN7xBmOBl+JiBYcg/vhVyaE8sPJJH7H0XtTDz0AUNxW5Jwd0w7R0zOOjvJTVL\ntOGt/RJE226H8vpw95DfCmSNVzZOL1K+An61Q/1gMtCrW/cXRyN8J3ZRApbk\nHW6irr9djenn3bk/I4uQHdy7lXpod/V8Jxa9WXGTbxwhNrLcjlc3kWD/Kuq5\nzu4kK/ARjVyVf5AYJm95K0mxXfjkQ5QUYZNbCmrvl33R3hlQ1AYrtHqbY9k7\nZfcAI2ZCvG57ed6+YUh3VD0+TWwDU9hrKU7WoKSMlIvKeussb9MxIVnR67b4\nT49w3Y/E8Fcr3qrP8IfohUw9KJDfcWr8EGFoWSUuVx/M68xO4PzDB8EN+VJ+\na14L\r\n=NZk9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.2","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-94717e0-1595522684840_1595522728204_0.5784642394480881","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-94717e0-1595522686478":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-94717e0-1595522686478","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-94717e0-1595522686478","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1b0f2d2091dba0745de0f8cb077ca2618c33d511","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-94717e0-1595522686478.tgz","fileCount":7,"integrity":"sha512-Zaceb0gjZKpTePLEB0QZyD0h8rumgbEZlh1GznuLyh92oSrb75ysmukXidnpgPpfOVRSAkQ7s8391mYVNiNH4Q==","signatures":[{"sig":"MEYCIQCcXG3LB7dufFUTE0ukJbbANRTsEyWKfx0gSkWyLzc+YgIhAJPJHGGpyfAVOdBekwbpDPYX5a6o5OKIpUlLyLZlt/hM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGb6uCRA9TVsSAnZWagAAUaAP/Ry8Q/PJvm4RedUAXh0x\nYKlK8g9PIGEW0soHpbK2K8NSuLQ413CYNjbSxl59JuABLmI4S5tmFTXXkQFo\n5CgNvjR4nj7y8lFI+ir30Xf7FfUDTdpzfrgKXzNPvUvMjv1OOZVYbiQ8g20Y\nXEKAIGGxSyEQavgtJleS67tP23kGyPwO6cadgJlVKVA7svauWgzLwYGUKhPH\nhQZg9T0q7jHobjDQAkdRYC22cR/ThYL2vL1caCCUGYIycKqt4yl+TK6fIUPa\n0a469v1sLsm044t72Ne0lRj1e1DMu8m5TiRIpksiWs37k1N0sSmeQKOt1FM7\nl8hp1MUtxb+UhjjBpatmsVItJNgHXHfpO0gw74GWE6xwBtLIYZp2gxbID3/q\nWEFy0v2liqSKuJKk62RNFrpb9E2t2jMDI/AuNEB4u9qtHuaHyt6yO3lBTIQo\nV/tTxNg4zZ/2vjl+U05i9DW9mfOUS0IRe2GFMYlykpaB8LD4+1B1GGGst1+/\nDMlpAE1TPfCTRqPSPt2Vn71n3qKAoF8zXDYPjzvtC/K8lFGlOSCC2sclAwIb\nxGhEw142AKOxHpyoIVSZD+BcOhvbBZuf/94qTOlIoGQFnVL78wFYurPmcWMg\nD1FfH3yqJ7q0XvJdXoqzwX6s2MTgO6nJPuMn95v1Q/dp1Ii5oxGgnMgAZfzt\nRVXF\r\n=hl3b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.2","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-94717e0-1595522686478_1595522734575_0.04621532926889249","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-94717e0-1595522681171":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-94717e0-1595522681171","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-94717e0-1595522681171","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"86c8719331df063060cf37f866d51adb5f27c911","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-94717e0-1595522681171.tgz","fileCount":7,"integrity":"sha512-xoJEWwqM11z+1INYHlF4cCuSawhoaKcP8J67c7SwKSb0HjV2IVcley7CHT9Y3OAPtSHJMH4wCB67qPoIgb6V2w==","signatures":[{"sig":"MEUCIEMrCDu2r948fMvD65uyP0FCf9R1J8Zu1hYGn7wvQesXAiEA2LUNjSFqHVE9l6ZK4Fs8dxvuwFJfRIEIB6aJrOXhIZ4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGb63CRA9TVsSAnZWagAAycYP/RWMfUTiR0P3/rpjEsJZ\nMVAsjkka3nlX8NzolUGnP3nPGXgrdCMAbl6gSFaceNzn+BybJ6LZmcFOJdyr\ngdsrleo0KTgxjGl35da+u6dGbwqKkGpba6xX6oYs4q2IP2bcSNNMan9+5l9A\nRLOu7h4NS+nrv9Lf0bnJN2Eyi6Fl1TEGS6ovF0jgn6udMB3yjLXYXguCl/FF\nMwUj+CQ7bk53cgR0KB28dKZqJl+6l4ThypfoJLCc2r9AVjjTW/shjSSEKta7\nRbo2xe3ro9gw30njv0c5aAci9dcFUu6C0t29jYpoqjfPeNRn9qrVJ1k5VWTy\nbO3MwxVuUvoGB8N5XlKQNiiJwMs/0aDppV5EtKfH73ZGMzmoFe1I/M/nze0D\nx/V0VtGArIpFsyOtmaMrU2KOjHl3uocYy2Uj93LcA3sMPM1i3aZuptO4dl8r\n5eQX01Kg4vsvnXZDRKETl/UkbLXevmJS2ycBEWvvHyAynAhQoUfpigyg1oRV\nrxkwDgGEnulk60qh9okl6N27DZHooB8lEXvqI1J50LvGB7MmL4BZ9Yfuymza\noXXkUc2wD+L0DLiH65ATuXSZOxXVKCa8u82kz0bL7fMj4Mvwc6jI6tBVTA95\n/o+Y8WNfc5Pykj2dtRiDKSW8i5RUavZ7WOrgMkVdDbc+4+JPy5aRmAz1Is+I\nwkxd\r\n=lGvA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.22.2","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-94717e0-1595522681171_1595522742596_0.17270066958412378","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7c6c410-1595530728682":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7c6c410-1595530728682","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7c6c410-1595530728682","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4cdf279c4eaba7fefa6e864a7072cc37fdb97a95","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7c6c410-1595530728682.tgz","fileCount":7,"integrity":"sha512-SA3a0HwL1TcJSgbZlxUEWf++0xUX56EBg9RjI/XSg8WpcV2Yr7vO3qDJsGAwBKMYEaDDyq5VuoXFDIKtqdF/tQ==","signatures":[{"sig":"MEUCIC+4OxQiI9WeUjI38HmNkrmQ384pryDzSALBQkWvWuYPAiEAiKCQtjxSe3p4fSLc70629d9BcBp6ca22ZCxJspXVdYw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGd4WCRA9TVsSAnZWagAAM9AP/AlYVuGDuYTiK+6Ks01v\nezxTPL8kl377Rzd2bHsSPBqg6Pr8qzRgcXM1Yrb+BP9C3pKmnFHDYgLh2rD7\ngNxNEPcQkzLCCQholXSxDkukGigdtm0W2dUQ/lf7hqCssrnpOrPzHFOVyyYe\nNwOWOnv31/egWIWhNDjXqrLK6xF+cyuVWLZ5gHVxtV0VEi5/Lp0WIUGd4Urq\nMzVWoLLOIp+0KIGtv1SWlnfS7Vl3W9BZHaatIgmgbVeHxxdRB3svv4I11940\nm9v3ilf+rfrIFYleyXbnuq8EulzHuEqKuXTDi3F22sKXsHY3yr+LmrcXSFNN\nfwrM/gmmlRe9wfIZQQ/1s/opZKigKmYvWQI8ttclLLvtERVt0zBQwN1K2jQL\nuP39+d4DLWY3iLgtSDXGHLAjGmIVJClrm1dJ5gR0t/6V69YRy26ISuIvGmHH\nJXdkKGIiCzfNGnlqXuCLCV0+58QHHzNBdl2u2hvGIm/5lDkfLJTCni5MrUlB\neEZMQsCj6xLdUpdXSERo9SbQjlO5UJMw3f+2hVrz0CNpv/PjnjA3UfWCF5OI\n7u7uijx1jl+1G8QxY0DFtAA7umbfYezon1Mcd/gdMtrR2JJxZsZY/Z7ZWqpR\nYvxPjvsw//a5dx1awM9JC2jVt3B0t2NU3U0spGiW+/wOb2UzZELfikZ5HnYn\nhYYt\r\n=QZxa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7c6c410-1595530728682_1595530774164_0.6772070629609235","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0db5dac-1595530793940":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0db5dac-1595530793940","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0db5dac-1595530793940","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"703721e454f57d4991b77ed2a3c96449b82e25d0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0db5dac-1595530793940.tgz","fileCount":7,"integrity":"sha512-LLcJRW7GQKLhWoH3Rh5S3Ot2TV6I9F4M2cooeiBMcOGYgH2dUZQHwtZeoJ7QFxt/AjoSsEG9in4t4Kdy+DEFNw==","signatures":[{"sig":"MEUCIQDtWiij+6H1T6Qs6Q9H5WyYP93zpNnvseDewI/morqnaQIgKRfdagkqDm3vh1hX2kvjm60CBPNnwb/Ttk713K6k1D0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGd5pCRA9TVsSAnZWagAAXqsQAKF5aXjbbEiInOj/CbsI\nVNvorR0yBZKEMT1auP3DbqPwpepWkoqb5SLeO13Vz1iTH66nJbhZw56svatc\n7NWvbwZufyUhXM66GSaqufvPn3jg/UdBUvdWdy9Ux8yxWwkNcQIicC1rV3To\nqXeHTnSPzNykK5kJbRGdtHdotl66R2mLY51X+UBGwlENOSCpuKqe1pcjXLmE\nvHVPBJh3tTsAOz9BeDdTIn0YyG9CiSBx4nx2hsEoQo3tTTm7FRneZoH0ZS+5\n9p8WAiL0/KezSWLBTMQHja8Lz6dfAOUy1erv9ypxKXq+yJWElY2Q5GV5b+ZN\nAAmAlSZNpma7VvF2HCi+mLwR86aGn5xhYNgzd2hEOs98Y3ZgYHIc7RXv2+P3\n7J4iqVFL92tN+wjm0L3KUUHJCPgWgFounjZ1N16e16i7ZSMa3OOie9UT0WKZ\nh4ovXyaWosoYz/SyoJ++3vT8Ee0/ZxE0NMORuREh8smAgoT3vCNQX11Lq7gy\nfqr3I9IIhoUuQpHXqr0O7NjU+PtY3rKIdi4bZbZpjnUkaG7L5qOWW3w/NHwI\n3bOcYRtEKl7lWeusA1/2BXuTCn9Lg/T2Pio4tBTvL8OmLIDSMobp342rJ0vR\nSboV7VEtJOj52K5xZlrVTqo78iK4AUnLZMDWQ1bClGKHCVVI12+lUnofaQkr\nV68A\r\n=/jVs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0db5dac-1595530793940_1595530856404_0.30034166171498144","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7243d09-1595548894831":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7243d09-1595548894831","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7243d09-1595548894831","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f131524e0aeafcfe4215b7e2bcabf7b0019b825a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7243d09-1595548894831.tgz","fileCount":7,"integrity":"sha512-Ier1HLgfTde58MXHb7nOQvrw9s3TVGlLlOA4QSH+Pe6q1Eg5xhf6yxV0OrjjlgmQJJ99Ropj3DkdWB3rCPJV0Q==","signatures":[{"sig":"MEUCICTtMeONk6GffEUYJLLR0A0o3WTTPesO82fUSY7yet6qAiEAzZxxN2z9FHkY7dCwMfrL+VCPfmSvoLYIxYkKia8lW3Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGiULCRA9TVsSAnZWagAAkYgP/1UKvnLibKRJNrhu+ax8\nEq3/8MO+0z61R+SDw8NbejA3zqmum9+BL6DtDhfpXcuQX1hc1Qg8skhNvPyd\nE42Aqh4106HNoP5o6O9O/Y6xQZ2Frfs5tsQ/LdvW1q2XVL+6spwLkMDZ+ThE\nb6dXgflOpE197dXYM4nKV7MyL09CeaQiq42h5FnACcOGkiix9JLjcNj81CBX\ncahI6NF/jYpmhHkC19SKKsAn+HKLm0EIU1kyL8fbii9PRyWecroz8JjX3jIb\nORIlL31PnqOuXtz9US7l54ZKClAHo9q5ofMgp1iV6sBuG5K7dN1p5U943729\nxK3Ry/GlB0GcEG6hrHPfjq9+ngwTv3XMxgjqQYHhz8xx/6pwiXYhnoR8rdWI\nI6BxpeUB2uJ+FoISEx97R38fQnTPh8sTYkBZ6ehqEWxw1pCFYGE9/AL3BVaq\nFSfkUrcnq/nxmJ6DK2URGaTnVJ296OpYtFMfl0JK/v131FeydJgOTKnMkIfc\nKP/3fkoHn0fEp5fKjBUXGOyfN0kz3uq5x9+wD4X3RX5yTSezk1qT3+R4QXEF\ngivWG8aQ8HQhbL3cjd3zmt5eix4wfnkC1DFP48KQ/ossETotZUw/MeaP+1gl\nAcZi+R8Ggiy1w5MGQHco7ofGej5y+xvs5E4d/Ugxwc0VkMhyqj/jymPjpayC\ngr6/\r\n=fHzm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7243d09-1595548894831_1595548938670_0.15853525582836991","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7243d09-1595548896165":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7243d09-1595548896165","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7243d09-1595548896165","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"19bae5b92d50d96aa5bf6e8b37df7d6bddda551d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7243d09-1595548896165.tgz","fileCount":7,"integrity":"sha512-OU1KQXexdxI6d0z8Bg5/mvTFwkUqHCmV9/geixBkY6B2Xhyb1q2o1tPlQCO6Fty45FsvAduVBU68NUxlvs8Vbg==","signatures":[{"sig":"MEUCIHPms9wotfjlpaBygu7bOoP3oclF0PsKZAsdU0AJWSOIAiEAqj1tXfOuyKm9+wV8dl6zLrlO7E286wVk17Hh2ejX19s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGiUTCRA9TVsSAnZWagAADToP/jVoM1g6JS4SNY7vsxF7\nWQXNWuI6nyPtlAUuDH40idhPg6tEIWuikSxFn1dcOldgwXk1c+4v9IL0l7z6\n/RyzLvOlJDns5OViIDwVdlCzTCM2Dn/NgfyKpoAyt0BTitB4ndSyoVqH3S+N\nsZ8gPo56LqjefZb2GCaPX6gdfmbr9dJOK6FX/EFfVt451s4fnIcrLoeBtamj\nMK62XeaiP/oDKL3P20YOaa2W9m8ClOglcP6Vtxl86dtEP+iAvkfIURjFS8eo\n7EGd4cd1nVSlAAjNN/NZVY89xKFHa6ZruxUi1CFQ+6gp8iyIOoOklOVpjTCl\niWru/iX0p9OFXQfXKGBnVXAeSHoZkC1wKsvfkOSFaPkkz09RawGLmbQxEttr\nmngG+IrN8eUitfwfBMy5r2JYzdnkn4uuT9nvoCaKKUmYpxbMcbLIXgpjeFHP\nrPXKVsMJT2FAi0bhJqcHxnScoZgbK6lGr92H076Twq6vZNpIzNuaYFCYMLgO\nNLI3GZdU5iRVSCq05DHpobBTnCaZ/FmQ/Hn10O8djhYtMx/b4l0NklemAQLP\nffWVjOC9VOcMJYTL9IvEWCfOkwPXrQJow5OgiRx9ep32j0nAkv4jqHZp9pUY\nF1fh2IgBGOkYsHcA013Zoh0XrTIxSY2VmMmHrcdSn0MjYEblzNafSpqrCISc\no/o9\r\n=pU7v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7243d09-1595548896165_1595548947257_0.9139824156427252","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7243d09-1595548899533":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7243d09-1595548899533","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7243d09-1595548899533","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ba7d81e5318a00ddbf699eafea5f7b1f93e8ff6c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7243d09-1595548899533.tgz","fileCount":7,"integrity":"sha512-d1UPReqXLBnq+EbcYd9crUGKf93fuIKNpvuhnRNwERcsD9EKytlFzQ2Hn+Ie2L31gcxNBuIBHpm75Mefb3gRNw==","signatures":[{"sig":"MEQCIC9zu0awVjHoIx9PhmDM95lu5NeUIOR+wP9Zih2OiY+/AiBF1m8v/mbthQ32CjztYqmJ8jVweiVFQWKZq6dfGy93Cg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGiUbCRA9TVsSAnZWagAAALkP/0tBQ7skeax+/V/v508m\nb6rb7AHA+e5ukB2aeJF+kVuUN2zZK9+jcNySUc+eZ04eZkuGK+7DkWsV+0cW\n5B9ITlKeHwpM9C+oEeOng/RES+ystwaNCaGUE74W2ae/IcyImNeU87lBuwj0\n9iqrxR0BG9zia8q4AOl9t6KNV5YBDdNBrKRwZdHZAms7lmYHgbiHectj6Eyi\nnud4anrkge4YmvmUdEcrIc3Dt8zPx5V9PDtkXyXky21o6xASeVZhIRbOgAYe\nqT00HjIGOYSbwHAjGZiX4STQa+MsA52+tAo2Oa6pjJ5EsOjQHWPAaEDRxKsx\nrSHSd8aYAhBa3vaAk29MS69AqsUu4tyvFNg3DMR3DIZP5nJYnvVIsCJMafyO\n0l5WbBrQ9eprrgDjRiXa8GQn8KsfuWZIMfVf14dA5UsJkkQt6/5xjt1IQgx4\nLfxQi3lyrkmOHHHkb8V/7zx4azicV9ppiMukAbshaI4hbpW9oSuPQQnS/b1+\nrvjOvOSGIpeSH7Eu6UpQbO5suEQDZpB1onFwDcHXaIzHT93UdPjVtlrhvnDQ\nh49IYEFikOwnPmdTF82J33nJynkWk37t25fES091akMWq25Yjrk3VIXYCbwM\nT7KqHKBPmFCtaOYPqx2lbRxSGiABKK2agDIBmLWBEGLTOFMx+SBl8/fEGIsQ\nXE0t\r\n=SraB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.3","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7243d09-1595548899533_1595548954590_0.04023109621815779","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-41a87b2-1595927098919":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-41a87b2-1595927098919","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-41a87b2-1595927098919","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"14fdf030855e1c33208126d0fc2cdd667df18638","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-41a87b2-1595927098919.tgz","fileCount":7,"integrity":"sha512-g4AGH2tH1VtvoXEF1h9mrSNzuZN1efl32nw7iDRrvOXMTDitaPDW5/U+zG5F3qmwpxpOvHSrRdxJ/a3Ardk8qw==","signatures":[{"sig":"MEQCIH7s2iGzon3Gi4Isjazb1jj3M/3JJHeJVsZ5Jr9VdzawAiAxNx+nqHWqdgRYJ8lF25Pyh2gDPtEAKcVXpWBcrAQ6Hg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfH+ppCRA9TVsSAnZWagAAmgQP/021ryRYceHH3YdKbsJG\njRaof0YSeSmSQ/M40KJxniRsSOJWR0G9IUerYb8G7v9JSpHzCSSKYrQE5fMm\nTOCkux6hGsOUHHUw051yyLmMefahGv+qfF1rlxxK4dZfcgnAeiroAbvCIE5G\n+h99oPa9pmbaFpuJ9wthW/wVxd6xFV2mfI9MZ6t2DmYPjNbDmvA+wrnBS3lq\nC1MkaHZWbihSKZDKp70VBZqzvHXFEbrWwjo3ApVFKENjA72FjZJUsnMOzdyQ\nUmJF0eIbhMQ5cWogno7mTkp/ORvhLk2+KQCXCSMfuTzxex3pE973kLo1viqh\nruEgDR7QHdDJVa5xKgVsWBaBDP33JTLExuBo4/W2d27LIwaEC3O2VNe6GzAg\njIlZmNb9/ui3KmP2BIjGnp71GRAa/mGDZLJHuA5KJhLWN3PmsXRDNqntb4Tj\npxAsYkbn7Kudza/i4I6F+1jkQacd014pXsscvGgcet+6s9M5qplIhdFlyZF4\nto3I45a5SD226uqAPIAGOMdtKvM7ROt/ENyNFXE5Yu1GfZyku5YVidTvwSUS\nfuW+NY0tNV0zIznjICPiyMpG/EjBu1h+vuUwEGfdjdipJhkLvwtKBTMJOhq9\n4jyEYfjwpdlMVUkUAYIdBb9mY5emL/WNlT+kwT/9ynlp2Hfx013X9k/dHUPR\n5RX3\r\n=HreQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-41a87b2-1595927098919_1595927145133_0.004982784538351215","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-41a87b2-1595927100551":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-41a87b2-1595927100551","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-41a87b2-1595927100551","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9b526b5fc516f6305fb8d89a2cf8cb670405d617","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-41a87b2-1595927100551.tgz","fileCount":7,"integrity":"sha512-xq4f8NbeN9sePTzrc3xXkpNoSLi0lVqWghrrcW1ou+jOzjfsMcelJnr1DXP/i8mAAXhVGkTBCL8QML4WezOGpA==","signatures":[{"sig":"MEQCIHTL7pNWCmlL/Y2Buf4h+kSaxDQc67l0tD6ah41kWDE+AiB0kpDTN6T3QjAd83bhoXGCTPuFS3vvQiF+3A8IWri7pA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfH+qHCRA9TVsSAnZWagAAZqEQAJ1/L2m8LcM6WbjD8pBd\nSScI1rgURsZ8WlBGa3jimKt9vt4qeywqLnfdBXDZHB/RG4dXQ+m9wcZa1S6i\nTis1E3wQ/fy86xIpZU7e+vgH3KQPzeFcVwCtYiK7D3Nh/TywGxj6tUefG6Qq\nCbU4v5SZjBUkbn9QMADPetUF8p2zQ85N7rciD/pzd/e9D3N6KuKcTARCSy1L\nvhYT3EsZh59v9ZEUng2Zo7fc4TV83bvGXHf4pheSHDiJwn7ngwtFa1ETBOaN\napgMTSrtk4LEisSXxRdRUe5OiFcoPkInIQMdpw0703if0XYg90WsxVYDbUCL\n2r8J+KPI6yldrNElZplF7h3y15L3+26DM44HP1vk0qxM64omcmB2o5FXdRfq\nIDMAF+G7l2kk9TooWKDk/+NmfYu0JSHnr+HogqlDaYK/KJB0ZOhV68lmXv/e\nfZnNKYErqb3VOmh5xl+G5px5lgnO779TnsMfamVEUBCq1QMpFjI3qyBXemVZ\njRpAUyyQHVmzjHDgSkUckhhYoM4csvGncRVmccTnj0o18xx7SuSc0v6UfZyL\nzgvIp46EI2f2Yu+bA9dWd2Y6Nes2+U/qRCQtbi6ZDAbI6WYNKhdeWa3L8VXY\n107iyca/w5Ce86UyyxH+AoB44o93M4nCO40l/7j8pjiYJz+W1aGLVX/PLUco\na2tI\r\n=g5H/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-41a87b2-1595927100551_1595927175378_0.20970821316453225","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f2bdef4-1596105909955":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f2bdef4-1596105909955","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f2bdef4-1596105909955","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"239832497e6ffefecd137476cfb345c66b912969","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f2bdef4-1596105909955.tgz","fileCount":7,"integrity":"sha512-2mYU6uYefVrto+2fF1tXYuhkmPrp5Lq30olSMAcOyshjA//r2VOJvdxtIbhD8QhFlL67vrJp39pINwy/xCmZLg==","signatures":[{"sig":"MEUCIF1G11avBguH3dYOXAylWeiEk/AnBLXr3UJ7PChL7E/AAiEAnlA3PlIDCsvy2v6JeAt7fY4VX2spz/vfrqTkz2WJgCc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIqTrCRA9TVsSAnZWagAAgZUQAJsIVScKCSuGKYfRdsAl\nwfJfZ7Js+UnlNMSfoG29Wo98MgasKWgqyK5A3Cdk0LkbI1ODxGSacT12EmcK\nupRNodfq+NtgZsKd65bMpKdOn7JMr+2FcqGyweLDZ8qPJCJp7x8faHMmQBjr\nCpoD6+YKBK4ZLkMdsaeraR4/VO50YLWTAnatqcExAPwWobSL8INcZvuLe3Ua\nRqPrLxyzWR2FEegB97TcOonwuXQ9aAWzh1eaANHWDy0h5iXEnrvA6QLMPGwf\nN1B3kwIfqJqc9HmgL3U76Gz4NCw5BkQGeC3XcpQ5wfJ07CoRoTUGIBVRA6wW\nR5XWSCN/UdZ+Sb/ckFY2s/E6DSeu9aWblBvc5r4a5ig/WMef2MB/1E/DNypJ\nruqFH5sMrOVet8xxcgYgMk6jKq4tgZKsFifqEDk3IDrF8TZ7tvyjFoRRR8pY\naEJZyNBthyKVcjB3O3gkj9478T7X7XA4cmdgJFbcTFpL7o9p6A9abJwxpRYs\nCoaR61DK1q2Wo3VpO9cOBmsFGpLcv/UZ8vA1pGetBZbLgV7cW1nMTMQl9gK5\nzQFYlyqJdyc+Dt1rhOPQFiNLghq9De0lxVT/cTFxBmzkISEWuIPJaOmbqwtB\nsCAfkFDxEBsuixqESa6h9iKFtUtggRYCD9TV9lH1AmUndBNV477eZOgwBLsV\nrCse\r\n=hKwo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f2bdef4-1596105909955_1596105962506_0.11048515849418727","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f2bdef4-1596105915606":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f2bdef4-1596105915606","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f2bdef4-1596105915606","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1af35da2ac0b0f7094d2daea72b5d629714863a1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f2bdef4-1596105915606.tgz","fileCount":7,"integrity":"sha512-KSRFrUFKoIjyZB4rgiHLGC18QFJQxxih5szELJdpgOKlYShCZvaaeTdgVErTEdgrhaDtI6BEV8N++x94aMsvWg==","signatures":[{"sig":"MEUCIQDYe50BAJaC/Gy44adDkujEqR2KmI/7mMM5iQjJcO3fBgIgRXJlqxhfnbS056esfkK6Q1kRzNg/1JPTsnjowwLlWrk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIqT4CRA9TVsSAnZWagAAEpMP/A+tpsVxlXwQUs+5Bmji\n2WoJJZud6NphGMNlRa5d2sahKtNsG1WmStgSNywK+PgDkhqh5b4sqZwcdJeh\nAR4R2y9dVtzSaHfChnFNQl87nl9XwZcIBTC2ulG6GYuinn0HnlHrZGXAh2G9\ntZTvDE4eb+SLH+glEQaRG3HKA1+AtYW5dS/smhsRi38sgCuoS81uQRHlWL3L\npI/jU/HJb7vpWUWGKdyFmNuPcUNoJntmBJv6uNSaB+TTSZsV4Q/KhHpDhSy7\nBx8acpg1qnoq6Bx3xkyU9xmV4dFCbG+aUU0c9wmhAcc/VNEh8a5d2wVNf7Nd\nyaMV5C4wBS5Oh8+1oXxgnp++Rx75jd/oU+YXYjwiSEcSypPy4KTMt1Bi7dg8\nul0Ilcfm5wKvRNWBwN8P3hpS1xk9GPVnPZH6XIw8f7vFCN2imJokXF93pRuZ\n9wsPPcIo9jCfvU/LKHUUTeAKNYhVqtVMD1wqbrQHd/87fOC8JSzcH/sFcei9\nkW//J9R90gCy5tAIjF97dJUO0cLrwVlp7fNh1unMYY2Og44ceXD1YtlVZbID\ncCp0JMmIPVqDeGg2nV/Na13RiQdOWtJAhb6xLzLNlOvpYQS282erZnGj3lB/\nwRpagXU1LyUDNKoMKwr34s8EGTVn5IlEQSkaRsJtv/iR3o9/BUuQE+2IDzMN\n0u1c\r\n=61sM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.0","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f2bdef4-1596105915606_1596105976497_0.4000446677182634","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-2cc7f9f-1596109319511":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-2cc7f9f-1596109319511","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-2cc7f9f-1596109319511","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6bc738d5ed70fe6010a8ec0d2e6e64a1077e1bf7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-2cc7f9f-1596109319511.tgz","fileCount":7,"integrity":"sha512-9BVU66i0ZfEAttc2apgtFYvAaU7o0NNANGZ5skEOluecXTn7Quf4JKIB4yOM6GUmfIWLHzfEJeKC4seVinYJhQ==","signatures":[{"sig":"MEUCIH4Og9hbju9P2N6ueGdnUznYG/2Pvh8NDw1pa6NEKmUvAiEA3BHOxOYb6imvNkcZcv1dLo9Mf2lcxFRmU+dJNcTkiZk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIrJHCRA9TVsSAnZWagAAR+YP/A/hdZ9ZXT41BEovMng1\nm62ruCNhEAuZkdM7afaL7taAU8Wm+ZfeWJB26fzc+4/UNA8rXLMhVM2kh+Vk\nthh/ufhRYbKEiqFF584aODin3IQRC92tEQWwEXsSTd7PvssRwlF3K6WcjiaF\nM4rHgX9rv0pMHguQ4MWuNeuxCc83BuEpAr2nbh3pGgOEJoVCr5CyiTtkUKeH\n6zMm2eH5hip/wjFZ7XpwV/KpvlCFCoHwv/IS1NejuJRznaSDm+2LiU9LUz9a\nPDMdmtryxATP2FMM5Lz/vLnpAXFL5OnFQWnr+vfiQP4XWf/qroR8tBgtiwDn\nS/MOjL+/cDk5nQmTsyE9y34Yv7dH8vCjNwydpW9TRyMR064lH++sXnEu1X/I\n8hjEMP5sp3/ic3Y+6IvU2v8eU0AczCYom84cvHsoFTJJjlZp1WVf33sojAK+\nHQnM4wB4KkmoeaB+K/Fvsb8THBU4b/gPQKWXzLg9rCUkgkxINlZ9Vh7BQLP0\nKeWF5k3jZf6sMw+8UodK5XK6slZnIGh1nZ/sV3exgEdEqxyNbiaxnXvE/uhK\n13pTGLdPo71xgRewZu46nqq5eb5lSjXm7eWcVdfBvNDk+itSs5+EtUImky21\nUvfRm51l59PRSk04IDcQLyFSlTq9k4fhcqR2zEUYwPUevngyyPDoNKBK4e6K\nIaFz\r\n=KBug\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-2cc7f9f-1596109319511_1596109382817_0.9144562202757329","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-8bac19e-1596109317428":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-8bac19e-1596109317428","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-8bac19e-1596109317428","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b5873b8870423ef3463c6a0a07ec541de96a4eb1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-8bac19e-1596109317428.tgz","fileCount":7,"integrity":"sha512-g1gLY7JS73ErrDe/+84Prrcej1eF+1KK11uXIwCYR3MQkI0WwOQJrHyUrly1SKOxuePynxMiE7xUB9O6N9r+/w==","signatures":[{"sig":"MEUCIQCj4skzpPM1i027/7BIQO16j4osUfEUYEHjEEEFHzTyTAIgWpB5E1Ar7Z+2F/SnKh+ku+sUbLMQjtwHCSfbEmG0XhA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIrJYCRA9TVsSAnZWagAA6xwP/iFeu15Cg61GBL9RLTpP\naUb7HGmrxsWhyloLeET3owSY5KfoeeuGk3ZZIrXN6BdVxGtcgumb1Zc7xt5l\n+/shSAnYdiB77QvzSXvn9xjLYF8+viVc8G8GulXp+q71s2KfiC95Z/0snCTh\nHIWoLDQc1Llmutm8NcvufuKOweZIUx6YpXVdN/IiZRvAp8RHx3AHFwsajCW/\nTL/DVct12Zy1j/dR2jl6QU1DwilzQj59Eov0TKZfNMwt8S2mT33/PCGrzgMw\nipfPpOOa2axL3buM/58+R9RVaYolpZUSWt1utDTX6pPKkhQVHY0I2wgniNKq\nCSfrThm4kiqT+8pWg9yCYrW2xQNOQYcQ0yp5Cc6kDN7fMRT/0tzaFFXFSeEC\nm5vlC1I3OrGTdRZI9oj34JmZXvW0iMsRZhXoAr7e4/gp2g5ob/OktS4fYPuS\n0KVNhGJv8Vgg8PmKJmDRWfW+jiuTwC6K1FiOKxquKJ2m0ZZ8RG+2m95QznGj\nNdNFJgpfBmQn6PEfUBsL1yLs4+vPJ1ZKLHBBP8YFVTXfWqmkPyTv+haaiDN8\n6oL4OMbCMid0duFkhqCKvb0WgmCoNBQOEMTcpv0VUtgN8v9dT+2Q2X2HZIEl\nMECRcaVkEgFxdMIdXrfndz2qwZkMagFJs9RsipE0yCktjjoVvKQ+Tn9zU/tq\nrRDe\r\n=YouA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.7","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-8bac19e-1596109317428_1596109399855_0.3087601972164631","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3bbd938-1596173579623":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3bbd938-1596173579623","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3bbd938-1596173579623","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9e3cf5b86e6eb89631bc5f54376cbaafbf2da55c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3bbd938-1596173579623.tgz","fileCount":7,"integrity":"sha512-QZfJSKBuZPyq2ZkqR+kAShR4qPDJINX/p/4tcX8YdJRGdEGq4nNoNpBnZuYOnKEdobC4HA52iZi9cfw8GvjKhg==","signatures":[{"sig":"MEUCIQC/TRYUI8GQxhC6yBACE1RKzINI5se+vOOCJlvdfni4+gIgVR2D5wzZ7H26zDyy8xqCYJjCfwq1gz1kYV8yz9+ADQQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI606CRA9TVsSAnZWagAA1UQQAJS2W+Wiwh0i1gkhM8Mh\ncekEuXWSu1mhbScFE3oIfmVkCC+8P3iiMc7i8lgkacOkmjM/OPD8RZGBPlfL\nMyTS7I67YpwFn2W7wC0nudeeW5DxQGtKDy20A/KEmU03fvTM8GY2Vg+N6/1s\n5hbNnmptew3eO8legdM6fFFUof6Lt44l5riTYATEWa4Xk8moOYL91Y1zJ8IX\n3rf5KEGENsD3t3Zq2gWAZlGos/xCMWmZ/SkQzcu1FElo3p7bRLJLkAl47xRZ\nuRKMEJiLXGNEs0CBCWIWP0bJzsGd+2ZlNgImAKXfTyDBI99lr8djskgkPmz/\nBjlQUNLEEIZIhcj3cVUI67ayT8a6dSrQSjpUzvtmLoet1dqJXR8yDgsE8oGZ\nJPHe26EEUk1OsL+A1pk9Kj5dM5UmFRNK0qVf8YbMYXbYVxIebH0S9rV3Ozai\n9ukxadfeonwdjT03Y7FZgU8JX8Xxk+HZ59Um6zVHijElcHGoJcLtTLdQUrOz\nkSBcPWsVqOz8fApbsGypM9aqd/KyfVpOzsLoNH2VrlOh+8HwL/qMlpKKLd89\nzHYBDF/nvfwyDm5AuxuAaUiHxlOBq9y030StZU34jL/9ORkFX6VSHmmLm1Iw\nBMucXaTrznagCtGRSro8MHlyMA2mLLxrPM0qgtq7iMxeIGsxJhsu60WvF+D2\ncek5\r\n=Nusl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3bbd938-1596173579623_1596173626272_0.38452382176843125","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3bbd938-1596173576246":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3bbd938-1596173576246","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3bbd938-1596173576246","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"44daed4db7c851a76d76577d3b2b6137d7470733","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3bbd938-1596173576246.tgz","fileCount":7,"integrity":"sha512-czr1QArjCW7kHdrTirIBbjSEwWg7zIXe20WqlTR5w2cr1tbCCPyM/SfxTygmvq+gqj4Ck8cCwFhIbqIaJMeOhQ==","signatures":[{"sig":"MEUCIEIKohRL8JIDnZgMyBx2tOJ9o4/D8jBrVr9/8l46egsrAiEA2BP1XhXO9y8HbU4xcU7n7Xfb5kjg0xEVEYymXbuK6ds=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI60+CRA9TVsSAnZWagAAUbcQAJyGKc3yajWfGDuxEmX+\njEfkm/vwoT3X9roxwZL1irR57x47bCs4+4lrWSHKkMcbUGv6EGiJFfv5iIhO\nBepDPFOGQoLxcMywbD6JUjKAwDjUnbhjjakqSqGJ+Xn0bGuO5rLxidplBXgH\nknCRBlAv6uaHDpGbQOyK48txl+xCFmp1jQdaWqg8FPml8arbG/dbu6S2kLkC\nipsFKUBTwd6SMPj6gg4ovKGdpK1vwisnl6BRmTSDlKnv2AdS52M3DUga+9cW\n1kWxg3kR8cdyUxv7n5GoewpH+3bqeFc98CBmwRiX8tci8pVCFX42nnXIY2mJ\npoF+JXJpuF3cAGXaMFN5vnDCA/gJmZ7pFz2kfG9hWE/LmxhnzgtwuceM8Tux\n2/TsLagfekC/DSed/k3xf0iTJ7sCXlhFzOvNLMVJ8Socl6bYeYVqswZ0YQ7K\nbyIhRtZJDs8nK2aQefakfrCqMoYwMPSxn30lK1tXwH5ciwO4Jn8xFxm5hlAD\nUSIqNLu5gwUWla5y5E0rkHAtJm/5DNHWKggAP0Ry4LaZH0I/9AR55BQSZCAb\n2Ilg0NBEq5p+wnLBf8JNyXqL0P8Is6TcrDQEo16bz+/hBvhMYs+R70TQviI+\nrH0yH8sRt6BiAgzH9n7UE/CZPxLrjhD4YKN9CpfRMygO7sdC3xlNe/hxJzMn\ngbd0\r\n=xQGM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3bbd938-1596173576246_1596173630154_0.2651103000741939","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c638ae-1596193307470":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c638ae-1596193307470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c638ae-1596193307470","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7b15a549ad22c70898051faa8a4a62a981788d15","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c638ae-1596193307470.tgz","fileCount":7,"integrity":"sha512-m/oROZ0Z1efBGH2TzbHtWnOdlZnPMKi8oFve8v+oM2kjHhfe0o/HjABTBavsP0Q+L0HozD8hnJSSdrrx74stqw==","signatures":[{"sig":"MEUCIHDHUfHndP5iHG+rgKdyzdI+tiwrshikHbYMyH53ingSAiEAqU1OOOh57yka9x+Q2uBnyOqYduXOs/xNCXzkbnsH6Xw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI/pTCRA9TVsSAnZWagAA12IQAI/gbPVNQoDTCVGvYut4\ndcCWFaLYVSVUIJESKWlAME2b0zxQAFBrU/hUSOo/eQGyPVtSui3G3GnyorKY\nRWA/JTdB8wwvel0nDWzdGu3JFO0JtYDntIgTaKsoHgDRJ17DYA/rpwn1G6jW\nDg76g1vtGsasmyVfHoRQUsx2VG+0B8+d9NVl1vgTtnOv/sYj3nVWC87GJiGc\n48s2u499oIbl6Q/J4WznPDwuHo67zKbxyRFB2UUg7+sh+HBBArJn5uWXRuwX\nEIQdQwiR9ZbBIl/rTQNRNYqnxvRhVpBNdEPDlC3iLCTjNO7LEJ0YFxfDsUFP\nXVS2Ih5umhQeEz/zL/sQbC3vmnfYwHb1oisurD3eF0TO3G9g0Wf7avk/Sh8E\n8lf4HIRJjeiLVtu+sLwREJsdAFTpQUm0nbLUQ12RMi4ii9/Nnvv7ClBNu+jM\n/ESd0nSEhREG6CtiPULmiM6MNW5atSvF9qfM3IopSmL7mNftzSiBoKqn7EXY\nCt4DBIWTT+/IsDmYVrKljYPQQXzTpqJHk+4SOeTATdpUQIwuMNfJ8gp+Q3DH\nZh3nBP8iZzab+XZv5VI1NwYWWCwrA/jzOVFwsiKy5+MctNM951yHhdaJoRT8\n3glXGTkApTeCO5lMzqW+vF7U556q0tGy7zNzXOMIySZekTP2d8vNWpg/ty+5\ny3rQ\r\n=0rui\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c638ae-1596193307470_1596193363126_0.9492087965029727","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c638ae-1596193307326":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c638ae-1596193307326","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c638ae-1596193307326","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e99fb93be7bbfe24b7367f1a92a8c3f8d5141690","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c638ae-1596193307326.tgz","fileCount":7,"integrity":"sha512-ujdK3eZga6l2VV0kKEqH/0b6xYkvthZMAvapVgdyonOEPT67EP6ygR/Xi1GttWpSFtbCQamISaKs5FgV6Ndjqw==","signatures":[{"sig":"MEUCIQCyzo2wDSfvyK4ILdawW9m3QlToiqB6/46hDkXVW+V+0AIgEAHk6A/W6QhBOP+F94Nknx+pnkmjbJrg+4AbPcjqH8w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI/piCRA9TVsSAnZWagAA3KoP/28D6FAT86fNirQdc9kF\nhqocIKJv4/0X0wCuqOB1/g/3KZmQYcweu1AXNhm+vXGQ9z+i+/SoX2SKNtAj\nWNaW5dtLHkxh3sL9KkCufwnTX3xirP0AC9DW9huPN1URFfOItiG67KR1DROi\nR2zWydMpu3rUjfXlJHzT3pk47DcmzGCSS/KopGzx9gRZ2hIQeYkikfxhde8y\nLzm330Fvk6Mz7aUSN8d/IiPP0DEdhZ4KTG2EgbDkO5ljAF5QpN0lNWaEN30g\n4c2O8oNKW61A7irT5nOAjHFVLuvfJXbt4QUlNRxDcOBr4GsTBAyT1mBIA62k\n2kS7a64/Yf8kKan8fDfQ+HhLjJIJIlfkFXSgqJl/CfvjX6mMR4EyRPXXhCcz\nvFKxJCczkbwjF8zwvvF+lbADpSvrcapTZLKlU6mEATa9G4olFxEADwLbPv2s\nyehYs9Zj+W77ITufZf6Cn6DZFjgPDZVLQG68hvVt96rjCbz4VVr7UmJZYzVe\nj2TVG3e828DhAj94nQLNFhinDgK0c3uTEUJpRHa1k9nDDqdIKfZBRCnP61yw\nqtPulC68j8krLN3jlXDpfgde4ewKdjsYGA0eBzxZwvm3rUtSnqyX662bFAK+\nQKyqN4OX1SFc1VqS2QgON4V8Q2K31Gz6ktvD/0QmfPXVaSK5BsQe77tyTww8\nz4dI\r\n=jXl6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.5.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c638ae-1596193307326_1596193377743_0.5212423547833189","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d816a04-1596238573598":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d816a04-1596238573598","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d816a04-1596238573598","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5aa4941e84ec972766129e5fe769307b67900ce6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d816a04-1596238573598.tgz","fileCount":7,"integrity":"sha512-WbLJokvyQeEH+onQmuC8ApR6qHurQfoU4QqBNC/RAVLDlBPy5FhPQvo9GCQN9U3xdaryhT75tHUZ1CimChV6LQ==","signatures":[{"sig":"MEYCIQCosHjMHMB39LXoRVnQ+9ctG1PqA4768DUW1IY5jZQgsQIhANvxnHoo3TBniu+gTRZNVAmZKh4yQgA6oRXbZ5HjbgxA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJKsVCRA9TVsSAnZWagAAnJ4P/RlWMoDoKbgqEwqqVC1P\nWjqCcP8iiArTGg4txxn3WRHjn7qt0Gc0Ihal/tWHnUJ/Dz62YlSmVTjIj7gu\nPj6Va7pifXr5MSnyZesr7ypxpb3FV4j4Ldsu3XSEmO2cDpsAQReVhYRbziwV\nE56hHOMq6UWg7Lb1LwkF54pGMmTAYtQ+iXmYSirVDBldddxhctvAArsWPATe\nxqQHQy94AhG+Y3mmOLIU0e7qLoyXebeSaqL5K5qVc1MI1dbjzSu8HVsR7DL5\nVkFfaFAEqR7g/23g3TR1/eOJ40w18qzPO46aby3iRm7w1cei65xlZXm8QHCd\nbyypbpwZOppaiW5CC8Ghsldd3FjUUA3QrOPU/sqvXwP86ugQhFOcH90vE6o0\nGUmK2mGSv8kkV9CUxU1rBQVRUFsxSthAZWBim9I6exnsemw3anzbkqIOYXIv\nPC114NPxpXMJcqShjAbo9Ft4Eg/fRdYfLlCn2GSVa7IWh5CNiKRcp5Iwi+ak\nZym1v2Yj9ovMPS3HXT0X202a3lE0jTcrf9p+ylVDTyII9T6GuZCmYKvTGjdo\nPAL0YWYBRSHsI7s1a8JQOKHc9HTWoA0loV+m971wuFNQ+kVaSiIGJ5hIzq5B\nhvHoKEVl3qcKttGFlVnhFgMyGZL1YOc7rB8bu/Xw0sQui/RHv1z60BUwW0IE\n+ZyP\r\n=20cE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d816a04-1596238573598_1596238612739_0.659708937692528","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d816a04-1596238574602":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d816a04-1596238574602","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d816a04-1596238574602","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fb07b9e0627134b01d940df671ef4f71cb2d7f58","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d816a04-1596238574602.tgz","fileCount":7,"integrity":"sha512-mzptQt1xNRtly7clMShNCpDa4ogf1TDVDyYZx5PBltjVCXerYdgpsNfxwSW15NKFjf8TPddoyk6J+5okKV/0lA==","signatures":[{"sig":"MEUCIE9d/TsHCk/oG/79qHcnbt7OiU2Tc3GkLHbkZ6DnUAzzAiEA2TkVbdHj1cnRiRt2CUhzj3UAMulPk3Fcj7tfGxj7Kbo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJKspCRA9TVsSAnZWagAABw8QAJaOI+ZZQPgEG5LPLsoB\nrMdW1U299StW7V38dsDTNpt0IGEg6rkt7oCK0buyb3a7+nIVe1BMpQC0VTwf\nHsa+himWDYyqs6BEaIF6sLRoTHRCfh2DhFeWGjLvXTxhlR7PDPS3h+c3WPxX\n5TsfwlhJV+ibcg4j5wzKZhFDysS7Ivl9dWPUKWyBnvv95KfiWiEP2XpMHdoq\n2YkpSu3HYK4+n97pwnbWIdp7BueJmdTlN5Oaoxbl2ZwcjtGuJjXF/JxzzudY\nA78wVj/1VWEJmkgQJFll1raxxMJL1zfuPIhdyf96JBsWHCPrtiueX/fOOGer\ny4Qhbe+DbGEGC32zm86GzbYMUl20Fgs2DJJeGA2f30cTEFVVykCA+tIW++x2\n6EU+QrGPPdkvh3uiz+eOCikP10/7O5r27Yi794nK2QVlJxeuynwcSbk2fXc1\nQ+fPGxncedS9WZcSFU9Kfv4zxB1fXx2QpR2Z2vwpeeLW1AW1nhb20NTwPa2Z\ntxKKIpG9dOb1g867GI4p2vnyKMAFVFbtjThEBIC63WHPtKU84yWDFpXE3qGJ\nwsZlJzgepA7HaLPnPwi2TaO1BPHIDQPl8n6noO2E8PfIUy6Y2rABJyJP5v2V\nW7Ww6LkeluGzK8+IrtzvNdj5L8qUO3Kl2LTh6yfhqosuj/84eUOfvcVjl+Bw\nmnek\r\n=ulRc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.1","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d816a04-1596238574602_1596238630358_0.15420445716513753","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0836c80-1596406709591":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0836c80-1596406709591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0836c80-1596406709591","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"23f5b92871b867a036c9b7e60422dfb07ad213d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0836c80-1596406709591.tgz","fileCount":7,"integrity":"sha512-fmzRw9xbpHVuYoRPote0DyaIpoG2DNmcAPbReDAV/S5fksLEYNNFtfxp+i/RmDzpFVn7DnbUFQizF/W+BrfRiA==","signatures":[{"sig":"MEQCICBk2LkUaPtHVw42zP5kMktUPP/pT7IwlKca8NnWXi7iAiBfS1FrI4dmcoaqIfFeMZchaUCW6GJPMzP62L7sF108PA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJzvuCRA9TVsSAnZWagAARjcP+wfUW8s4NlgP/9iyeTBL\nLdWXwSyo88VpX9jcDlttkXt/hm2Ra69sSIGxddo/7Nll6DnNaUcbjjRp003/\n7cjAIpnzKo0aZosPZANRfrxDSiUfCukJFM0ml+usP3rlAGJojf0U3fIQ30A9\nZKZZnkthmW6yG1T72U8u5nEENkjgqxyPLZXLy2ZIwaoiN1VHrwNejKxMdqAM\nZHLeqY5cnhAqeHcMmi/OudQp+KkQhieiWRNx7aLPB1jooCA2xWMryMHbRwyi\nCzIJaaRRJJUk/SjDvXx2nU6uvjjVFgUCr/MHtXXmF0mhcbyQgQX6shvSzIhX\nPbpj4L0U1lq1XENocSvUAUh0d408GbmXeELJEc0jysa+7VIOCfetUFw5ofjW\n0LrUMSxpYxWTvTEAE2hkWqndP867TMw8Zau4k4M45a4CnE1O9My1i15q+avB\n6vfbN04rj04Vq7mFDhO+QJmjiSvq8QxLtwxLfKEjjaEgM5z502MZJrF3aTOh\nPrNC8bnnTW+hq4mGNHKZyOdBPIcVC5nuxBp28M3edTb4AdjAEyNN5nzS56RE\nQgH+iWAeHWOtkPsesUbYsSWnFX43HK1WGeZa1Xvz7nB6BhWQbn5hejAbBo6m\nfn0IwkmCHtodLqxuczaDnPihg0BSkXPpH/EFSEEN86ESlZNfxaU7WWS1y5zy\niOG4\r\n=mvEq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0836c80-1596406709591_1596406765925_0.5195344901893271","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-aa451ca-1596492929392":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-aa451ca-1596492929392","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-aa451ca-1596492929392","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"58df0fd3cdf4d753c5a2773b78a81a9f6100a15d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-aa451ca-1596492929392.tgz","fileCount":7,"integrity":"sha512-fFooaITQcImC0IAcmy8tBF+NDNPbI2aof++VETgQKZZqMIwHdnt7/dG1N4Dfqw4hLO35oBqmZ4TQYbknUUA77w==","signatures":[{"sig":"MEYCIQCsAV10gZufOjP6DA9Q1bvBvWubEQfccRlvO+RRPyC7qQIhALphseMfpKxrZnt6/batteTjflbFSJD8K8zxTo4o4rJ0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfKIy6CRA9TVsSAnZWagAAVwoP/1ALTI/mqVX8jHJdOlhC\nFa3GyzlIRKNFsRSyUK3hByB4z1W/oH7QYP75+LUtYVizJJcbDujCx3qLWaBJ\nzJfM1ICSYrW70dRPME2JFAl2eQeFzLBnnO5nMakZSyDrRztLjxEfH7QRe2sU\nvfNMxw9KcKndZLa2GBWDg8M9Tedv8KOoBgZi9PU+eEm4BozGLrAZHeAPKtPc\nVomNGa15NsgHxC4hDZKyJrLoiU7BGHCK8Sm/Vr6aPuf9GnP3qNocN8A1Bu/x\nOYapqSmyF8jI98gREyhmT5pOYtpys1sMF01VfIWLPDRvkW61tR39ETBDB0c0\njR6/CDqU12MvL33//Juhw7eGEV4L/+hubSYKDHSNWydw2WYOFX44UPbh9FLx\nWgSjJzYwfvbvVS3419dv+V7JoKyPs4v9TytFMQYR7w496AN0JLsuuOQQv3FA\nGisqaVcq2hp9Z27SXQ/XwKJGyddmUYX10L5uS4epoV78a997QG4QY7TRHyJ5\nfdEDrQxNfhc770/XZN80aqgD8JwGDhmEBFTxKQokNN2f5GCIKIpCjs1bc5Yg\nyy5ydqVHHfsNetjFlzhV+sOYlwyrGn9tF+aZKQQbFR6aetg99XwFcOjPhs44\nZiR2pjl6ZOlZyQjqHi5AQn17by6BsuTqRUCnJLnmkLnRoT+zu09My/cIO5Nd\nHrwc\r\n=vbcQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-aa451ca-1596492929392_1596492986273_0.21425839689210546","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c01bf33-1596579274849":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c01bf33-1596579274849","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c01bf33-1596579274849","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4cb22f5bb2a16ad8641d8fd00fbcee58780ba0c0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c01bf33-1596579274849.tgz","fileCount":7,"integrity":"sha512-GSBOeC9Tx8WKaqJnwOEd24e1VG9CyLeEzJdjXhIuHe85sFSN9ql6OKIvqqjccNTQvD4omKj4zye7lyXWYKKrjQ==","signatures":[{"sig":"MEQCIFPGXpcdG1wXuje9qHS0dQxZtVy4UKIsikpIr5Uhr+vNAiAlEh/NYblrxfeqWQ/sfCsEJ4fe9MrbNVNUkQwZpZggUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfKd33CRA9TVsSAnZWagAA4MYP+wSANrtHEYflD6rb1Soy\noYVYzZB523A5sct9SMUyLYYEcXsRopycXxYVQATNy68A7p/9n3Hiw7ip7zxe\nMsNPpWbzpnmKKAjHbOMSoaLY77DPVNMOJbkRt+RTbaIjC63VydIpr909fwkJ\nYhk4FW7XZtuskNPk7C1OaM75xhwJbabOtpbFQHTUEK/mEnPq0xqM73vP9tb7\n5NWmDvb05hGstq6Fb3mYMwF3nctxT2TWjXCnE7fr8kPZgTD2nitfgZHDG/Nx\nu5QXRTrRkz1/kNT9z8FP+8zAvF/rX0/0W54jHMWZwv47J5kUsstB9mhKjqY3\nZ9EvZ6pKxL6sifCmOzyyWArFeKxPBR29PLfNIbJoRiNEa4+tQ+vyCpgUIukX\n5zYBIdF6KjvjVPzDD4In/0f6DMsTiMbU+cCjPUOwgbz0F2uGwdQzuS+05kog\nhqFNRh7Wiub+hjP3HsT/XGOwD2SzDEJvY39/O87YWhG0e4gyKDctHgG7h51W\nc8h6lClA7B1a2XHugf6RdCQfTQt4HvF7eKhVE1jTQhRq/ee7g9hwsNFyXnTS\n1s1vvavDmZJwaSjlV6VyT5b2VjVAOJTX7MzzrQ+JChBnoESIpRlMea3pK4kq\nAzhgmX1g6ADgdSh2GUBQKPN7ntXyW1s5nGMlOk1Vh6Yxot4VekXrIBFq6tju\nUNjW\r\n=lFGZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.8","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c01bf33-1596579274849_1596579318968_0.5023695329464057","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ceb9e9c-1596672332082":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ceb9e9c-1596672332082","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ceb9e9c-1596672332082","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ec5ded981593925f7a440c85641e80dc830fc312","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ceb9e9c-1596672332082.tgz","fileCount":7,"integrity":"sha512-Eg0Kgrb3VlT9kOdWZqlfrslPbjR+ahCFMZInDimmjN3W8Wes6+7lDO6YQz2LKWaiFSkKL011EDSgxr2mrEukLg==","signatures":[{"sig":"MEYCIQD0SKGGIk1wxYAlWjQjr1ZfBsuZrC7me8bxnps4Nce6sgIhAKaG1Uj9o0tkkv/2l9egNxbMb84kDOOb1cvPpLSJQ+NB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfK0l6CRA9TVsSAnZWagAAPQAQAJ8oyyvNUo7gQTWaAkSb\ngp9Z5sJJ2VguYG5aG5i+oqWayOV4/3nk31/g195M4klrJBsj2+wRWFT0VWef\nzcpEEChlDoa3KtbHU2eQPXKTqYt4iAycLNaD+KZXayzaXat6veUfzeOlBwV8\nqll66XiJV76lBYFp5ROZ5n0xI93XKCCBpzUaeGYPYoaoUp+qcDNHn/fMD658\nUaY/RggUQL0EdKSCoTWeJ5Zz0Y5BP3VJaB0MY1PX7L+/qj48l/IBb5zynly1\ntoQaYiR1to8Hm85Vr5j1lnOnQ0qSTq6dQmhMLhZr4/XutUr5NwVbpIVwSfYa\nqQLAp8VIqEIldbgJwnu4RJ5pV4yhjOlA6Bs3U3490ZnGUPKK1WHTFiEcIoE5\n5ryGig89kKJ5mYPs5Ps+71b5mrUBpCqNDTHBLLE7nUPzyN4MJQgkWkIewW3P\nDuKAUzVm759yuYxBGm1WL8P5j3OL58lu6A+YAXDiut+J9vQYoOlmnRfe+BPR\nBFY/WDuaTS6Zty4D/ukq6H5MuiUSecQai+3ribHERAJhbt8MGFfY6fzK5+55\n0NX3QmkTGcRvrxVcBgtgiuHwleAaanAxESiok3ZkqUctS783nPEcjHREzLR/\nBgbi2TYC/IFwjTyNjB/G65FUoUqOu0/pMChs0GFHKO/SLp2t5UxniKqvqVMo\n5pvr\r\n=PTTU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ceb9e9c-1596672332082_1596672377949_0.5482838318380883","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ceb9e9c-1596672339865":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ceb9e9c-1596672339865","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ceb9e9c-1596672339865","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fe00cda60dd5214a92a683c16bd61d63a0e0b254","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ceb9e9c-1596672339865.tgz","fileCount":7,"integrity":"sha512-e1zQK9PSzQiqFDiwSakghCFK3T6DYHgOTVxmIVf19Bb66Gto2mNhRsaO0+9RIL6QvTih9o1p2bId4Xnc0JxyVg==","signatures":[{"sig":"MEUCIQCvpC2r8SsW5QrXaNp/ynvr/wVZycDvLcd/vTQBD6RF8AIgCq8P52sqb5s6ISrL+P4r01wmWiCf97vNLNBYw0TYjTM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfK0mPCRA9TVsSAnZWagAA/CYP/0gRbN3Gi93a+wChYIFm\nmXEDf+55xxsiX9lTprierxmJ6BOlJ7QKPmJTXVZTZJ2xFzuuKI43L6um0GwL\ntLNjtMscKsRgNe0WxvF3l20c0tXdJq9PUDPaIt2ZFjtGyaTRh1yogRu6ciqv\nmQCTh2N6NxGhJlP8wBlWc6AYrLKjPIQrMqgVbwrA+2uD8AOvpM7AtTY1Bi2e\npGyiMV1pTbYFloip94y6jt2b63XflsQy/bv/MGz2V/8nscRttm3Lhjil1H28\nm1kmKVnnKQsQsq8al/+oe9q+KWsD4Gi6N9Hv2wFMx8t8tkH8Fy3bVV2XSS16\nTU07MhXi8whDXrfjK5DWaJzErAZIKYQY/ZcCUQ+MCq8xRJ2Db/haa4OP9x2c\nW4RNfSMDrubbG8S+ZjySpmm6t4vFRuH2Z20xvqh7qbmBOAkuvPzsdq7w3kgv\nertErWlFXf8SI4KXwF8bq7Z6u5jJrtzKPzuOZb/B+v8315v3nRLGXkbLcCF2\n1m2PaCQ9+bZuwMz50A1VoGp66witH5PalvHm5XzN0aT0Abwpka4TsRWIiDMx\nVxXJqJv1/DdBkGQbVRJKBWX9KcojNFgTjHPUi1OW67dfKAYUZCInW2ruG4xk\ncrg8IIDxkf78hXSYgbm6pKgbHnv43GjRXeLXfSrpxemOFU6DIJcVm/5H9r07\n6ytp\r\n=0SK/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.0","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ceb9e9c-1596672339865_1596672399298_0.9452250341055284","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-8b35b3a-1596753592307":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-8b35b3a-1596753592307","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-8b35b3a-1596753592307","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"41b407d072e160a3f93a9edfa905ce947b9b4dac","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-8b35b3a-1596753592307.tgz","fileCount":7,"integrity":"sha512-DTNnGgQAu4R5VlfbO0UFGY7nUgpCjS28y/zhhbZnleAlB6ya5LSQzU6pu9vLEYTkFgYf9QFKUMk9DqjpSg4pMQ==","signatures":[{"sig":"MEYCIQDmD96VhD92rdPgidyTNdXu0k/35rygZg5DTs9+zKdMGgIhAKKtsMsBGsgXzjvQOiFo6Lvz2HJ6zFBCoSbzQ8n/Dsx4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLIblCRA9TVsSAnZWagAARDEP/RHW3SSovsw6SPFjfOx9\nDEpED0QCKN0uUFSD7NKKL/pGM2fMW+gydoEng1OBcPi9x/tWuRuu6Ks29bHK\nclBh3fmyK3q0H/rVNE2uSRJt7ZLUsenC3HxvMZaGXHZfelSqDGJCX0FFYpFS\nzp0rX3k+Q38wNwllBg51nc8Ups8wK8sNqeUtutGhQfNugiNrE4r+foevxqvL\nDQdV4ju4Tgn/KmvDSDCKYIEtc8i/izrMkYzGWp5K+8NgTFYqslbcuNbGHmD4\nO7CWxBya4t2hIkcpqjh180hgExCTeIVKQoGsaR6BohMtoFXNnEYxyBRBciAD\n61x2xN7/mxFDd+CWW2o7gkaMUFTQZkJ1BKnLjbOjQOqiOoSiZBQrJESSDlZ9\nM5GiofAhMCA5+9+bM/9OxANiZFQ3Hn+0/3vCy6dU1j9tP24yb4OEkH+JU0jg\nhS8gdv/Gy7jBOEkG72CGZOMbsTqIQkuvexIPmYpZ6loK5O5sthaTdPigwFmR\nykd4c6usA2LeiT9zZLL2QLmWhoaV5X/GwUy5T+ewcfIYyh7gR7VLz56Gw+11\nS4JNp6lrF+HLYMrBy3JObKH/ehOC+EMMidKkv70TBsBN6GkVA/0PE8jtM1Ad\n01oiZtZKiRWaCrRI4L7J3QMclh17Y/FpgY32OqOK1X0Fvu89t9enGmomm8Ab\nkP+l\r\n=zuQ1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-8b35b3a-1596753592307_1596753637465_0.047177357563758626","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-8b35b3a-1596753627736":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-8b35b3a-1596753627736","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-8b35b3a-1596753627736","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a9af03a937e28cadbd0379af3409f7a8722917a0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-8b35b3a-1596753627736.tgz","fileCount":7,"integrity":"sha512-FbcZNG+Nqml+1x5X0RU/t5JK1F5U9KJu8PqkXCglI9gIW5l9J5yZw0Ksbal23S+H0i4wYoRttszbbRx0Iq6/zg==","signatures":[{"sig":"MEUCIE++kN63lh0qaBTcSJdZ8AkdBSTbgxh0hobthKyekvmYAiEApA1xel68V0aoVg9ZAfGvaBRZswjal+kuWz9KRd0U1t8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLIcFCRA9TVsSAnZWagAAW7AP/1+DQssi7mR4OKFrcemp\n0h4CL8wBgYja5TtTpnM8fCp7JFOpy+HKJKpLQ3de7l/OOl/21K9dGnnJ5via\nrzG/Y3qlmWgCT+RW3OGLDsM76y1kGKRB2L6nRfq0PBQH5w1jFt2tKJ8ANhke\nvYWWFdNlE61mL8i1ewEkAS5+947wHQum6quv5F0Hk6rc/0ROc+zd4QOuqatQ\n5OO7Kpq57ASR270O0+guSQghTLrAcvcZe/U+dQ+YqL+IIsldKvYMYpon/S7F\nL3uB2rYlPw+tZZAiP/itXDrJgwKfpOcsjUExxPK4i+o1rcRY2DcM6QEK6MPO\n4WU27kg/U2vgusNqkMH3LKdT+Z/Iqsjy+zw5rBq4mU/CNwXb8RNT6ACx7vQo\nlwfHLjU44SpWxzaFLZRy0xmLaqKdbOPDRaEvYx7zQ1Y+QQ0thPyw1w05GGUW\n7Kx7tgjZH02NMAlJnw6jLvZ3M/9ik8N4TFqew5+uTEhtjX+bgWpPRdGPpbE2\nXpu6lwzUJ8nA9r/qPvHYJ8l8wWc5Gcs/FPwXwVuyINPOXsSIro5McCcLhB/l\naxrW4VBBjzQus29dMsp/c6/2DmifTYHBdVb37zcghetanfkgLHLO/YVF2A1M\nLKat4BnxJvLfLgh55+mo9+DCJWHndotFS9MNzPQcep9xqsixL8sFMTTmJ0kD\nXV1H\r\n=h7Us\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-8b35b3a-1596753627736_1596753669294_0.23464696749420377","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1b01986-1596824997735":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1b01986-1596824997735","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1b01986-1596824997735","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"28f3d01c0237822884f3046b9934254be0def759","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1b01986-1596824997735.tgz","fileCount":7,"integrity":"sha512-HMPsVVxj9I94JGNqKvuRHBwJyaRMw2T/ztIb+WVcnmXFBrV11+pwJAyieg7A3kPtfIEj5ARe+ZNf0XPCLvRxfg==","signatures":[{"sig":"MEYCIQC8y3o463yjK0DhUfwKnFp6ACfJOxgtZy2/+q1RVOdkLAIhAIfvAZfmzm9qfKOZiEk+8c7tY4Ibm+AqtYO+GS4R1JV6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLZ3RCRA9TVsSAnZWagAAlcoP/iCkyfqwkP5GLvvip4JN\n3A04vVenYyRaUbTUzeXvKBm4AksdxJ8wP/KjMdljFp8JE+lbiMytsVSAKR3h\nIv/zanatyAOKd4XkVLyfEFFPt0xygcMMEAo30/8MfL+cQ5J8lTt+j1MIHphd\ncGohyQUMpRs82Z/G9jkSC5jNaMvj1teRGYfkghCB6lLKb6ex1CuaDKZHptRD\nmkO2/ho4dMIkTN9pHuLvSa18f4eOkLGd+bGUKFgXfl7m/9N4IS+dt8YvaoYr\nfDYlIjJtZTV6c4mYJg4DuoOgYvBn4RbZSQIUq8PCWGxFdyvHf5RDe7Z0aVMy\nW7bEmnKXuoS9PJwPjuYEjyrzh8cM0HKZsHgRc9VuGfTnRFAm5mBE5cVX20AF\nx0fmtZ9CW29+P/54c+3wMs8e80D3xWRI/1BUrc2iy+hAv2EkFAlwzaQYwb5n\nWAnN2RVgZD2XrXF74SiEC3aygSEFqKzoPVr55rv/xtqvsRbtVIY9Nb+m/5pZ\ngZbirWP59iLsiZ2BsyreTA4yY3E9lLu60bthnPZRvNsIwSOxAFCDkvZgx6Yu\nQMY24zfHxfrq0gHfQ7YEdeqjD9/uc20MDbf1x+nnJS/m0CBiPRMU111Of+7S\n4eRboc9PoCUMBCNA1vxFY4s84KO4ktUd6UIu5k5ziy2hFI6BO5U2YM0NhY2B\nNh4L\r\n=nCRZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1b01986-1596824997735_1596825040952_0.4492953735301861","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1b01986-1596824996142":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1b01986-1596824996142","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1b01986-1596824996142","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"94ff511381055334c6cdc29891a28e625979085a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1b01986-1596824996142.tgz","fileCount":7,"integrity":"sha512-tp3X0Nb6FSgt+uWtfyC1I7FcGafhnu/jZf58O4+Ogt/YXoHIkuv4t6Ceo2q5hScsIYk7F8zAgvkxvTbIsdffsg==","signatures":[{"sig":"MEUCIQCz6Jg7r9Jyuj1BZ+s6rt75SHuoR2YGHZWf1bqfmMcq+gIgX7JrG6O8MQ0nF59+F5nQG/eNKAfUZKeQjdWWtR7YyXk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLZ3jCRA9TVsSAnZWagAAf2QP/04Ho9sWOqfKWYaz+z+Z\nJKP44UgRObXzuuvC0sKt6G+nAuKtklKVvQUJ73+K3863fOHf1+66PXl+UfAk\nREMyQDOOl5vyg3EFP2OGX8fjlaIXKuj/oiNNT5gSVkdXrU/7KtnX2zH331Qs\nXqvMSS/q6nhYzP23lnks4ODWf/2S96M3mBiytQEhFq7jDdEvhvDWcLHk6MDY\nUtgOt0uU1/Yq8dUJLqxdWzSQYhHpJM+hY3P3vDkVmYEgwAyZHP/gMC3eCrql\ni5ct+2ITvPgGx/Ghu1LEcgAjg+byg0Vub+6YRVDOeFi34/chB2YbqUsbSpuf\nFxyQOHbya8IGNuC8t5OEAeOOt5TFqLpg8ulsClReghR/f3yEiTLk/P4UsvcN\natbjIAcsJwfyM5XSrjfEs7D6C9zz3JIb6MmaA2XGurqdnjjS0xHYYdix3q6N\n3zHr2LUB7C1WWyCk4e7aGNfyLX3UEU6xQB6PYNd0k6m93A7neUscr97lxvsh\nAwaVLl+yI755ic7HyWbDQ3ZCZls5pioIC8ZiV8BRBAUhRhrG8Q9TWP/kRFGV\nne4bmLp2I9Ml209WCoJy8kiM1iLI2AqnOBB0Z8TJQZs/jtXhszJ7l7Yh/avy\n+KQRu81dPbOXNV9SU+JN1LUzxoYqGa4OGDUnfUI9aj3xaoX14kP5H0X2WGOS\n/C5U\r\n=QSzz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.0","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1b01986-1596824996142_1596825058668_0.6364753440060211","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b7da9f2-1596830003325":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b7da9f2-1596830003325","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b7da9f2-1596830003325","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"da925072f7af3ef6b0dafaa827c7c5eadfb3d58d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b7da9f2-1596830003325.tgz","fileCount":7,"integrity":"sha512-Fl6ybPpW8Nhifc+jNWAhQBlVsJHxdHUT3soIZ2Gu/9YAWrylCUQaWg9tBw7ndlRav8j+XQDEDOS/fUtssdtD2g==","signatures":[{"sig":"MEUCIAqjp2O76G+Dsb7iJ1HCDLRCky3lzCEVd6wPbihRqFz6AiEAwilnH4+fxgvzGVxi01I7p+k+i5iHg0xK4cRZPeX71O4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLbFjCRA9TVsSAnZWagAAWz4P/jpT/NHNZj0UoLrfMdWg\n062D3bjtx9ooPBPC2XIHbcOYM2dPl65sQn2U5GAwKC44WAcrmLsCCS9R8tJr\ndhFTLNFbVJPfM+2zA2G2WKVCrh0cNeHtVnKjnc6z7Pfq6lDFiFOThNF18CqO\nYM9hIgKTgJxwpC6VV/ZRu/VMCGlOZvu9CMCEKqf46P461sVc6yl2k3gTYL/B\n68pNzLVDAm6qVKm+AglJ9WB3zlNiMYJ6SXSI3ffYq69vuBApTHRHX107QoUu\nvLNZVsk93Ik58YrI8FHad9mcOcox09yxISr/LHIgz2caxblrf6YwyimTdlFi\noh7Fd0GehqMZ/3QqF8yC0mtVwQx+mzzDOkon6uN1F0ujmKnFNgvIH+hwCitP\nKj48sFbAfc7PTpx+HssbqI0Eu99R+K/GzkCH778hjRAQf/YLKt40rX3567PU\ntzAIXQHglGAvcyJAr14cBeAf4hPlzZPdnFMUCgDagz8lAtGtP7emNEu0OSEu\ns63bGJkrJ72LzzLImhCXCCircMqo9FmU8ZCdDQJUtrSShujAfuJd98UQWsmG\nIxB4MEN3Mt/5CYA1Nz8x9j18lpVTxQkGJBPVlFki7sWrhVgogJm2PkULYI3d\np20MMUSQqP6IdmDg5HJNIeT+ptrSPoH1IgAA5OzOBXbs/oFAv5amuvVdXtrc\nZ40m\r\n=5OZM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b7da9f2-1596830003325_1596830051330_0.12122918933018867","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b7da9f2-1596830005960":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b7da9f2-1596830005960","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b7da9f2-1596830005960","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b3040e41399b982693cf086553caeeb27e2e8c37","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b7da9f2-1596830005960.tgz","fileCount":7,"integrity":"sha512-M5X+wN1wuQJNw8HWAWuusJRjd4Qb+ae9+8Qoj84pXUDX63Eqi1jnVrtKq6A4hSpcZ320R2zttbaticCMU0iAuA==","signatures":[{"sig":"MEYCIQDF7AQVKE5uT9exMGiZLeBsZrdlCcIgqS39hvdt5jDRSgIhAJyxmue/mXzEdtWc57ySolgfV7Ox+SOY6zTEoCqIySGg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLbFnCRA9TVsSAnZWagAAubAP/RQi3/8B9847EAReHx+T\nSWBiKa9vc6IPPbuqzYqzbV/jtL9GhdARC8/EX9tZDoGuK9RX8FY5X7HfWlzn\nBFnRfdzJlThrzme3iEn9Pd4R/nE1sPIMXGbQAZXdM9CyiWhTQADbBd8AIB37\nBKoqnVPdYXaNjlDEdwJzkT7i3AJglrhIFoPCxVL6nlciwY5VEKKbc4r97uhC\nUFsbpzMxL1RA7GUHtpDM6N0hoXJTzScQeSXaazEiu2kSGvwJSCEYmZQ0CMeS\nUB6t0cXWnT2Cmno1InDKZz060MO9wlwSPYRXHpTTHyZC60S+wjcCu7DkHbHZ\nK/TMxccDNQnkneLwiL+j681hBZfe94zn/agJtxpUd1nPiAz56znbRnkelANo\ncOA++I8HMougF4aMGTsL8MaLCTLRqJplRIdyBTi/aw7T5uZcGz0frPRTObTK\nDGVyuk8YQ41BCitCzbd4n8jW5SifhIeaFko2R1Zwcq/OzawMKTucWllkd60Q\nh4+LWvuZ01uIVlA5vNIOrNhbLme4NP1Xg0217OVl+jrYuE7wgiwQIRkdWte/\nN/CUXm2MaAFW8CFyiA9ZOFr9l2REMAkHwa5wXHHZ7Z1fQ+u2JZXwarTnFVXW\nSJEMXH9h+PHX1zrJJNvKESL5sXkekAJ/ZJ8BxRjMOe/ZcHz++tgqVeeCxQ4h\nWRSr\r\n=Q6xI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b7da9f2-1596830005960_1596830054791_0.366821400880438","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cbed595-1596934271099":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cbed595-1596934271099","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cbed595-1596934271099","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d03e5693cba85cb83cd1a197230b73d9f0ddc3fb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cbed595-1596934271099.tgz","fileCount":7,"integrity":"sha512-6Uf9cFrS2YCmkxGKNjCYA/smiqvAvC2PJn14Ockvp3P3Js7SDAUGurtfd17lkcC1iManRLNxmvlvTqQLCu1hEg==","signatures":[{"sig":"MEQCIEmBQ6oS4OiUo9dLomiARcYInxkFC2/d3BvyXM3ufXMfAiBT/FOQ2XDeM1YQvyOMVLttXaewma+d5+rg/Mw9sKDziw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL0i/CRA9TVsSAnZWagAA/8oP/3NOE+Lrers4ELthnkdN\naMcZVpNjdNQwFi26MIDJtXL8pz2IWEMZ2QVeescd6ElpTw6i49fep0rGza7J\nWPfzSaUs7Hz3PfYKlF5Tmy80SBTQfqCul7KFvZmbPdmougjFQ9mtNGFCA6mD\nn52xKZXtz0tk3SCEzBhRaVW9eyBrEIdwAS0sSw2tawaQ0NA9sPtUqBUHPsbv\nQgrnD8vH52xYRRDZo1N/Fzp2wxkUNXWzSbvMynhvH0olrshMgGNvV0V4YHkq\nBQP+I2ePqwrVmf26oJdBD/GEEBOutyjjpjMqUGRHzeLt9azQvvnZ/39wuA5o\nvSZM/tyds8yspmRoXv/V2wnkjbDLcqgWtF8aov+AjuKi935I6x1zN7uqGuOt\naGOk0zv6jwWQd7rEwR/WKtqQxYe4e1+DQeyRHV2VEx+xtZNp04npNXNBuFmO\n9pcoZYKCwb4vJLOsHWT3Um1+CwBewia4qO6xF6yZP8De38pSvvaj1YlSOjeD\nIAwUgKZjYL87QOp/XiFws08p5q7Nvtu6xtJQRJo0Hapu6n815CoWFcuM6afR\nLqx5ne1SpZHPfGhB8iCYeBXarYsXk2HIYQicxChcROBNK2jDu4dSFRbl6z9l\nLE49c2mWVfhDCQ1kNhgKOMgvO71QiJ0hLe3GZ828lhpkdhNnrT45ELxzfqNj\nVAXl\r\n=g5gg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cbed595-1596934271099_1596934335302_0.1748643779193173","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cbed595-1596934268193":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cbed595-1596934268193","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cbed595-1596934268193","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e536ed448aed704eece12b64484ab89eb9d0a0cf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cbed595-1596934268193.tgz","fileCount":7,"integrity":"sha512-o/Q512wsTjIj+h+u0e0LVLuHOynIjXPYpkmLgGbXtJE+mpH9F1M4XCEwmUNL1s26ThV8KcVDvcuN4rRSN7zoNw==","signatures":[{"sig":"MEQCIGc5vBcVB+snjJ0HlaSYfKH3/7fqoiBmNBPIJvUpzVaXAiA3PRb5bRDV6Wn9adBQOjlR78Nhzb7Q2BD16hN2cmk9LA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL0jNCRA9TVsSAnZWagAALSEP/1OQk8B9iyDFuQQ6ywNx\nlyQvoV4OOn2vxA3QN/eg/rxsAQT60koQ8/FalaCsjEKMXsGxQXJNu8W90X2s\nXODths4zrrahGb/pkIA8us4LmX6F09ZzcoUpgVCWJ57b2uSWYsgzfVu9nGsh\nLj/DxDYrYq22tplT6m24Kj0xejspPbSGqi/zU+Etj+QjdI6wgWm9sjFqDKko\nygvAiUTtH4RSSP7/sP4QRYxcgNxQsn/DnM6gTwi0qyxrWh+BqcDJ7hlTwjXi\ny0moV5GSobCFE3yVGw/yZESY3cS8Bt1hNs+VKez4mgMtPj3F8XBxOSfopCPh\nHTZD5lHm7jmHbFJiWgEBITLm7sFUFEqtZC3fMS6cqnklM7XfGEypcCkpf1kx\nToE/eqMTg+Yq93WpVaknHcSY+zH7VEK26r+YOu/LWxRia1xzaJPojPkpu07w\nrw5rIMOZN5u7Er8PkxUE2NJP8sKwjwEA8jADHd4tFiq6CpzA9vr5s7cISg49\niao8qbATUZzYi4eGGHv2n4Tce55KVpIpCoM87wycR/52v+9PQjfmeDdb2qyb\nptEmMWTVkWQlQ3o69tmpr0Z8VquVf7tszGsOtsI82ViVXMt+CEJBrezVo9Kq\nDmWv+Q0w4Xe/DZyA3jRzZDdBfg3Q1ArqptAM+Z3gyOP2eTD6YsGzyyJeMasP\nptjQ\r\n=LjfK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cbed595-1596934268193_1596934348989_0.5934462564319329","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c5fe0ba-1596978391327":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c5fe0ba-1596978391327","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c5fe0ba-1596978391327","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d9aed1a29738e1b06924189c1acdc807eb729564","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c5fe0ba-1596978391327.tgz","fileCount":7,"integrity":"sha512-r5aMJ/Php7dK9q0HiOkrXA/kBwUqXpCEFI6jKO/ndtmhKaBytJ5q3rY+dOaZge7tw6767RaIF1/+crArfadk/A==","signatures":[{"sig":"MEUCIQDmdvfp8cgc5M/gqaey0nNjrpWz/Va/7HkvnUOr8/ObvwIgNcj7ITYBgJXvZ/unURY4Q1X43hnMR/rqjqT6hLwNT9M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL/UNCRA9TVsSAnZWagAAGEUP/iShulWsKdps8npHm68E\nF8BU/Adz/8RyZAaNmLih6dJTU8vsUxH3hV47NQJ/xXnJCn2rHVxQ+MjszbSj\nmmsYgwctpJ/rsQgRfzQodZ9LJGf/bdpBbgs87fKzq2ohrG2rqJiaHKalDkfM\n4ilZtJci35owFWfOu7o+GDqDd7ThQpdGUjVl79foTc+yOfjiv3GlKHkx5aYE\n0diY0GBjx090TnJjp1DT8lhJKiXSfNDd+xeVPDRPippkufch3Jmb02DKC0PL\n+J/xUrwAVd/6YDThKNikPj0KXZ8MmE/mjW20oEqxXIm/EWfkcWqAT5eu5D3y\nEqwU4po7Sw/81HU9Ra3uW+jCRiuflbn5uO4RkDHRNmXp7tfgLcOkhS+v8d9M\nKyKtcR+WXEHoQzckIog7ORFfb8g+OE7GVHtcMFD7JfeES1Ghtw7kiALJMB50\nf/hZ6sKd+joIiGuHOU904nysRB+GD5zPZ9mxfWtOSaI0E9bbHhrSKV5rvNxQ\negulItyC/P8qo8fwgxJnaIbA+oRPidOyntjImIPlmmJCDEGRfdTvs/uniPKJ\nYZRxkG8ArjBz87ERv21b258YtJ2TROaf1NALtfGxv6WQCgLtly1Q8TXKZFYS\n/e67YMq4v5k+bTcDv6trJS1MIUZ6+9KGYrYEBBI33bxV2LuBvmPujWUFIsFu\nf304\r\n=tNTU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c5fe0ba-1596978391327_1596978445214_0.04133654858138991","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c5fe0ba-1596978388611":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c5fe0ba-1596978388611","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c5fe0ba-1596978388611","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e5bcd36fa409636480de1e8d61b3f2b638d551d5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c5fe0ba-1596978388611.tgz","fileCount":7,"integrity":"sha512-Qk27aueC28KRRYVVggjJXZIyJnCOesElynBeS5CwlOUDYC4GeuBF3v1TOS/Zq8Rz4RKFqe25iMMVEno4yxXwqg==","signatures":[{"sig":"MEUCIGNlq4bWGBCmH2wInf0JAhi6Z7FYZFWfm4674Art91dHAiEAgtIw7cfCw1b0UucbX8EXT+8BNn+cNHRXCX2Wc5SpczA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL/UdCRA9TVsSAnZWagAApa4P/1tZBu9XGlVdYPnnBQnh\nuDeEKqVR/8iLNeh6c3h+6rUhwOM52uV6rmcLygVg0jtvgKxOorojrjuBQfCA\n1oErSHkqkmrmh59lWashMKyAwHHXMQX2tayktBLsLebn2iGSkbhEY8yk2cc3\nInmJn+OpUVWUi4VQa/+LdLovIaBDrkR/0Uq/+VMyPVXLNMDBgI9WHaGajKAx\n/mq33wIIUBh6akniTSPaBQZBk1YHPBa1u4iHMFNsqGDVbAO0gGRjwbhLuhFp\n3/M5UHU/+h0RtDzbSA3QE1pvyCzN/xPRf3g8gRCTiWExx33HodcDAU5/iQhV\nAM1HL5bIcJ2Y1+ftjPvVJDpaluEo5S16/MzqrmAaKWO9PXK9zY+qBPhb7LRb\n9Of0DM1ikruyKixjOc0CzCKtbEf0GjZDSi65XoDqvJyivgPj/Euo6b8RLBZA\n+580EQ2F7qYCVwC9bZ7Fy6gsJtphBld/3nwV6wxbuK7+txd67bo50Wk6nPut\nuaqFbleJ0scRe9gptUxI1qx7ii4OFOaVq26nzUWLZwRFZ7xzwi+HNoF68qCs\nqK7hDIkkPHO1TwsK1QVgc1jl4zITNW/QbfPO/iuMY6B11vLmQWKWuhmFuMbV\nbFA0t+/fHr/fc4IPtLtZoVcQB7l461UYSdAM/V2TMXrzSG/9DiubHjADu/aC\nN+7F\r\n=UjVb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c5fe0ba-1596978388611_1596978460787_0.886166766155843","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-40e8fd1-1597044224222":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-40e8fd1-1597044224222","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-40e8fd1-1597044224222","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4c7d59f0d39310035034828dbd5c0e937c5dd506","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-40e8fd1-1597044224222.tgz","fileCount":7,"integrity":"sha512-V7C99ON0y2zlpy0V3UGLwM1j/VbqidILkz5lcbXksoaJtmEv4G8U3bAGXORybka45udqyP+ADSEcvyHcsKEx/g==","signatures":[{"sig":"MEUCID7/D+cSO9mksgY4QS/IE4GxJkhgpsI3dbanAw9KfBqNAiEApLI5iMSnnHlYwXmGaP/OlMbVLtb4H7xxqQfQm5jiq88=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPY1CRA9TVsSAnZWagAAGToP/jq+NLjhOitD0sBsRsFp\n6lkBsaiif1mZnF3qJTeYsaWYaS84Ii1/SK4ItrqjY8g9/n94xIlz4g07JQWr\nDxGeYALUvI9vxPvXpgA7H24iXCOMrTI6llHTw/HenUjtGJMyMDxL15E5ndK5\nh41qKOwtwbyF43ZzvoLlfpoIqGgc+gDXmc1RtDH6ebTR57xXZBWe1TfZ+wfa\nTDFmV7H0gc9KbNTsziFrmbnmhXRJ5zJ+HoD7WG9wYLypz7/aenGc8xW5T28E\n8ScPaBOzGsGqLmBRMpbnM2TMHfMbaMerLuU5Z9GlAOIKTBMDPFbL1Jzke7C7\n+J4So9RBc/C4TEsvATsVeSaiscXK81CUEtrzYDRziFPK6y/RzyW1YM8Xh9TF\n4CGOFix0dKH8cHCMy+XPDWwR7Esm8s/fX0uKrwurtAqQdr0cwxWrJlq2Cwbg\nGCasXiUh4shCxpyIutZebbX+nwv5mhMdmiIsNk62P2ZsGONrNFTpNmjyBYH/\ng9eUtL25EhOR3sTAnroZHPlCYCzIN0KmXToM/m5fv6hqZcdTX+CUP9mY9pxo\ncxSNA2SJoQTFiK1gDocrUK4wsN4ZBXVGR+qYWC5lNhn8POUu/m6qWz2wvU9k\nYEoePzaIHjXWJsGwIGDMN1dmI6sYw7HV3k/DQ4opTmNKeSLdE+AoOPrgrkxf\nagSC\r\n=8oi9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-40e8fd1-1597044224222_1597044277199_0.45245828551070666","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7335af5-1597044237825":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7335af5-1597044237825","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7335af5-1597044237825","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e676fb202129c393fcde0c53581b7cf4b41e0e22","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7335af5-1597044237825.tgz","fileCount":7,"integrity":"sha512-AoFHhfPPdzGxhL3WkF7xaK7LbIHHl6vDgVy0p4pZ0QVlJkHnlL7gdOjrlezwQL8WIAOIwitjmgS/8eykyLk2lw==","signatures":[{"sig":"MEUCIBzTJvvPa7PaKlDibd4vdFRxSB+RhvaUKjLabCiBif2AAiEAuiVkj9R5Hq6ZEmb9mZxljWWvh6CP1VBD/AlDie2d1rw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPZCCRA9TVsSAnZWagAAK6QP/2x1LNIuwfFGQxglU4hw\nnFhvliIB8xljbokPCddCUh2j0G2bYnmGu5E4KOpzkMMDw1ldeGetlaL6vd4E\nSCW646Z1gFc5wudw/SgwM6XjJkLevffqdDo8GyQk8MaHJG0x/8SIZSij6f9U\n/g+D8VKTZz5Ru2E2PXAESDMNJk1NrvSka7XNiRAPtlQwjcSMlY4ubSEhZMvQ\n9Ka6MXBCOwk6UIMQTgPqDBZwsOcUaGhNp5skIKHDsZHGczk1orb3OzQmGTml\nAdJcB7BKowcQnCj1lz0RBhH0hvh3KJuLVLZmW5mEcl1aFIPKr1/0w6eFck76\nqmjruOFSKzZIQBZkIVbyEPfhdc+e1PXs1gcVvFpq5pRD9Uyhr7ZFZEaWrJ8B\nwSIr5ey17hYntr8pP8U5YI+juI/e3g3V8e4dFf+fTT8EnycSdfxKlBcPAB+F\nt9nbGCXqkinI04aP6YBoCqLlrkOOySeVZGpgxpiXNmpIcJJuIZaDlT59wq82\nASDtp2Ao1lauD2wP2j9Gz0tFuz80ON2vQJ+KaEfhHa51ZwJVOT0zC0C15QB4\n2FJKPuXL/YlSWCu7L/VO0G7CsIVmKUgBip9izeFs4oQHZWCysQ6TgKIGYhoZ\nO72x1Jlke/sNLNnBLM8KjtIdHkxNrUznm/I8qZbv0KtLgw8zQHUo6zj3vMgA\n/Z/t\r\n=XicF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7335af5-1597044237825_1597044290509_0.8785200441390011","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5a84f2a-1597044418286":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5a84f2a-1597044418286","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5a84f2a-1597044418286","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"318964410630fa8250283dea1bf88db883b331b5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5a84f2a-1597044418286.tgz","fileCount":7,"integrity":"sha512-FlWbyZRyp7tRuATswzxjvmdyDckbdafQizDYvch6Nmn6nezj+sweQCmcHDgk/UUls+iOH5V8EsBaSwy9oYzPqg==","signatures":[{"sig":"MEUCIQDUKAr1NPUuaHRd4/+8IDw8CPf35lzQXba7W3Xn75XMRgIgNRc7OeJsSvH9FqkrJLKDavcUfAYLyV0xhfVGMnAUqQo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPb5CRA9TVsSAnZWagAAkL4QAJxNM/SzVbTlrwe2BeJK\nouzSSU97r2wJNH1VfDpVBP7UpLxWMX7omZcinVkYIYkHiWvX49XQT296yp0h\nx+8KEpz+Mb/584LU3Qrs+e2APe1LuttiFxbNViEi2y/x7s+bmL1SJdjVt5aS\nTG0/SchR+mkDyrm9XzNYwvzbCmIuch9msjqtkV0ftfbWAOer4byMdJTB5Glr\ncq36d4Rfi3z6MPdu5rMQ61AkwNBxHv6uCY8QWxwsIJDoVpK8oCHfsNGUUEDu\nz4mc1/A5pOSzjzsstkeYVNEyVgeOmTCIdrHzl3yyDauiYa/X8JtAf9ZJaLfi\nYBBdkW2I27LDSyG7nFFdSEDao6m3KGOSIYnM/aQvvrTjo6ixRQKeGNgN6IUl\nPpBl9r2P88BF2wh+RLz95oq8gOUrtIfzuj6iR2/BpPMZB9oZHS6AKzcax5hK\n1mY7BoC1qxszMTzdEOPSwMCHfThSSMU98WevQXgScE3AKoMxfvGleLrJryEO\nEGCwdaEpl9V0zh8rO77bMxXTtrkSBRIIPN2R4fYf1Tl2Pa/a7WTnNDAT1Ack\nf4qstb9yDoyl8pPaEQH/FUSisK/QWdvgXuZ8q9O0LJHS1bCsXwPmOC46TW1Q\nY/8PjvMVcYSgYnQsgIInrC2K6XdXisDzyszLWaYJvqEllGsgoTmstCCQM9je\ngXwH\r\n=2LOs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5a84f2a-1597044418286_1597044472807_0.7619849124599454","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6a4672f-1597044441137":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6a4672f-1597044441137","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6a4672f-1597044441137","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9418f359afddfde9a504ec45d34d8eb7ba3653d7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6a4672f-1597044441137.tgz","fileCount":7,"integrity":"sha512-YbFjtusqki30w//lAutIdqgi9fE8eTUAafXBG99cScu823K8O9lDlbnjb6Y3fBo8O/r8ypgFTlpalZi0RZrd+w==","signatures":[{"sig":"MEYCIQD3oAn7SMT4bOpSI+OGJPG5mKpqulMEizTxXVydauyWVgIhAJ6g/Z8yxEj6sEVvyCSkRLp4197X9EMyE2+u4YzjDw80","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPcNCRA9TVsSAnZWagAAmn4P/jHnJ7UVbQn482PTG92H\nxYNrVbbd+8ujd74JnbI48+EIR2OsihMAmUWv8vtt23NvYq9bdRV8vrDpK6FJ\nZSgW64Cd2Bur1LBS+ue9afWOI7mHwyye8CBxenk99TIuZf5glCDtgt8LyfbF\nQgrN5dxo9dU9HuMhIrr0UOjfIbIIOeeSnrT4kT/Ek7/YBeEbUBkjtP7eAob0\nWwt3L3qIpsRlsTIhG1cv7kzwaMkBRHeeXLnA1A49peeNdHCTifyg8CMv71IP\nbzisMdg87ZPyhgcWsCoZMaKvywpJ0T2LU8GLHLm0k8u70GcTAdAbj8QZ1jEy\nVFVvsn+RmGcM2rzY+Pken7z+Uu4M6NeecTX6lWKUaFsPf9eBjMvGL0e/6+mn\n8oaBgQTqn9+1pLV0KCBHr/wEGqkJInVh/e+CQG0j6mfbPRu+yximNmRt8Rx7\nHow+naHa6c8KVbXcjgVqJefB3d3xfU/yJuzycAYkZ9C/6aORXHs8HiGP+vYy\nSyKFU9LFyBx8AeP/mEV7kVpXi9kPMlPLgaFJ/5/etTIaNhyHTL8lrCff5reO\naoH7sPSf+N5vVkoflSfEW3HVWT9I9woCwQea0CpH8i6IM/1L1fMLGgnIcVUd\nIPvVVXKLwHkioBhPfzPJu3McxhnaU4Roz4oFDSByyLvYKor+nloXdcfOg9Ww\nBKr1\r\n=lMhX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6a4672f-1597044441137_1597044493415_0.6493872389875552","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a4f01e6-1597044580143":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a4f01e6-1597044580143","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a4f01e6-1597044580143","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"09c0aa25586ac4a54abba26b1d36b40d21772cbc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a4f01e6-1597044580143.tgz","fileCount":7,"integrity":"sha512-WpqM9Czi4gf7MCvzaseBA/L/fti4Sk1DW+nPbmYns3DGHdQ4fiksW302Y+vPZSWYm1n1DcjtiohuxSKl4zL7jg==","signatures":[{"sig":"MEQCIFbHvv7uNzOUzSopEhF212zJHocu33Pes7e8ODGpwZ5tAiBLMk40LgiglhbH3nBI7BdmB77m9FxgN5T6QzyzPqBvFA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPeWCRA9TVsSAnZWagAAtyIP/Ax37B0ZYhczhE2qg29F\ntFN7GiKfv7jPhHSu16oAHHZle6N+AugQrUNXJEN/m/gIXRKh2YhWp+8WLoeX\ntp8tx3Sk/r30jAPY1WHD84Oxb5ik4jIiiRk8NJijZiMZDLVXf7KTfuPOHdT2\nJ9thznXnnQ2l7oJDUgntk745Qs5gdIc7sye/hOoRmSq5lsD2GuCVZGkKhpKQ\njeuTcm2K89r/leyPkvvEHMgPH0ydXPY/aZdV8U5nGNWlisPZrwk0rUToQPNX\nU4e23U6uIN1FTCstCXXzBx+c9cqSzuPRtf1yEMZTMkKXc0UKF8wCNvnH3I49\n0C79M4I5ZUQk5lAUJCZJyBnObOMQZsX5i971cpNMxi+j0KtA8iSih2xAN4xD\nRJp9k/Pl6LFR2LnGczTFGIdjrqBNZtge23zRDdc86F6tHpLHJkzQczozNqMA\nAaIWgRFnysdowu/5ZfyJe30EFQyysz+ft0fMYPI2RG2sMLQ8WrkXbRzNLSCR\n0PbkKrteRjNmyhmbuI9DsbRSMFw8EGiS53hYl9gfMUwLQ8d+/dCDVfyJawtV\nCLXKQ+jVUqEt0cfFhreSXjh4b1K+fE7ltIhWiSjbC28IF1Nm7Qd7pInYtRLT\nQji1rlDUOa7hnV9umknCpSGhxsWOl8bXiAP0LsYckD5VNN1aJeEnsT/2GGbw\n4NWF\r\n=0e3E\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a4f01e6-1597044580143_1597044629971_0.8308615522669847","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-62ce1fc-1597044587007":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-62ce1fc-1597044587007","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-62ce1fc-1597044587007","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f0b82b68b38d9669fcf7450c303552a95e079586","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-62ce1fc-1597044587007.tgz","fileCount":7,"integrity":"sha512-9VQAX5m759Deo2DMywjr9052l++r5H2qf8RG97t/Z7N1x1bqiOsjQ3jzLYqV524fDKTp1mbGOVc296CRJe4Ghg==","signatures":[{"sig":"MEUCIQD2jFcKJ1+R9E3Zdmh36kH9g0nN2yhCJF920gACczSM8gIgJSeoK9eVsQ3/GnrrXafqLU5fWc6RfAxF7h/iy8rm4qs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPeaCRA9TVsSAnZWagAA3ggP/2FGlcD9865tL6hJqT6U\nS0SpxkFkiT4bL61Df4I3kJRyIw4QjQDtDMxl02lhMfnL+Nq+683qO5w4r1A6\nr9vbqpbRSlMUf1m29RG8QAEJ3AOX4O3WnHwHXbGZq2ZQUoTZCxp7NBth8yTW\n2dTcWcwigsaoOCPAWziPY3GxkAyrnAO1OPvgvpxvmySZNZkc+PSNup+tCK0+\nRoO3UbDr5OzqqRvWORIGAEb7TpS3YMJNlC6hKUvm1YnWL9XrEGX0fNdZ4Ur/\nWHZx3bnRBgjBTsNvKSzxQoE1uRA0fLI5+ad7MTPuqpr0JnCubJz9jCubyiqy\nQXuplcz3Ak1RqbcF1x7IicC9/ZmvrZY6AtLkFzb36lHZBp91osH2TJ9zkkkP\nI/9vRkBAs+vfcgbFvxe+b/N95b/hrKmC0wGoLt3TW3UJvN0Z2R+2cwTg3AJf\n4rqSH/KHCN6rs+/LYLmPIfAuzF9uQu/wTB9J3ZALHtJum3//8WxkaRrJnO8b\n6HuwoXmBw3+nvO5tPZ7Yxjh/mTuDtr1dGS1X04v6lLXLPnebCBaY5O4eA8Qp\nude4yvYULa1eDbgMoUOnSVMYLOEQ1pBKqXk5OZ5Q1yVyi77GbUY+IY5yPEwW\nvl+iGIqQa2N9ro5VRcVoTCdkFxmhLsgq2aMP/dXekXk5B0lpV5bwVEI9WO8N\nXbhY\r\n=R4X8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-62ce1fc-1597044587007_1597044634136_0.39640385035996406","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0fa5751-1597044771127":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0fa5751-1597044771127","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0fa5751-1597044771127","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d2d084406f2a5e5c75f376c86a9a43147680d22","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0fa5751-1597044771127.tgz","fileCount":7,"integrity":"sha512-S2IxFmGMXsJ0Zdra4+pdK+ZIIu6WEcmDBYICfnw/NEXH8+T/p/P7lGNRpNJSy6F3I6HJ7IheEWNKaINj7/CdZA==","signatures":[{"sig":"MEUCIQDAfEwG+goG+CQt/yI1uBfWvf+AMN8/mRludRRCDlb1iwIgOT5dKjfSgS3hGZ1XFxZykOQWPl9YokVtT4YfeKk5OKM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPhRCRA9TVsSAnZWagAAwx0P/06+O7xRflJL6c4Umh03\nc+ADy6kWiP1TmqPP0DzSs9I9TRNdiC35EBGygVdPr/GehJJjoYd3qLCvTbgU\nzHY5f2juSRNMgXCb2qUjKb0G/Xg+pQ+2gqEOksgOBEg9uw0p3eFcgdxx58w3\naavEY9m3vf2oDr8xnaIKh4vSnlCNfuhLHp3VLvdfxUEd6ZJHMtwq7pXaABeu\nPitSeidu46Mk0vF9BQ2o195rLUr5slcmJE69eFN6ahkNkO/s+Hx3PJUJfyrr\nB5eqDB/AEkm3NZ6cH6u9LI9+7XuzOyEgg2OV7Olp2DFfu8MTXPJuD0IMbwdi\np4Z0Cxm9iS+/A/zzNg506085hddaIk+ZK/Kjfpac2EXDhyZAC/f7ATW/q2qf\nJevRUEHiIK/RfeMkCCtmJMer0OQ7xyzvu3TZtZKIfmiB+K7OSkC5Vk7IrYII\nNrLnGiRPV8GLSTpsctxUnISl0WWQIOVP6dDhIWslS4eyA46ZTcAoTnYvteYp\nCK99KTwNgOQAhZwvb1Dxs/OW0HsfW4HGIpRjj0NbVXkbw+lIImqDh4oHGq6/\nhiTB0tRPj0iLVrzaOctjZBTAd3Kppf30jq6OrssHbZrvd7rCjwDrqnKGzNtP\nFzF3vNCoy1+/cm8MbsUH6iBxO9EABTLT8al92TYN4+Wb1NEvZ2l8Uqx7etMr\nqAb8\r\n=vjof\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.17.8","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0fa5751-1597044771127_1597044817591_0.9071017543584825","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1a37def-1597044770687":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1a37def-1597044770687","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1a37def-1597044770687","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6ccd813404d7a4157bf5e1bf4105fcd665b03e89","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1a37def-1597044770687.tgz","fileCount":7,"integrity":"sha512-cI87SNxAsy40ejnD+sddCsExxk3lq0b7+jyb7XfOpDoUe77SmxHo9k0wA9dMMQxPiKaDPyQ3jRzgQnBOKXKtcg==","signatures":[{"sig":"MEQCIEE0DAQj6FlJkKnaYxj0ZxuOwLsEWGHTmyxztbzGZYXMAiANMiMrcqwfGk08NBX9D5ArNenXL6MPt9tmKwaNBEiQLw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPhiCRA9TVsSAnZWagAAQokP+wWQr3mAG5IQ6u3l3ouk\nwNBDqYfbdCtkcRQSVO3HERBlITxwyJVsNob2zcQry0B9HqPuolnf/m6C6dcN\nyE7E9Oqx104gxWUpq8NB8Y253LY9DnDlOq2RmuDUBX0Vng+WoUrhZXlX7KWt\naC0sNGesU2mFnr8JkvxybL/wGK/PcET0j/TqoTfBquF3+JWtrJObuBEopJBc\n3Kfg4pde1I76PmdqhscNMBrJyZE+pTAQUdqB79YV5QISAz66RV7zKJispfdS\n9izkt5rEZV2UzGecRno7qPd7G81bB0NSQAhLx03aLJkIZOJLkesMGmRD1sJC\nJWgU4kmPlWFO5JMFKv/9u8ZDgGnfOLzMbvgi8ZPr+0Jd+xqUPWmMHwRE48r0\nlwqFinQphOCP6ovt+WyJo3IwWvf6Pc+5ngcqBlj+v6HuJrfa+NbQTtM1c/Ux\noZkyycuM8suRRXAtl6yZjR/T+2V2JaN8B9HxbrCdc2xurvdoJb5+M1D7dYUB\nmpo9JT3LpU0fm0rYtjcgUga7ijA5aj/fwPPFwhYnNZBGaeqCwnfVK+1KdgHb\nUBwiQM5NnJoedBhNAJ/bnYEQ/FnOnp4krR6xyaEpN4IzuGerqkCYpxYg4560\n9gLoogvpCDXMf2/HlWbKl24l5PoS+mUyFdELxxRHcQ9e9NSQMklEkpf2O27E\ncaEJ\r\n=3N62\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1a37def-1597044770687_1597044834052_0.10790547426920516","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c8a8e12-1597044976405":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c8a8e12-1597044976405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c8a8e12-1597044976405","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2adccce0eb84c5eb351969dbe7321ef200a13cd8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c8a8e12-1597044976405.tgz","fileCount":7,"integrity":"sha512-1Sx9ZWf7kkAPr3XZR/YTyiRzkQxGac/5uvkGu2wI4E6hdW1byY1fSDWqYjTAHoFz0/yTgkhlaTzKBPP9BVAlgA==","signatures":[{"sig":"MEQCICwRrJbKdi488wPPNMkFrOOLs05pNBkbaNnd9FLhRiUmAiBCE8j+6kW6rpkWjfyt27H/L2yAlq1sMQiDRySp1YSCGA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPkdCRA9TVsSAnZWagAAsKYP/3ToSEWLwu8xKw+choyT\naPSLAQFGw0huup1SS1PsQ+UCgjhhZKdpiIAWrMe2YJaGEhJjuC4u+XgZPXWW\nNoBjfM0zzJawPSj2uCRuMuioSUARyI1/Oaa2t/3C31D63lV98zWT+fNPnKo+\nDHZbaUZHZdeF0P7HQsuNOp44ZMoyHtGfgEMTxOiF47QGmEmyOjBBmt4a8m/K\n2XM3UqbGNZ3PjB902CYbr7ORbN/C+YLP9v+J6KH6n2KJGhBJeeC+nGmzOBD5\nOvDQuIW3YaNMXcS9e79aGa9hifL6O07R9lk80yNufMa5Zs5GLeEAR2ycESfR\n9ww88YvYcHhCskW6UBSimkWHqislPENRqUiDRMl8brXJWdWr84ye1qHq/R8E\nZ5d95Kvk1vHz2T/6ZmhYMNWf9phnWEWySAePyrjg1MhVaS53MmSiYCUe3WCj\n/42oI3QNTvyeFbGg2jdVY885W9US6Z3xbgJpxnO4FQPo09YeKefx+6kTeGt6\nSgm+hUgYshWDHP9WLVA4RCYoWHNYikZfTw7Z4iRMkxbyx1aH4wcU5vAlXgzp\nwLDBLzkpg46WhFqK8/Fy6Bp5RdwrdqaZ3LKbj9Z6bm1/EofHM8eqgZUYUTMc\nDLxWD0A7+i5l7r0Ituftsdkp8c2EBSM+4WezFmL3vOFtbzRLMmkdxGSg8Hid\nYrnc\r\n=i56k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.2.2","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c8a8e12-1597044976405_1597045020653_0.2934933295940856","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9a115ff-1597059582264":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9a115ff-1597059582264","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9a115ff-1597059582264","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b6aede605e8ed3e9e59592a1d9c8f3b7e30e2755","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9a115ff-1597059582264.tgz","fileCount":7,"integrity":"sha512-wij1VlxcqNjaDwrJAPhilIlHfd7qceZ/ve+9SFa7wCisIkK819wLUMNg7uQSJC4kIACDVZMSsxwW+RxvEcE7sw==","signatures":[{"sig":"MEUCIE+3kfm9AuQPo0llqjBV9sigphTMVl2Fxgvp1LQ5L3gEAiEArRxlQ0sCcP6aIItTeNW8vwxvGHX0zlCmrHrJVWU/CwU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMTIqCRA9TVsSAnZWagAAGIYP/1z2DUeOL0HuEiMc0bET\no8ROiU0Fm2+jcMKLHQkZT3wNcRcGWj5eVsb8bEE1NszGIgYiVCRcU2HWd0r3\nJqyni1XZ4XitVK819axb12IojYL2Q2sGa7CuE1b4vcPbGRS1HTBGyw8ZyYHb\nBf86alv8oVoxzwOmAYK+FLCTQe+cuJxwdxckAq8GNwfS9U155r660na3MtpR\n4bsRKCunjWkZZVbks8TIeSm0CLjSB+BkEpkcruRG4tgGhPFmeTfh8AG7VQzp\nomduROAY46K6OvWcBEmy8wgAQ1xVWBVHYozlPz4ouXUR8AphxE3AHtwli0Hy\nNN2+nD1PbimirIT8PQ71IJWDdmlelBchbcawcCMXuqJCTOnE/S+jw8iDqcTy\nNM2DwILYtAL4yZLo+aINhMS4c7J85pK9ppIrBOSaneA7PeLZ6KwkcDXPkr4+\nr2ocMJrBVRXCg54cRpvh2eUpLZCtTe5YaYNXv6mXwCh+MJdzyFhTR3xjeSVZ\naPgaaQXzfRfja69UkehFr6oTp/E0Jyd8YNgPnhrHwkO5x52jILQU0VX/d2gD\n3IiRdAMjRHRVBfh8iYsJN1d8lPtRcT7PUJRoVz7qPtszyAJuxc6zrQ04QSmA\nlnT515VK62eGYTQmP72myQ0FTjcgTG1V46Cbro0fKuoxaQT7ot7PvNDrIsOf\nmeUj\r\n=z2VW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.3.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9a115ff-1597059582264_1597059625942_0.676435937219714","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9a115ff-1597059582601":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9a115ff-1597059582601","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9a115ff-1597059582601","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4a84bba3227df43632c71bf808a1acac0da2644f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9a115ff-1597059582601.tgz","fileCount":7,"integrity":"sha512-OG6kCn/w5GcZGXRAObWW7PoFChpF/Thf98yLgUnNAElIhOII3KU8f+k08xztWhUXfBne8+ZbyrFmfkhHCr7eAQ==","signatures":[{"sig":"MEQCIClTmVuLfoYs0n9KoLU6nkCYcX8MRbMXSyIP3H6Pzb48AiBpbrtqeq7HJmooy8hBjWBshQ9Qkj5wssuZDWN+Wv1oag==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMTIzCRA9TVsSAnZWagAA8csQAIyARFMxJPHwOJBNEw87\n9mGkdY6w8iO+R4TBb/kuyFxSOd2nvv9AEMhj7gGneh8WZegSY9QGR4Bf+766\noPfng1FN136ltQq7sAsFIE61ooR1C2QOBDEQv2B3CR8uz9xuumwv1KUP/+3P\nbVUhYcELUzngdOZat5ELnGgIAyU6R4WEZYyK8Zey0obkElIUNKX2QCgOts21\n5E/V2792dCxb/NQ93GtikcaJQn8c9BFbaYDqcy/RHydaAwNGNk15NKxZuTLa\nrC/cVi66C3vCG/jvnvVq6IDAL4YQRPcs5xHJE9JnVeX/j/wMNP2ce0JPYwnQ\nWkNGNyLme7wApneiYkO3PUxoseOKz1pYb1VRwcgC2s/ebu1QeiHGtitwnfk7\nBammXkWgnnal3CMMnQMaokaQTUTxGWtTPIAyggikAtEXZA+lMJH6A74zuyWT\nC8eCwPnb4HCENzL+t5cdLt0xdWDvyMwgHR5Z8r211gS6OoMs0BUivq2M6N22\n5G6OOA/Fe5rLq1VGJUqkL12sbZSfR+KbURpDo+cLWbYyRC8HX8Sts3HrCPTC\nDKyUtc3o/zcfk9cGUdgHbi4TKeviLqmTHqzRTZ9e7kTfyWKjOO+trefl8XUr\nq+1c27q5iuTX8OO7qU1isaWlGU++aKubVDTptgtQsFnhMOvi5pD5QZZFakCI\nSvj9\r\n=Cv/r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.3.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.1.4","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9a115ff-1597059582601_1597059634978_0.21646572230751016","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e5008af-1597142542661":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e5008af-1597142542661","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e5008af-1597142542661","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b685fda528990b1f21b8d14eb900b38273a0f6e3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e5008af-1597142542661.tgz","fileCount":7,"integrity":"sha512-vQvJBAtlAokBz1RL0pkisiXYru2bYlRJlc69+LHmQrLu5tZFJHrLTHmf5kz9xW9FzAH5/RabwN6d+jJb+/AVGQ==","signatures":[{"sig":"MEUCIC4PGxMTj6l6VDerLZRFV/07VI4RdOzo4OgCwRuaOpFPAiEA/cRAHxhxTLuOtskmhgc3JmGOB2VabDSy2r+3u2bsZFI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMnY4CRA9TVsSAnZWagAAgNMP/2YpUb29nWfFJS7LI4Xb\nLzjDfPXuTt/1TtiTBxYXzuDtnB7d4FcULfcFUxrf8Er7f8IKa5NTyBXeD6b5\nF9nouB0hXb/QR1WoaVJIrnIsZpgUBdb//hQOZrlF6JXwebMyFNjtD76CBPXz\n0fdcD5sfYGNNspPAIFL8n95qJPm5lg7UTAxPduksCwFD0vLNk1tcMb6iNp3f\nMjACzbwXW/2L4dbmxle4/4j+Jr8FPXhtrgs9KrLCfh6i/PCUIe6HOzcQU0VL\n7hdC0NKznN3ulz5hoGb7Pc9ZVuJ4V0EeVFxG051JrOhsr9IP6B/eLxFpbx59\naRezvNLLTJbokBZWX1c0vDfckpW9RgCJRiJrEcTuvSYioz+Yz0PObPxN9l6f\nl/ueZ6FD88uRR/trqrSvHsJu/E1UAuyqQo7jc5sQNnFu6bmddhpHji561I8B\nzR384khQC9JjWI741nQ8nxsAc3qtQ7C4m3dcNzxIUePQ8FrCmG98u8dk665g\nCITkFwEaYaB9rA7Lw6R2H8YNaIPBrK4DfX/JlfKp11v3dXtvPPk6h350YARz\nieLJUBbdAxXJDPEW4DJfUUIek8hOjJon9l6Am3dNyfk/5EEvIsaF8x32O8sS\nnOu59b9ATrvugOA025aQdtWixPsox9w/zagJLQJC4NxFMzBwNVPh8lfOMQ0X\nd4s5\r\n=AHQ4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.3.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e5008af-1597142542661_1597142584299_0.6816488072775813","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e5008af-1597142548118":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e5008af-1597142548118","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e5008af-1597142548118","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8897845359e994a78362ce352f066441455fdbb0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e5008af-1597142548118.tgz","fileCount":7,"integrity":"sha512-T+D62plgXAFmVPlemaoM8BaIT70o+KAroyNDBfZEwrzrsqJeKPBZkW/xoDStBqHwVDNhSHKsnwwJ9TqIgE9zbQ==","signatures":[{"sig":"MEQCIHZQWM1ZpuHpfrowySnizPYsbbfKFfOZclN68corLZPCAiBZ5kVKrdSLatVbvlsPY6EcMiJ0k97s5TvEN6V/U1gxyw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMnY/CRA9TVsSAnZWagAAmHMQAIW6oyPSvmsHwDtIaUvM\nVfGvihH0ThzZjzVFd+YtLxen4xDJuw0vQFdhlRS4Z6FDz8lY7zAkw2huWNR4\nhuJtQCjXrdgbo96G0mMANGpYwRkEnrlRDAN+MqLHXBTdWLQCRLrLssfIlSKQ\nJxDMZcy2pXNGG50XZQJqLsiPrTqpbv36Xpq8I/Rzffz0rmybTEpH/yaWERlw\nbnHoqiIju9PGMcxrDc7ZE1TI8HMTI1M7EvwZI/cwnqOZJEGskgqwhCil/uuU\ng8HN2U92WVoxC3g6V/80+xsHWHHDAif5F5ptv6jfeAQjKUdrNmjDsjw5fmQy\ntopdgaAsSYqJ+JlhnK6jYHF+0VB5aiitRhhFw4Gx1GA833v/pgVYq/TDLzLX\naor3WDd8+yjCxszyZqQO9qAUG1N1cuAgaaIfWt1fjK9uupldIGs8pTyS32ci\nAjysdW9E2H4u4ZZMKtuuAwzQBIuZbydaz6k2zsDFjT14t1Cns7mnWCTPs/lu\nRN5pQp/4dSnr3D+t4vxQ1sWCRvJuKeQZt3RWJtg1fPWQJNMJ/s7+X5KMpNYu\nUjKu4Q1c1FlbeF/MUyXyB/UJ95c62uaZMpcBaopqivyygTY3rPMsfWfxBOMz\n+/R+34okGcycIdtfHUaYGvvQIZ6eA76hfdCy9XTBDqxtZiDwkpFZQ+f0yAo6\nNYYz\r\n=whAy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.3.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e5008af-1597142548118_1597142591173_0.8857356667164098","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3ea22b7-1597266328879":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3ea22b7-1597266328879","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3ea22b7-1597266328879","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c828372f7955acbc341414d2a1907ad035a985ba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3ea22b7-1597266328879.tgz","fileCount":7,"integrity":"sha512-I55h5YeCYFRzI8DdbbKT8/9kGfaaRtsjccudvqA3xuOj2IY76MnrzKuCuMY6x71NR158Ob6+FsgN4GlkEmsCcw==","signatures":[{"sig":"MEQCICojc7l8XuI0GpErt9JXaR2U72gOI2DzHT8Y4dUArwOjAiBDnS5e14UxuV3J6G/TxgRyEgCxoJxp4SOJ7ADwACFgsQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNFnICRA9TVsSAnZWagAAxQsP/0IQZgDDS4rYQTuZxmgt\nhK3OZEgTw6Vau6joRNsh8PJ7Db/nFE7RY6xMw7BxdYgWqJVFITSu07h1H53o\nG5o5VlUFLrdrRMtrg0fCDuSGfa6WnjIPOSirsIk3PjX8w+vjNTvryc56PEYE\nBZ8TxpJ/bMOGX2mOUO/nJ1LoMqd8RSIAJtFbbVd6kO56PfhBL4Gi/chelRld\n441FPiHZEVegnZpuN750NhYWAnjEPFuWKhiwDyXJALk+VPgGHCmy0TyP17rw\ncwPrFTW8X7drkDJ0tVJ/81jGiXDd7GvnAvd1++St+baugiaKuNiYuni9oDqe\nsJBOexxXxL7crdfGXS+DWfVGOIc68PmbiTN2qfHAyIm1wMXwWXXm1DqRbmNX\nl8cA0Ag74qiznVriATWQstv5z8aSzklNVb0Tai2Z4OR/4b2+5nWomFBczxhQ\nS20Fo47DmfApt8JKmqKbUC8Y86BEmKDWLXw+XBzjbRN+6n0OSsNwYZAXBwfo\nRdm3Vq4RY4fY2vIIaen5mfRUAs1gZah75Ly5Bcwnpx35smVZgFSU/VMi+skM\nc17+MblFDcDqH1+HcGkZs+YuUR0XFcv137NOaqOEueBk5KGNoV3w5C3EHPsh\nx4C7EVT/HC35BRaWLAk4J870if22zT767NfJIHW9ypAY1/nE0kP2bDH9oHk1\nfiou\r\n=OHBg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3ea22b7-1597266328879_1597266375504_0.7620769578164461","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3ea22b7-1597266324713":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3ea22b7-1597266324713","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3ea22b7-1597266324713","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1fcf4e9d14829850ee86a12ad6e8b6a3f6da298f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3ea22b7-1597266324713.tgz","fileCount":7,"integrity":"sha512-gAYppyHQ5LyiMpmh1jDlkx5PV5bfdz1SoqG6CQz8JmvqomYLZO5tmy2GGOOrCNWo+GxUMgfV8buE+gez3nRWnQ==","signatures":[{"sig":"MEUCIQC86zpov3k9yDeRrmHRM1n62vpBUIY3h6ml4pC7Qdaw9AIgZj8Yft+B3xdPBL3XvXD037Fx2vxDlEzLZ9QQOJiWnSE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNFnOCRA9TVsSAnZWagAAYNQP/jrklBAAu1WPSEp0ffo/\nuyDsFX5b9XZRzyuqn4Ajd1CcF1zj9Lw04f+seLA6XYoFCBzWnD+kqznlfKwF\nXye8bLZr8ONU6pRFXqWJq2Vt8dJunebxAmJ7ikB+unJ6CEgiaoB9Az3pkB0b\n956vdlY3cLqh8/e2CDBRiSVPcbyyNe1DuIEBUYaYqvqgQFgJSbaAyiEgWvRf\nNkXjliYWijqE7lqsBctiJACGFwWR3BldVe25LN+w6LM0Sr6Ru/ehIBp08AHs\nH+zp+9VHQDhepBKPk+EzSxkmHuop1ddTRRI2uTGPdfwZe/TwoZ6HG7tJD81q\nDXVnCOjhCpUpnJcfgUAs1GyLUng4xQQjHUAP1IfXtGIlUkjVAMH9w3IYLVg0\nRRPGKEekfro336QquwVGLr0V8tZIbFOY3q66Km7R6smn76n85ldj2ZePbHnz\nmQTrA6yOTGLSDOoIP8H4FsuFxOSjclg9776GaNfSwhpCJaLe2Nxay2P6fasn\n07/cBJvSUYeDYaXE6SOyRPuU7CWQn6euU/VZRjrPC2Chfm+pzz2niWdIflMG\ns+cOOYkJMvzSqoDO+XJlIcXf4jTT3nMYzu1sIW7gYT5ACXqelFyWmKrEYkuy\n/adRk76LrmesRuFpvMIoT8FjOgxgCm265ayDPsnohS0TT23qvt3b/M2CJsAi\ng3nq\r\n=g3ho\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3ea22b7-1597266324713_1597266381601_0.42741487459669036","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-52bd956-1597326379200":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-52bd956-1597326379200","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-52bd956-1597326379200","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"26f8998f2857e32fadec85e1b214a083fd95e487","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-52bd956-1597326379200.tgz","fileCount":7,"integrity":"sha512-f9/jjzZFZU/q6lragFEQmnMFvIBEzvKn0P6IGQEpOaBiLGPvQ7JKI6SFc+iiekMwJ1KOQRMNFGnJbOdyq16usw==","signatures":[{"sig":"MEQCIFHqsfWCwD/PjuidTh9wZ4eIiaeFiht8eyOvNYTg1EV5AiAXxXHU5Zcns7vFYihhQZe3tEEvxN6Z/fxEs0EZd2/Jdw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNURVCRA9TVsSAnZWagAARMUP/1teK1Q7Skkl7iy4bAvd\nQsGlVHRTLTSKUMXR5LP0gUfjVmBA7i3xp85SSVn+eeHy3jKUgn+VjVkGZHvK\nXxqQQcateBZ9TxKa16hUoF4IfI9fPr5KkimJJlkgGvnCstKIr91RcJYmSkzh\nJMMnI23pLzDketd+T/KqzG/SQ3rL6yJOUbj/CdAN/W8AhFamL30Pg5eOe4zJ\n570Vz6z3AASX7FnfeRAux2Q3UxhrShREPfdjTF0S0G+ArjbkgvP3vsvbTMUo\nDPx7RDAtRTDLJUdYZSw6/g5vHDpCfJRlAz/AtLHXBePwNynfgXWAaO+XqlFg\nJNGzDMKY8/+gOzdD76WYqEdwYbKzvzjBnuV2y0vPalsVp1xrBLdPVwET/g5i\nKnaARGfQH1gPFMxsHqL2I9qcegM7IZ4eA6uB5pbN7RmGtLEj4heLbtxKw/ar\n8BsjSa+/0tWfv3wjDYwBpCt85bu0xg8oZlgEl4csX1dUsmO5OuokVHxRszWE\nSJOH+QpmOnC9oa/KXho36UKTbm1IKkF/Yjct1lq2bmNTrf/rFhbNGTnSTUl2\nimFDY2X2vpShTEGmutzYInU6Il5WOys/SR7jkcyN5iqenzhIOcmTuhkn5PLi\naNCpXYf+unQnf/tl+3OJQNdaD4Yav60xwoT5KQ8PxNPV7QkcAiWRas2BXi+9\n4qpu\r\n=NzMV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-52bd956-1597326379200_1597326420793_0.50721030972119","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-52bd956-1597326377494":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-52bd956-1597326377494","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-52bd956-1597326377494","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5a0d6af269ea32a607599979200d2aec27abe0d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-52bd956-1597326377494.tgz","fileCount":7,"integrity":"sha512-rTdaSPt5NPS/R5j3OFj/eLpqhNZhOUL3lswPO3lvfmfNj/YlkImacQ4Xzv5xiUvoWbbwVZvUdswwY/TYHrgUIw==","signatures":[{"sig":"MEYCIQCzK+H7oem1tE9RaNwmJXqKh8Gf+2I5BhgyjjCRIrVfegIhAJJgfJUwE5inTtrNleVFQ7GLCWHL4zosbzzx6/5eCMTr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNURgCRA9TVsSAnZWagAAKX8P/1zjjPjHPgb1NMhxDI7b\ng+B6kAZG+Rs1l1iMJvCx7JPbN/BsY37jHkI/RV3uCinqEqqHH31UEe+efz4O\nLvLkymvL3MKa21mDFS4JEEJedmWbAV9K6prMTxyGmvXUxN+d1wIs8MHNtcaZ\nkMYgFLho88KxYCQmoFten54unPbSbuTMK1xkhArM1upN3lGGij2pPNZQ1Wnp\nT/JrddWwW0ePeRW+bTZW3aj/xe2sElHz3HgqKayk7wDoB5wW+i86zuop+j4m\nr4PMcfXnoXFQd85QDn60geTOirr9ZxgDd6rzlgHHU+eOCJUeinlKAkjeqX6q\n9H3vEEI214I4sn2B1tvETF7HM0VU/i/lpYU2kXQSX9W3DCyri92z3mCqkfnH\nIEkzlwPX5hAfftjX7wyQnmbKE6eeU2JtMbbeNaUlkmd9ChMDAkbwzTO/UQcO\nwqw7M8og/voHm29/QC2Bb7QcKL9VYbnh5e83Xf8YbhwsQf4rMbyC0skwp6ss\nsmp7ey7JNvG94mPS/p3uNDpQqs2WCDMTezPv3PJvxqqqQWcGg1ri2NAeC/uq\n0vb11XtSm9H/pqoo/+ocIRyGKdKfpZ71lXQkNPYk8oXiA/7Au4Y9MIBaHHXB\n4y8hharm58uDEyhNZviVZ/wvWYI/HEKX6YQDQkcBu7+ydPMV5dzIIZMOUG8a\nBa55\r\n=Fsv7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.23.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-52bd956-1597326377494_1597326430883_0.0655373609872063","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-90db262-1597348988111":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-90db262-1597348988111","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-90db262-1597348988111","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3432839cd0a9c021e65cdabd21d4ba134f6d1964","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-90db262-1597348988111.tgz","fileCount":7,"integrity":"sha512-BKjIP3ebUUAvDFN7XuWBMY/Lhuo/BHp3nQqTR7j9udD+G7hmn4I7lPwBo78W1+YCM0OxKm4NH10w4f1DeS//5Q==","signatures":[{"sig":"MEYCIQDADOzuQt1lC8fZdB/NcVz9ELPK7jX32HJI/myIkN8o+gIhAPxAi/q47owLSNVpTuj/aqaVtNBfl3wgcQGnYFU4OHdU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNZyrCRA9TVsSAnZWagAARxUP/3iWuz5/RFHxPqt2aeqq\n+wKtRAAuT8hWl9oXDNWQLBmZNTYhsKinKdz1AB14cjmLFDuK6RUV9c8cYuUV\nwrB3ysa6dflV1im9fDzSsAiihUhkccrvWeTmwUZDQEuAaJlv24KfzpbPtgkx\nLboEdLmv3/bm8ql+/XCiWB81bZ6Y48VvyyCiAQcJ8OL2RBlVYNjPpK83WmD8\nSL0VVGK75BT0P/pJJcn7pE1y45fplkla4KsmGVKGG8GStntkphvzNxC4tF3h\ntHBeVPrmpK49XXJmJ99jI8jZwo0C8h7XgSaVhdUH2hJZKYR4qv+/S4o5BUgP\nybIdndIdg21hDikRGNvBlUGpox8Qw1yVOQh3mhIBuJJTXES8RbMm7HCJ7nZV\nAsfaoDj7rATXguGyFOdFBCT+kNcmBUJFWAmixekn6iVM14ewpcPQMINBVczI\njv5cl2uvLGPyTfQc+5fR5K9IGN7dV0a8dNTd/VMp3TYYykmajCz0yAi66BKW\nnxx5ANBJ/Jw70Bez66Ug/O5/AN1VuRIlv/arDdSRQ5+Uq626lsHML018+eY1\nqtyAm7X+ho/+Xz2BMQoAGJwpN7HeY7loBpyXT1CH4/eTdifdYA20WtgeF8qX\nQdbNbFM8QG+hD1SHW5IXFVxeoWFLUw3JFP53pKXFpKEbgTQaRU+idHmTI9Pb\neP2V\r\n=3R2M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.24.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-90db262-1597348988111_1597349035213_0.5089516906922753","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-90db262-1597348990029":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-90db262-1597348990029","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-90db262-1597348990029","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"64819a23806af66ea26b438dba168bafacdad771","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-90db262-1597348990029.tgz","fileCount":7,"integrity":"sha512-99bP02/HPE+rOe4g97+uLZW78lltRRA00EuywkQNdRiKrTVTxy/lDry0HUI7cD7RgjKGfQ8zUCsd77T4s4sC/g==","signatures":[{"sig":"MEYCIQDrUwi660+GzZDU63UnHo7X1LkGqqk2wEJ9yqcXU/whygIhANqOY5eIpXydKphWheL2YWjD8h31ZNqxlk6w5v7v3ZvW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNZzACRA9TVsSAnZWagAAfd0QAJqhWzCP2msdQewfRhau\nivjTUkWlk3/8eQ72GMi3qVi7qS7G2B8TAB913z2dtE+b+FbB+MUPB5d8X66z\n9sYhUgIX9vnaO63gdqyIKhBfWA1mLimEs5KgDXh1RTz0aUDr2bsygWhtEOMW\ndOyE0KecN84pr6lhtLnI/p9oyjmAoAwQeaXcvGaJ0n9PczeptmNOte+qZF38\n+gt8xHmaBxy3d5ehIbOo0+9/eXj3I7eVtxf5CI55xeghD6odZ/4FSQzqmcs6\nZdp/iQZEaGrir/VA7nHxSgcP2CwOyFbk2xlXHrYycOKAsgzVgf64RrTNljRk\nVElTDx6W3SxW2pqcwmLTYaOnjH3JzF8gYFR+41Vskssueh31v/P1u5oyqyQO\n2ViC/JDnDx3d4hzJrYWRIjffB/In4hMd42HYiZ7xNNHANnDxkx/tmW7ZFM8l\nq63gn4sOvjDlJlet/MpFbyE/9Eo6LV3BP74jIk2ac5cSqu8y/klvJge0yD6R\nAzsCfsBrdG76a8augKlq9Iq7f4kig6eXlfWo8br76OzUfPd7jhuWprbmGPIN\n5f71KPpeeJ9b3lg+UpHEkuLX1bsMRrSzzJlDHA6sq1S/g/Vww1EowISeobTc\nw3uMeoy5By0wr39tVc4Q5bDTLoQmDVOZB4CfwWC5vCNWRi3ewdSxw2VBQP06\nFOgQ\r\n=8fzC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.24.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-90db262-1597348990029_1597349055658_0.24446952530629096","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-20c3df1-1597383020273":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-20c3df1-1597383020273","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-20c3df1-1597383020273","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"675254a625c46163e47a4481f75e5ff9910dd8b1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-20c3df1-1597383020273.tgz","fileCount":7,"integrity":"sha512-6IWWN8DOvkyrvbijpE8we/7EJffn2BC3QqISNbLqRNpy8wekRMNhKCKd5hn0v4k+FYbjZHXcdN3iBzs1Mrc7Vw==","signatures":[{"sig":"MEUCICZKOQMtnSGUjJ6eo7UdUaF+JK1h6x7Wb/8wcMdhniyHAiEAn5Blaq48ehz+dM7Do+yl8/l8CzSlKsyKZvw4DvGgzmo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNiGbCRA9TVsSAnZWagAA03cP/RlQl97u/D1uSSVz7YlQ\n8R5s7594Oo7BAxJiS1aa8OmtIfdzFVVXwjDDDfa3/TCrcMn6vj1ZLXQFDtI6\nzG6N3TlMzl/AnOK9mPtZ9FeVM14P6IyVOEAhHD3kTEku1iP+kKLpCM2Ni4Aq\niMvgcQrJY1965UryXdVBIWeg4kOOMCoFNBqO9WCYIboTMuMqb9YKkcJiEQkc\nNa0DPRiBrURSEAxSSd1uI1xVWmOIahRUecXaAJh+e98ZIeeUgH2D8jzKfjns\nU3eaG/xNHhFmRly1bP4wAStLzAZWvDxszq4E+95PdtRanFsWA60hNfMCi0m9\nE6R5eDyncsdkamtotNIFlzUsE4PzV3VwfkhCPP+ekfOPxs3STmNJJpdOKQRS\nImTfnHBsiNCUIuoZ7kTvtKK3q1KjUccbTZib3x3BeIZKLIFEpP1gNPBSGy2g\nXkCDzDHVbNPbzZEgsNCPKwDfk4A9cd7Gt7ZIVLDapDoLGD+yjyA4nQ9Ep6ag\nbSkUzIISuA3uM5k0nYq3EZSVZUVvAxWh34X+UTcQYXAI7iCmjn9qH6z3+RhD\nn/onbpXFfY1z+5xLhz4RU+JOSLu61fhwB2ndg7HAPqaK+boeZhXX3jMG88OL\nTxFp0dkdFlm8vR6uRiGDt8CmvhdYkgMjzc1rPnwkFYbnnIulh6Kc1VhTQ31O\nV3Xu\r\n=GvOx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-20c3df1-1597383020273_1597383066565_0.2249426734052331","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-20c3df1-1597383024073":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-20c3df1-1597383024073","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-20c3df1-1597383024073","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bb4156007cfda35ba8deaf5065ab5dbbae30f29b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-20c3df1-1597383024073.tgz","fileCount":7,"integrity":"sha512-lFa6SJhSnQYDNOVhUvAP/Z68vgJDc9UmQ5kzkK3oqfLy/NE3Ipz49unLrp8n3lifm8n5tPiMnlDKYQbO1OUkCQ==","signatures":[{"sig":"MEYCIQDPle8eFH1d+FZ7FEvGpxMTG5LJxixb0eA8mHEvgDjVYwIhAM/v0ujb73/62xEf0s+ZDLPTcBgp3ALoa3uWS/NTMo6r","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNiGqCRA9TVsSAnZWagAAc3gP/josAGFUMVxm/CiT3TgX\na4QOTJ19QTzUKJZhM4DrCo2tJrHH5fxR62LPCybv3a0/LE4pAwZTmrFQztRW\nUODzMF2TzoLG234KOKRVZinPeqIMcnzJwI6pc/PKvLKwbuy64XNEfPc1pXnZ\nZ7RgvG45GQgcWAiJk5vA5oHRSMd6/NKVqRLb9k08hPBG2qH5e4Ouv6m3Qu66\nCHuEUGCBkQsl1o5i+eZnnI9xs37Im5sro9v47qjdp9FwL6OZwgMBJDqYyo+f\nV8X/QSWHD9JTJmSpRQ1ogLUS6H9gC5toFLuNO/4G4ZQ//bXmQ+PTUBrWqx0C\nvJ2x3rYcpzCnpALfme/LikxMVor+JpX6eo0n+dDMqLv8aQnSHOenTV50hTIC\nFq1LmMbh2U5jaxN0mLfjXCYKeCLT5IaptPczXf3TSttyPWfJrrgm+Urhy1Lc\nYSRZJP2XmCyOdc1eB1qNzfP+nKsu0agBfTLIQHtlpRE5KfkhyvnL1lWwMv2E\ntdcxWIdDTvgBdJr3imyibR8x/pK24nGQBVQAM9pF8q/7j+8monETcwLLQKN1\nPLHW19P9vKaiDTQI7n0K6tWCi6QixIA1h9njRImLc9cn6BI9+tA8GHvgx2DZ\nFp/rSGi5xKyOQOG74DLf4aMXLQORkZLxaLKwsf16cQulcoZV2XnrwjEzaXhX\n7qgw\r\n=qBP5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.6.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-20c3df1-1597383024073_1597383082075_0.22927553404328238","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c00a01c-1597440826470":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c00a01c-1597440826470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c00a01c-1597440826470","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0b6e80a1ae48ff3455915471192ce78f69f20f5f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c00a01c-1597440826470.tgz","fileCount":7,"integrity":"sha512-lu5ohABN8mJ6LMrONLo0kUXMuxMLzrMeidbRRmuCIghtJ7WXr6Wr0wvDKZsRAe8+jrqHmOiqB6Ad+glDicS/IQ==","signatures":[{"sig":"MEUCIBzc4pHNRUZ+uSgaLDLeEDLjslabcpzCP/mq9qpepJjMAiEAmU0frgRcYSvNfmnTYnkmvV0BqU4Nf9bJYQpS+o01ryU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNwOKCRA9TVsSAnZWagAAUswP/3BBK2Ewzk4ig8yhmDoF\nS0r2Ed/Ua7pKy/UVQkCkh6Z0H4bbO1Waj5aeRQY7VXcD07/aL/CD91RMjxv2\nQcH+9dP8/1rQbyG3obtf8ViHIFjEedx3ByQOzHi2dpGrQNvbGD657s8NXa7l\npAoX4XjvDcDazAozDvXwKThX0Fr2b33UDpkkeeiMcOSgY2zvcWWJTnuOcdWZ\n0H9h8WNGLUQQ9JoX+1qxOV5bcgod/9JeyzwJfCA1s1TJGfXyojtHwV/sgIc8\nd+iXiMUovcdn5fJ5KJ8uDLEyqGMu/xtY/C7ZU6HhNG+n8QzSnYjCdf4CI859\nRbpA/YiNs9pJGfh16R22guiFtu/YrZshdb/A+oDuZ9trnZLmq3ePYALbQXBu\nL8eWajc0NqL2IwInPe3yj5u1CYla3xi5Tg0z3M3DrHQvEicS2hJz027zPUeM\nDSUROSCcImqdTbRRYZzhUTpr5N8NrdBed1lqyOtUKHCckZcYerQ5L6edSJjk\nk6jWfFmG3krUraVcXjdm5F3KqlYibhgkG8MfHf4SxdQPVAuyg4050WnJl99E\n9YI0PcgBTWOig+Dr6ZDCUYNZ1IxYoZhcPaBaY+IagZ0kbnQJmaHy3IFMQeRY\nIWnS683yJtVAieWA9jhKEuzaZ6dckdEeKGzbj48ioKVhuZ6fLOksjXwwu6pm\nh3pq\r\n=BmUo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c00a01c-1597440826470_1597440906058_0.46854725887748727","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c00a01c-1597440824908":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c00a01c-1597440824908","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c00a01c-1597440824908","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2a9ffebce9176cf3ce328f8656a90df477c804eb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c00a01c-1597440824908.tgz","fileCount":7,"integrity":"sha512-K8bNvFcz/Mxk1Otj8DVCXyxrpFUsvdYuTaVXIb8CRlU6XrjFAeShw6QCGLFAhngSgyIhcYUJxVEgn9JGIY+8Nw==","signatures":[{"sig":"MEYCIQDJxbtlCY3/B9KXCci4Bo8xEGEW26Z/AQ7Fz6YKte+7rAIhANLQlN1GaWcCviXSm85iGtoUrocstTfuUPPWLLn+Vwj5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNwOZCRA9TVsSAnZWagAAmyIP/1wluNjvNzXITfcAPpEt\nqXNMMc9Nthg+aO8EK85cSw4VDyjZpt66nn+k3NOaks64OJssCV5DKgyQcMI/\nCa0rGyOjK3Ii/JSww4f6/gMDgZcAqll15kofeqsWOLTyFMruNi+j/41GgK7o\nm3mnXz7wyjZqSscuGvcsJbrRjZSGVA8RK4gdmxznrO6B2bPUyw5e34nV/b+Y\nKNtrg7wEVaKigxpxbNJJgiRDij10eJRZqDWJDL8K6cJbORyL/wtvlzFOVWAo\nBYtTGfdy2PcbEHP0mibQxr6jXSd8m5vIO1b4K3AloIjGWUa3dJJMonha8+Sc\ng3A5BCrQyYEEnRb1k3o7pOwWFpqQMOeyYFFa4bO6R+h+5Ccy0CSJjKtCdY+s\n61DYMGwjJtO6ofM3WuxB4nF4qo0rzdhnFIo19qchg5JWCacxYMk52wl3fB3D\ng5DVOW9LIFxoB0xizJNoKIbvSeeR1fbctMoTN0lSosnF5MApqMPhokaugeHn\nU8b/ooGBL3Ypv9lwPVEuhb4RxATu4xhiLqV4a+yC8cCyF9/JLxpGrxFilS7V\ni7DVa2tnVb8samPDr2Q8MJKApBT0xlGN1lWF1wA6ZUBm0g1B4js94EiDSF+W\nFCb63EwW67Nxq8Bnq4k2vuvWp0+jsU2vo4hNqaiUEZ89TtwPYqd6kWYG7m5M\nPgCX\r\n=KyEY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.9","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c00a01c-1597440824908_1597440920952_0.6088799414626029","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a400ff8-1597448982542":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a400ff8-1597448982542","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a400ff8-1597448982542","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a6406c4db13f5565603b9320e52b1197191a68c2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a400ff8-1597448982542.tgz","fileCount":7,"integrity":"sha512-F/KwQQ6NyuM1Ruey3G4DKdKzzirz1DBx7KxMkyvSgbtpkKAj0X8K1CElkN6aCwZkmJek7dExHuxS/+VDhj9EWA==","signatures":[{"sig":"MEQCIAike69uAwdQWzoOvlINyoW31dcGOBQr3tyTJi5G5xRDAiA2/jPRtH5a0QUf5bx6mztLjca+3Pol/Hrhs0AMzfNXYA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNyNFCRA9TVsSAnZWagAAQ7cP/jCXjUjXCJ+d7Mtgqatw\n2qq/8AIsEcpc1RHA6526ZA+CgeW4gW7deRaNifeT7UhMS4CLEkFY3c1j5vq7\n6NU7QIox5+5nJCGxu1ZeQFLo1KTXJGjw9q4azLXsmXtkqE+XQR7denl3ssId\niLs5WBki1B5UfsS3tun7cDVOedNQ2CQKLA7VLC1CRJiMv/w/JcL/Wfm+tdqa\nbkXj7OJLeZ31QrmUJXg9tEwFnHIjZCCWPaHfwnvl2AZrPK5Hf3epQfkuYcvn\nfzyUC/1H/GBk2qK6a0T5GrgOiNK3RY0zu4fzBlcbUFo+n5SZZXAOLMXv6ShA\nR/0yMvp6Gl9KloG5lGMBDg8Sji0ngSwcjeoVY7/ffe9h/iV82lPFxQp8wkyi\nRyhybx72zd2Qx7aUEgCA1QSuqt2z8eHZj5rYqV9mAEY/hXIHh/Ag2VHTnkEu\nTY7ze9x7ghEhgSYi45QYMxIEqWvw/73rekaPNju+jd/TjTHayi4V7VzQ9PG7\nun5LZfswriYBAcaaCQLzkU8plAkzn6DoSCHlI6xjtDAFv6RaLyhFT/7vkzd/\nwab4yTiw0dpPBC7X1khv3pfeUATlAOW4Ipt2KtxjrZK6To7+J2+5YHd+xY9h\n0VRY6imo1t8GBWswtIfoSEndRrwq+zUNpfrvFIBUoOra5mKMDJqlxaKsj6Nr\nCh4X\r\n=IKgP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a400ff8-1597448982542_1597449028901_0.12216945959745518","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a400ff8-1597448982395":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a400ff8-1597448982395","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a400ff8-1597448982395","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cd367efb7ef6608522912643209ed834782e106e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a400ff8-1597448982395.tgz","fileCount":7,"integrity":"sha512-+Ok7Q/nmAaXiv7IO5I12BlLytpAfxXyWngi6RGLTluxWXU8JEj8F4pTo2Xy3JJX0VGtLZsgeDQMO58NwVSOkaw==","signatures":[{"sig":"MEYCIQDpoAWIV6eNBfhXX48ySvnkfHNSRz8yprzzov7G+dFrxwIhAM28ULT9kZFAF/ofXmuUKgDgVofrWP9uZWwlgRVPzPyv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNyNTCRA9TVsSAnZWagAAx+gP/AgwiBrKrbi+hog5GmEX\nKmL3k7usIPcNZRNLKPgYA9pfGsnLTlLrkfdLOpPDA9PuenIYk9mXy6lApaM9\nfkc8vVK2FYlpco3s9powMg87WKYGIc5L6nFzblgrHKxc6uSlrndmnHb9lAY6\n7BzjuL9LaPxY4D+d7HCFJs7djAhWjxeUxZKp/85VhUBbOkiGaes/mMPac4HR\nQ1TYf5vuKKvS2laO21I9UAr7OIJOVXE/m4nq7ehNnLOqS/o0Xi4QNgxmhvyZ\nPYma5fYIcmAiTR8G4Lr6mbytMF5hge38sqHdcgdesfQnvkJDBPMH9q26RUbR\nW7dHv5+zhpWDMju9sbg+KeA6t00iSapJEGqeVYPqtWiN+7+ErFWdlmP6yEVu\n2gbTlIe9zk3Wh1/r9cFb5krTVcP59Qopz0DQDkovptpshQG1lSiR7WZjHqS/\n8SIObb1mDnYBz/3XSE80Q6TObxwmDaxSGpYwEiuMNrBaV5SZcux/CP+hV8SY\nuE1tyay6VtxpsBF7azkIUbQ/a4BCRmzlmvZtG6664kQQeObf5u1yRpycySpI\nvcvPiPFHU9ytlub504A4eEN2Q8+AGt+ECYMlTaWw34I9vpUDmvJDz7p33wNK\n+N587ldqeDtT950Ka52Tt3yUGYc1RFja9bviO31n2On+n851gO5OhVoZ0EBH\nG7sH\r\n=3GWJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.25.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a400ff8-1597448982395_1597449042922_0.929753484103196","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e545cb2-1597467241547":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e545cb2-1597467241547","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e545cb2-1597467241547","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8bef9289c50d800a58c566f5a5e780e3c27338ee","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e545cb2-1597467241547.tgz","fileCount":7,"integrity":"sha512-MHe7fL3CgiuvQUnZVikpeCCPMxNC7YxkS0v+7pKJySBq8IauB2O0Yc3nUKiBP2crqbU87e9VGZQaSa2FVpM/9w==","signatures":[{"sig":"MEUCIQCRzCJIY9YiSam/zRQHv/Dpg24c5+cowbOaPDbXkrkQVAIgPa8jJeppfBqR6reyMKbQZcLdY4H8boPC/Y/w27L5oec=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfN2qZCRA9TVsSAnZWagAAJJoP/08DelRUK/pV9kQBst/q\nmaoLbYtLo41vlBoWkps2qoLNplFX6kp3/f+7G26MDXOw4KM+u5L8Wv9CpNp7\nfpH330XmFnHhtdHKnyf2511N83CnZgVSsqhG2CkST7YMtGoutRLTbSL1Mk8o\nYyA7icqTMd8EwifPF/pcyKAMbZTBqKAfdQ29Yjmx+084CKYdq9GPVm44uASS\n/HmfzvgXNN6UpovaGC8sPvVPsZ5CYbVathvixz+nvnZkl8ef2gT+MQsTw1J9\n9TIVtobuANYUmsWBDjm+og2irlu2Pv7u2AkLL2efC5gsS3kwlBNmBhpx1a7y\nI/dKmd5UQPvRSirCzqiidKxk1fQaAS6wflf12/kMkyxcEo5gQGIwscIhPfLG\nUcwxbiKTLGdHPgeqoXT38KawRGJYnQNYmV0HyHaiJJRBJqiPM+Az6M/J3WiL\n++NDXP/3wr0I7Stke1JZJoTG8dTRII+IiUfcna6p7+8es90kM0nljJOWxk8F\n9OkscI3LKPY61DTmq+L6WFun25SlkR8z+RM3mIeWoKGUYhOFGpkZdQhCPvX6\nViK4xrfVJAWE7mhsnseUv3OKaDVD3oxcsu4f+QEIioPpj/X2CJuWsbQ1m0HK\nLEOsmQpwB6mQ5aACH5PHx51bU+A46CLtfYrHdWeGLKc+XrSkfhloYRn3gzWx\nz8Q1\r\n=4D7e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e545cb2-1597467241547_1597467288661_0.36563369688207104","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e545cb2-1597467242331":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e545cb2-1597467242331","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e545cb2-1597467242331","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d9fab953915db0cadbf9d40def3f46dcc1e4dfb1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e545cb2-1597467242331.tgz","fileCount":7,"integrity":"sha512-Pvmj1gBLZCBrg/8xoU+ZjJ6bvPOPEL2KjNNMnGABVvYGvolmu3/4aqesVoSxMKGDmBRXsZEcuaUfKNKzKcevbA==","signatures":[{"sig":"MEYCIQDdtGTs+rA01gTulvabvgyfT5antZ8zHzG2UQpfD8Sx+gIhAMlcPh7u5fHlFpjHRNTDe6JU201n4m/wA1yHxtYJQfCE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfN2qnCRA9TVsSAnZWagAAPJsQAJK5lFAAt+ExT0fMxl6O\nbvlfjAB6upaTHmSjWPBvTATIGRqztAYhwxNPYTm+R0bm8mHvsMmPV9vzAo+c\nRuIpxlvPdRlBBhN0Qj0MSdWquT8DxkpEWyOCZkHuuoVAXRCRtW/C6Sfxl/vr\nxkcZ7hKK+Fs7ObVrXPWMy+HIL/pBSgBQVTWngzIQPFiztNJsPMASn74NFaJr\n9e5Ie3dQQrynWP6b3WqpmmQibN45M+R8kOUmAnHc9MIh6ohz0pMX1ydWLGSZ\n9Y/JWJb4sKocyglmFs5JWnAovHAqyiPSdRsljXVb4iGo+12gV0FCEELFAImZ\nGSO4ZgiVTW1DvoAaDlY4dRHKWLkc+Yz2xTu2dxEEYx5QJmnDnK/DIThHJCju\nPDMkGWz+pZRbKkh4TuPIvZxk8z9Bj10Zi1S23iFwfy4XsFaY6FQSmUZiqMkf\ng+HRgVobsiuJWm0cVHLKWs0NAQmwmxrbsddqiyO5RMyMJB2OoOCcWewu8ggE\ngFtC00krq3bfwC3znrmqWPxlYnvxRSC5CBXpq6/sxcSaDtINn3oMkBqk77LT\nzI3Vrd/R6ehXowp5DBhvD/Kn2LvyTBQ2fpbF0/yVmE1sSGI2jEhgtK2q3syf\nTa5O8S/TTP8hydNmPS4LzXk2yuQO+8GsqNCt8pqB1HSqwiNRu9z5WncyCpH3\nHjkd\r\n=J98s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.0","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e545cb2-1597467242331_1597467303148_0.03588918725071877","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ae0fe20-1597553513561":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ae0fe20-1597553513561","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ae0fe20-1597553513561","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d1b194035e96da4350ffacea78f18d3c599030e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ae0fe20-1597553513561.tgz","fileCount":7,"integrity":"sha512-GhmCuPs3pY6m6CvgmkonVmTDqWG5Cxdz+bzbR2sUv4iL7lRapdTCVr6mDBUxKQ4jwC7OYEoivJ/pg4XOvVLEgg==","signatures":[{"sig":"MEYCIQDtigjcJ0Ig0Eirw0ij++dlbilpk7LR7YjgB+TnCT1bxAIhAInJO2ij2c7k5eurOeMWd+i9x7GATXUAvbFAWeycPBoD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOLuUCRA9TVsSAnZWagAAq0gQAIcKGu+TN3TtHWWEyuxB\nimjKNeD/Mt8qUORjqbAO6H73sAgE6dWGBRDoElBKDy3OnwiaY77uOCbV8o/Z\n0Xf22ZV+i3fMtowVhpya1RIU8kOdsgha5qx8bVjj8rCrJt0PWKBkPGlSp++Y\n4O1oLkh5JK0WMHdYwxSN8cr20OVhnABCpUkOkS+oo9JwKh9W5Inu509S8bJ1\nR09shinC8glbvfWq+YW0JFLTVFsaq1/wB7bDshySOC7T3he1wTs3EvIseqvi\nj49c9q4aoWYyVajvMUSEw7yEJEMfJ+4ZH+I8eO3JXJTQk6EHimO/dEqvVXqL\n83nWHD5M8VY+/yZ/qCBs4IqoXowKMdTFu8ORMgd5lbHN4vSSo0zTcOOAwqWs\n/NUHhjZwFaPehy0sVoRgb5RrxsnkYqKKhGmW3bdI+07oE7lynf4v+zLaBnwl\noNYp4xDK2Sdu/z7CzKrvyPzjtwUME3wAtmjpKa28gQE1uqfkXt23Ivr4Pffw\nEdEQHGGHKVEFPFWPMsUe1uVsZp3ZXGzCIpr55Xxflo9U0ISFUTw4fS1IKlLV\nCz0T0lFMjoCdzJ6bsZEHRkYpPiQ/5arrxOTkUlEZjoSd1vEIOfLKrxsQvb+4\naKhAAr4hDlIs3KjSQCdY85CwdEFb2ASnush4De38VGco/7EXBQR6Mzj0qY1R\nFL/v\r\n=7RBA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ae0fe20-1597553513561_1597553555489_0.2448693611565731","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ae0fe20-1597553515893":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ae0fe20-1597553515893","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ae0fe20-1597553515893","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"271fff277ff9527bf9a9feb92e90a91e6af731e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ae0fe20-1597553515893.tgz","fileCount":7,"integrity":"sha512-nDqDFCmTurmyXTEc3a6b+eWu8RhrL/AfQU/soVi4+Xz2dUiTM142l/8shl2TRYpklxrSbqNd6bMndpXUPmMU8w==","signatures":[{"sig":"MEYCIQCzsayHUPWYR7RrIOQKE9iNunGee68Dtg4MR6ikQTLlJwIhAM2T1jRGtd8sPlEXp9JGMiKYm/rqxj/VEsqAhZIcFOI/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOLvlCRA9TVsSAnZWagAAsCsP/j27c6o7dmO5LBSIP2F0\nVkuKsgm3A3r4aXmEHHZ64/wWN4V6sZ9NqGz5X7M/89ZhL+EBbZRggk4fSIKM\n5LkxW/SdZu2bnatz9G4mhj8Eg7OTqSMdswCNGBd5mord8XrUXEV2pM9zSKiH\nw3XtpsrYKORkBhwuMkNrrVu9JXOQJgUWGmbVNtYRDyy61vo0nETz6y+Z744S\n+Ecsi0e6UwnP8Lw5dNKH+c1z4yIj6UPq/110bYmUydXrQPNBksrPwmrMWbPO\ntjbjoTOA6oDV4pJ+NeQo/bjo6NAiw5wAPwOejDxhU9hUwR29ml/Fv2FRembK\naJ3AbV1QWJzTyOcrC5jlCt9X4h3qt5vMXfuMblSTWZJxWEthLk4pSi3PqQ1f\nvRCXiKsQVW1wFfUTZj+JBtlfVo/mQtcLqofKrS9rzvCXIgrO5kWSIW1J9c2B\nXFrFX/joyoDH2ZgdEFR6LpG0z/JLSlvGLT8u3ephYhCs0fU3VoqhHMNIopqQ\nkOvlwfpunaU6RhYWuifpaAM7tLQQYtzaAdAnXSHyW/Apz6Mt8ZfErEZN113j\nKmJDhRLhoCSS3SO8ZXp9VLDhAItg1SucM37XxN5Y0e34iJ47ZWlz1XHJlBp1\nSFSkg4CuNtXq+Llj6vQV0LkfddL2lWJMm1UHvH9dYoEFIZKn9Kqhom0MHIXV\n/B7K\r\n=YK3x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.1","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ae0fe20-1597553515893_1597553637372_0.3725258469734234","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c1aa20e-1597556676637":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c1aa20e-1597556676637","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c1aa20e-1597556676637","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f7c417a11f96e8b70442f0fc3fd5d90f81e15ffc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c1aa20e-1597556676637.tgz","fileCount":7,"integrity":"sha512-UmndaWbfSpLEkdA16934slkGvcjcI7Egq6rK+KvOOdDEeO6jfwcqaNsnFGUf0eXBakeK+hGYD8YMMnL6zouajw==","signatures":[{"sig":"MEUCIQDf4VV4x7rKmzQ+ynpvlPRULGG6FxmneNLYa1MeWGOeFwIgNF18CInzDLE3U5YQ2+UKxHyhO/7SFDDOxFBwBuqdD0M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOMfuCRA9TVsSAnZWagAAB28P/iliWW3j1oElAi0jDSEt\nuk6mACtYBikc9NdQzQdI8DVBdKpZH3b1ZxT7OTOnLFob0uD25qG87ZnLwQzb\nOg9OezheHQRQllfS000LwE6YbHBIZXJGh/HHVbuIEyj9SI1rMMYbMcNtl83f\n65urMyeG3ALZSi7W5lfov4gkxpwnS4jwz1eVm0+ykj09S7x+OU9oLOzrjwwd\nrGf7lhGz8/JhJsgh7EEk9Gvew4wCaycUX1JM22HXOUmKq0yqFrcpvpXIq/ro\nKkAqEUcpvkI4JK8l8t1jtbQWXx0Up6/pkBbjhXqXAUpQo0TZL9jho4LV/1aW\nbLnAThf8On0nsF1T/2XsA3qe+WO3QAjSBdKy0RElod5D+WPIwfQKNzHl6rUa\ni4rxTiHQx7luzWcMsLoPqzT7WMnqsY1CTDVqxeOpoArqF9cH5SXfgSSfHeHP\n7ysGMru1XPc06g6lk4QWXJWVfVokNyq5vYtH8iwgiQBq11wHGs8umRAAw7zD\nEVrb4Gd8lK+ys0feKi+gdHtf/39M7WyTiAwJefyXpN3guYeGUZd+T32UCRAG\n3fy03IyPT6V6JpNOAAvo2aJLqZdXlIte2u64WReXCACi+VlrjjiI1qpzpPQ9\nWYg8Rin5mbJZTu7rcr08Q9fMRMt9PI0MigYgYQ+AzK1WRPqqRoQDS5b29H7m\nAB5/\r\n=Sajb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.2","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c1aa20e-1597556676637_1597556718125_0.051786299367500455","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c1aa20e-1597556679855":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c1aa20e-1597556679855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c1aa20e-1597556679855","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ed608cfd73675ed97746be68667423ab6166584f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c1aa20e-1597556679855.tgz","fileCount":7,"integrity":"sha512-Wx/nAMVBR+PMMdreqqdkciUOMNlJgUZyQv9w7VenBZOgI0+y597S8+XJsfBEU8pjCQ8mVnvizwDtcvgb6+6YBw==","signatures":[{"sig":"MEUCIQDZTJGVrCX3oWKbabvMw6Xr0n0kJ8FSrwmjS/gdCyfvOgIgLIeEl6uGG9CIuoEHJlxCvFixhORQ3BlmzFWPAXwcZVA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOMf4CRA9TVsSAnZWagAAILsP/3YDTggqclBkSBD2kHLB\nKFJKg25/itRptl9Cgw2ADBu4vDZ73ecgxHbvuK0qsW+hxUbyYBZn45L1lJ0N\n0kDgxfxAd5c+vGIxfjvE39jKZscz6D5PlDSo9mc1oK+MxGnXtXWSMWEodSRS\nOEkk8bSbjYySCaYBRqoVpV6AAKgBFv2IlnoHcNU7D9Fvnbyfvr5302yXr9JZ\nsi1P90tc4dgPrdc5IfGIqcehi31Rh6CZwNTiao5TZq2APDCWvzWvDxN14EC/\n8ESFwt9y33PXKuVYRge4R3f+zI+4XFA5xqK31DHEMpToQpflZyw2cI/Y+jmK\nM8qz9YtZGLRo+FngKyNtg/GRoIpkdzP4baT49mT/yUXx1bkrgnzglnufy5od\njOL8bbkbubbmBgC46mdpHx0Py+DaX1PS+RiV/qVp2C5mEhv9M4uqLKr3ZZja\nXbQPSxCohmjkLTmT/+9sNgewy9++ok5SztjnO1YjRE3D52HY2fx0YvXs6O9W\nNDShqyAJ+CnNZ8VLeI+TU769TepcaDVHQGemPMtOUBk9XHZy4dwaiRQha2LD\npBmmyq9M7RIwxLb2iass00MwwN0lkjeHhdAwfyLP9tpyTyKFG7YAYtBuXmRP\nXl50cylKfSIn7Ac7qj3ACXoyHgoiOByElygah6N65dKG/vwKFzcrOj/oQrOX\neSru\r\n=9Ffb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.2","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c1aa20e-1597556679855_1597556727636_0.7957617320057018","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-80b0cea-1597607674216":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-80b0cea-1597607674216","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-80b0cea-1597607674216","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"16631808f554b4dd3c53b6a013e7e2149401fa1d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-80b0cea-1597607674216.tgz","fileCount":7,"integrity":"sha512-8swuez95H3BdumYr/VEd6xuBYpoTgGukLwIfW/IIIYM+6KcImVCJD34iGitzM1jOjaDJgWEG3T2Rq4ZIWwu0oQ==","signatures":[{"sig":"MEQCICcn8rHEf9krodavfPieQ9oPWoUd7Smu1FyI03RUNdC6AiAKdpvG3eaG5hOxLZxz52IXDsTnb/pY1qkC90Tg12naZg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOY8yCRA9TVsSAnZWagAAxlMP/iEz+Yw4Oit2bvmLSYzm\ne7VI85tg8oVM/k+iHUN8gzSnVYtLrtlyin14SFG40PeTpx1jxXuXGMY6wyIc\nytfOmFWQ+Hra1cpMOJzDkZEmDjUvLpYRqHgvWWkJyG+jqmJrRsaaa52EOe5L\nM3MKqYPYturc7NN02Xs9jcWcMmgElFv8xXFQ65N7DfuKlUjSey3veGNrrCzw\n2+Ai7C/x4A2Oc1srRxQzOOk+TKi6EqNH9fJ4SLndQ/CxXAz0wRz937MlA6HC\nD32VsSWtE+oF4yxt7hE4UUO2ensrDXiAoHh8i0AJlP77Q3C9MJye3Aldp+YT\n2VRd0SfL/F3eO0ShGGNuKPOZ7Y2aUc6jsHvO+NaTySrSfBUprWX/Hf+vvsWC\nbnJafqWYiE/ki+pjz2ZcFtBUCUXbfw3CnEHzNHJH34BeHfgVKyzQ6Nb90hYI\nx/X8T/qNGMUTNnS5vL/uoEy1DH99SrweO0iSg68mbSv9SBdWrID4SuSRjAWi\nFcV0OiVEnNCFEWn54FPGCfyxhej39xre2U3Iu6RQMYsm6ig9siq4QgGdycix\n2N9fQ5ysWx/00k86wjBUJObdihKLnY6AWjuWQDrFwR1ldhihHSTwU10ffXQG\noC/lY/AK5l1dtgDxywYGHtG7TpNjXqHPnDxq9lf+eJvmFoFLluszv3q8higL\nf7Cf\r\n=XYj1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.3","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-80b0cea-1597607674216_1597607729959_0.7359914713612057","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f7f7483-1597607678531":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f7f7483-1597607678531","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f7f7483-1597607678531","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6b3ba6f1b591015992cde2ef4386025259c3f02f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f7f7483-1597607678531.tgz","fileCount":7,"integrity":"sha512-+40gd19CRBzE/65+ZGv8Uueo9FAlsmrTt3qKL8ey3qk1Tmuf7yTQvTaRUTicIeBacur02C5Sj5F9hmbXzumBpg==","signatures":[{"sig":"MEUCIEzQKjo4izdUq8rpLNsVSL5TaOAvmEp1RqsT4nnzziLbAiEA2g5eFGG7rWjlNnxeESwuPw9Hbz1VFxXhbV1q6QITBJ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOY88CRA9TVsSAnZWagAAtOsP/iTimS3X9Hg21h0YnxQ2\nMx5Tt+5WJzZS7CxSTwyX40ixo27Ov0kdKCp9xxHO+1vO/X9dW20trRVyK1QW\nXFcJnk/QX6OeBG5nX49IKjluyyMI/E4ip15Yg3RTvE4eBZLhQEjgu/ebxbbS\n8IpMIoPf1tdoByI3vG/lFejwn2CiMAPi6gAjdeCGPPlP2JFHLZpUgf47XLOI\n3XjCdDqZfvY1h8rDu4fLLzAnVu/SRXyChsjaKgKIzIbdZlpx+Ivix1T+6gNX\n+3if/IY3OZ9n1aN0AzAfSiIXG/wzZW02DvVVD0vi/0mTui/eZP70yCKMws45\nfoBx8n/8aloKKdIkhRpRmw+cyg0lOLvTds75qWd7nliJnYTjioLxr8MMrSXq\n6YHtFUlJoxkMJ80pOj+vrbh74K2/j2iis144+ssBDNemDrlErc1F48eTUi8t\nNrlIis9Aai+OIQLE9bZX2YSQvOUannJtNcRKTRVV057D4UONk/I0b2fqssDA\nUNuzMEwEFybtww3AOy3dm4Ar+1pqFqZVZbHFmE6diK2ji1iFD+Hai3Pj47wS\n/jiPDOmgNUqpVVzZ4G0Vz0wC/vVt0jFujOGwg4LfqPEAXOptI2sZHpg6mUCs\nKZGAyHLJAW/SDaRfvwjPBLo83aSqyVXqFpVVerYqatqu0eVEnMbVy5Vyek+g\npIFo\r\n=7aPV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.3","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f7f7483-1597607678531_1597607739607_0.03218896694239559","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e1ad6c7-1597617944168":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e1ad6c7-1597617944168","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e1ad6c7-1597617944168","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"baa8127d53a976d93866e5def0b73c5631da67a3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e1ad6c7-1597617944168.tgz","fileCount":7,"integrity":"sha512-e8U8IkYO4h1IxGX24ULwyZvKxD0mQ7H48CozkyC7rmM9sCve9hklAU4BpemZYyOGYv/iAxMX4MQMc2xZnUYLCw==","signatures":[{"sig":"MEUCIQDwlXq0qQGL/HpZo+4io0YD/huic8sU/+RfuiuXDdmjtAIgSB5PdZ1Ls60T+QSHQnuP2Qf+UrqX+Lf34XC7zK9u7p8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfObdBCRA9TVsSAnZWagAAzwYQAJ1TsHzGv2my39CqmLin\nOu35BWSwfB6rVPtKPGWG9S0lZ2huKTqWlL99WRA++eK0LEPWKO8wcd9pr7hH\n1wzHxIg7j7s6LzH9usOGR2iC5J6g5A8MDEFWYSJN4S+QRekEE5peBB7NRAkd\nyK4oxXWbufG79kGwCEy0BzPvzHQVuW0yULssyUUL5a5+JXTAx13FjDBI8mK2\nHL+7bHuCN0AHtkHp6ep8CFgKMBR8M/oQKh3sL3y6OQ9aw0mimkLzf9an/GZi\nIiMGOe6u77qYrBlpYeXD3Ax3oJaoQKEd8eIKBqItvVYByPNECjsHmwP3Qsa6\nk5Ao845uTPvjoFf3svbjTESY9s4kAjXExAoE2VwCrZK/TCfndambUGeDtIrX\nPo2RXTPQMIUxHAx0r88isp65R2rlNXbYMcO5HcTqweJGB2GE91nrr20XEqZ3\nzw3VRzMjQsJYrNDHSgrGQEaRFS+GF9NlX2b1633vWpzkgbRjFovQNMFMtmVd\ng2t/m52OFpV+L5tQSDUsHD3YfFDYbf06fiSw9tMo9tcNHgBo5TVL9/tY41Lv\niZpJkeIkO563grSMbPgsHd49qhUjTFAHTIQDkwsiENl7h5VS2aDa2mAszQTM\n/Yk/67J1cSAv1c+5np94oP57ZbIS7xNt4nE0t+CBUM2m1p9OxJPxH+OOBWL6\nx45g\r\n=BFRM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.3","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e1ad6c7-1597617944168_1597617985548_0.7167830345006894","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b5fa4cc-1597702483719":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b5fa4cc-1597702483719","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b5fa4cc-1597702483719","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1fb55a39f2113b60373154aab0f8c10404131b62","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b5fa4cc-1597702483719.tgz","fileCount":7,"integrity":"sha512-exds9lbdSqLaWe8unMOQVQ/XQYEir4C4+2Rz0ym+qKiBnyBj1cAsalRMAZ6/xWsKdBrySRfvuY7EAEpYCo9v8w==","signatures":[{"sig":"MEYCIQCBC4Yhn170gwquUYXPaC3Ia/27Q5bECGEVg8uAMDf3vQIhAKP2ys0vhb5+ONcxBJc+FOWdLJ4NUQL27mXcjzhR9RrR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOwF+CRA9TVsSAnZWagAA6EEP+QHg3ULxaAPqxX0wM9zv\nLWFNeMOJdAmDjLQHSe8GN9+7ONz8p7IjIwSHWQXJFu2k2HtYBb85FMCEka51\nWBVUfPJScPAqryQfkmxMZGSrQz4+TDGJozj+J9QpgGzC0RoSHGEZAvr3FbR1\nsPgHtNNXYnk1PUqUblvvBJcTi7uiBQVByZyglXxsd7aMvpxHstkC6cPlAhPp\nYOzWAPXzN33WY/ZmBLg2OSlGcVkIxkZuDEC135F+iBb50WAK7u7DymcS1Qmx\nSxRflkxWHjSpAz6j8YFK85XCpDl4KTOX9+T8SmcZCu2IWn72lAtI36uixWIU\n38crONglfLzW9XFQxS0GiOFS4esvQe7Nd+2Na3OXdmlW8k5VY3TP4H9cl21i\nSkd1LDFDXaKOrsoaScBkReIIXRhvDMiQEsSVXkEZFD36+YXoYw/Y1IOHsSy3\nDjz0MgFIZeantVGuhOaQm0i87i4vEQZX5PNKnAKZGhbFD/Oug+f0jkiMv8hC\nDCqUpdwuvGB7pYwPZFYuYbfMsPjeVEuU/2K9FCYglD5jtysyW7f9k54fBQ7O\n6TE4+5aWauN3AzCQ7BU9Vm5gJSzpicahD77xNJhISvED2WKQC2E5DMWTVcGn\n0xj8oPitZ2dMSfAEspQzfhM2igncR50+NGnzeNCnT71jnMwkdtTOpo1YynGz\nQ8ar\r\n=zHBP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.3","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b5fa4cc-1597702483719_1597702525991_0.8448093455321846","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-84c57a8-1597820670814":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-84c57a8-1597820670814","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-84c57a8-1597820670814","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5d0bf34f3868f10d6e2c98ada481f50c39322e35","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-84c57a8-1597820670814.tgz","fileCount":7,"integrity":"sha512-J7I/4oaKHUzu4vvlv8IvdaRr4VgePsa75ufKYlzsK3AHoTA+xYRYOxOKG4iZzx6v2gLRXT/AAn+DKKghGsW7TA==","signatures":[{"sig":"MEQCIFJ6gRa6NotyAhh73uRyMHvIu3+IWFMErl7QBjGLQcWqAiAFBAAPuVtcsIi9DAVjz9c8OG94CrvmgP9k05JYkC2Gyg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPM8uCRA9TVsSAnZWagAAh4IP/2qEYhJaGlM+WLjOq5xv\nJLAVm1wyD6Sz7iogduFf4Lso6iP444Ruy9W/MwHz52HP/aoJsYtv0TKm8PyI\nB6MUXyR6c9XcLGZocDeYS6vVuXacR8yxlEEAyWZ1v+lxB0JvQZR8OT/9NnCL\nfTUrmlvGnXQe79yYlZS4Yw6Faz5hYRKI7lbRAtdB14kH7Wq1BBQcTj3Z/ESu\nvZTN9BdLqTczfo2xwV6z6u3ZKTQmRPklAy8PgqWXGQ0n8PNDLr0Gx8/JSdkA\n0b2hWjvWKlfg315LweNj6Z7DMRp/vg+NLTXxZggaBB/Ir9TlQPgSRlHG+iec\nY6k6rPHH5hj4IB257lu1/UImPMC0k5jTo3JEM43scMbhfN60cIYy6Ervw+qG\nttl/o5V3EgYBFbPsAT51cFXccPCWux7otdIkAhpII+4W7vOty/t7XWYnf55M\nA62w92WlTrploXIpxnp2XfmuJyuGk4w3g5ywAODmCwKyF1UgClIEO7W3q33N\nNMj2mKc7PNTxxtS9hNVC99ONwjhta6NkWd2ctCs4NeqcDaJ564bXLWqAK6hv\nn+8KEw6sDw3HUEIyFmNJ1vuZ0I4FkC/JfABAO4dN07i7ii+VFv3fj90ujVuX\nvd79yMPHRPWCMhRwr+X6kPzjXzvRInKePdrnO5wTsa5cfaArCCQw36zclt7B\nixav\r\n=lfWE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.4","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-84c57a8-1597820670814_1597820718045_0.824478408317906","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-84c57a8-1597820666754":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-84c57a8-1597820666754","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-84c57a8-1597820666754","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1f73996aee45200d5fe045aeb809fe114b4e7d09","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-84c57a8-1597820666754.tgz","fileCount":7,"integrity":"sha512-tOQmhmZUkXHzNDLZruksYsSBAM2/b+1XyZYyE04UkOq6beN9+FdbBNYTmwcD13qURMD8pXS3gU1BSATxw/LTOA==","signatures":[{"sig":"MEYCIQDd314eiDR4W1WXAbduo8QUg0tokbuChfsp/YjKxoQ5IgIhAMDsWEWkim6gMv95idF4slhdZLKd+h3rM3SCrZMarLHz","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPM87CRA9TVsSAnZWagAANBgQAJJJQJ2Ck7TnkutJEnD8\nymNigHfquUSYNLVZ4oI6OXNsvDcj2sQzSkzYAQAd8iUHswRwH3/vrjoch3X9\nGEqev6/eAs6vyBeQJrqV2/MHDhEP6Mb/aYrTlvjfvfQ+5zcK6HbZJ/j/YfOe\nTaNFO28uux1/WFv6/23R04Tmr/r8jR6VSvC+K4Y35iPb3jPhr0ZDMM1iS461\nGmi0LohRw0sEBk1bjeHx8trgGmBjpPSqjWbRrlDeUUmitr5NtI2X9UxMLXRC\niAH/70bxFpN8K7GImGXQIlcG2bpkTH2V/lbF/77FNSNXMcC4DA+iCCQjLfxj\nP+oT/CQlfBs4POpREzDgzGLZNWtuOTtkNTPmgz8sC+vjCI4va3z8rbljt3o2\n76IUuUjDOf0gQuI2noBG0McyJ4rsl81L1xkxxsRpJkhtZqtBXltnqI5/2ET+\nBpXdBPyhTWYEOMA/76cvLTl/KtZwW6sMenAyGEAWVL9xU04Viw+rIkheKvtR\nL6smxsLC9M5cHj/5TLb6v81tEAKlj8OtT/k3iIcDRjici1To7q2M3vt6q5hu\nLcx5dZg9IEBOvV7i7x+g3q1W5AQ65trwg5WeK/PvQMTKflltiF/MqtMFZNdr\nnOVmOKAlIGL+LEFI7s1tnHAdyFKQvCviQASbaxiiCzl20101sNzkK2AnfpQK\n1n0P\r\n=w43n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.4","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-84c57a8-1597820666754_1597820731022_0.5367933064330075","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-52fae2c-1598078449417":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-52fae2c-1598078449417","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-52fae2c-1598078449417","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0bfac2107fc4ef131e1214c5ac7b429d1f326bcf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-52fae2c-1598078449417.tgz","fileCount":7,"integrity":"sha512-E+E4HJoEBoeNFdidO8cBd+HxAk8vlPZnliIRz1nVm1tq5uY8jz+Eh8TqMDFWsO23JoPirLg9g5z3TxO5WvTNRA==","signatures":[{"sig":"MEUCIB9JwhawPXk704Knyls7FsoVjqUlU20yJB+rw7QKkF2fAiEAoTcAEyQHralYfW0MsVXtA9iJA8yGl9oQSQRa9IUA2xU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQL4bCRA9TVsSAnZWagAA7zYP/0Bi1skR2qGDq9x+Ysp5\n7mB4AvgvebVFJ7K/CRiOida4y1WjE1Yi++3Vr4+Klamiqdwu7iyJOjMHrsDC\nnIAC2bQlPtZ435GaZP9Tw8JWt44kHSmVp/9EEmkltwOhAq5ZmQr/TmVFC1Rx\nvNemQSiKy3O8YUAYpQwJ7FxD/cMF9gshgFT15GKcnSbwM3E2OU9ettcO+i2y\nHotYlbmrJBLYeGYdo9bgWP/PJyO8T3yuzPNC9VX8koEbyVKqfoRx7q/pEMNu\nqyju6iV7gmecsZlrar607c63b5QygweOMYQ+dBxbn/yfVhE35ocI+4BPRuht\nWQCyF1dYPteP7dX2q/7d3mzEM53keS3GNFsmzf9lduvxO1yj5mvZOZDrp9zV\nmOLaOn9KU0lCfnTCiIKxQ6B/v+r8v7DMKWOyLeyqtGeTlSl5g8N17ootbJUb\nCABAb8IsZpX1GlzcI1ILImh4cPWr2w6mYrTydDK2GrhG5YnhZfUE9yoswF72\nwXIUSSWZISDqRfcVJfId9G0WyVTpkBjJx9gTl2eGMbv2MBh9CaHOllJ6h/90\nF71KHVlO3DXyGk13XPu3wepK0iN7tfI5PzeGAwQxvaqdqf9pcYIIoNFTLO3l\nvWmXVBRy1Hr4w7bHoILcHbyuI2NlOL+hOEHN2n4zebSw3A/3h+W1oJBIl6wN\nEzPu\r\n=VqRG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-52fae2c-1598078449417_1598078491242_0.6026721978640672","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-52fae2c-1598078451504":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-52fae2c-1598078451504","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-52fae2c-1598078451504","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9e785ada3004eb60cc9372007eb083c7559009b1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-52fae2c-1598078451504.tgz","fileCount":7,"integrity":"sha512-tHCP9nfWjaZ1n82c3Mw37ma4pDaPl5M3pTKWnzSriJU85jvE2kS42msRpuqqjSulyLuyLNtgDwE2C8KLn4PUbQ==","signatures":[{"sig":"MEUCIAaRdDAeiYKWCgtFPeveIE+kyicTfZlIXmv6cIyiWupkAiEAy57D+J9lWoFe2YKjx0BHJpuqmfVHtm5wpmfH1yQEbb8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQL4fCRA9TVsSAnZWagAAfsgP/A9ZnY6B+IRt86YfmGcp\nogKx7lIQMAOZtVAnS1B1mLzVJReK3LRACYw1rcdAKW4lG9gpdVIbS84DbxFn\n6CBaXUadCzAGVisCJHluVYCopNO8P0Esu0UsvsuFu3rwd6Oqrz6r5wvtg8WK\nGYSaS7CekYMw1Re/S0q7mOMtLpnXcR1dnKpmEsLmY7sfxnuhviK/GMkVOci9\nq2RE+crYLGcn3/8W2a3m2lnnCDBRNc8FOFbd0CDYeXpB7MeKv/OThmqjlTe3\na0vbpfRpmEGP7oyOwdYUexupyp+KeeuhoTWTqceIizsjecBj2PWQBhb4KV3t\n5m9Ch8sYOcD6AgedNdSQFcSkEtWGkEGq02NSTbCrPArhQqvGDHuIYax+ioGk\nHzdFz/iEybqNueTGI7+TmwoeHadARlshguQDZSLHC5cEDRI/gbA7RhlwML2U\n3M/cui8G6aCvs9oU3lembOqvPhBRRfrUYTWEurwLfNRtJ07aq78w9R2aBqkV\nytEB/Q0nuUS+lwLxn0buom8vsJLyrA69x2gt0v5+jWjnUc+Do1UOLYxfWpPw\nbBpkxi1uU6F4DoytDL0Ul6A+yxOg+c4tuPBMmLxKuyGPqoMBbuLOmZnOnITj\n1S1LSypGJBS1LZOE1a2Uw6Lprzf4xeCJyxCVP+BGzC/HIJkHHx9cuMEJgC4x\nlYsa\r\n=+fF0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.0","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-52fae2c-1598078451504_1598078495407_0.7992771352774422","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-75ead24-1598101775909":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-75ead24-1598101775909","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-75ead24-1598101775909","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"520a76fcf781898f93bcb06869e2ac9e7a695e88","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-75ead24-1598101775909.tgz","fileCount":7,"integrity":"sha512-r4i1TM5ysdGf/LL3ALYm9dKCNyxBo1XavQI3lJJ3HvUxyoXwF33ZPkMfHF0MbcZXQYZyaYKEytDiV4Jx0+vB9A==","signatures":[{"sig":"MEYCIQDJ7Hfcwj5UR+jL1ddTuY4PZ5Gauy4htKMgrPvkt95bGwIhAJBNrp8rIu/lh5ig2H9suiMk0Eb1yHfSoCK1X5czuDAj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQRk7CRA9TVsSAnZWagAA+ioQAJZAe5HxYCo/Dyvy7jEX\nyRoUfvXHId8UiCaOYLN7pKQk0vO5hgvZSBvSuUTvPJoWTJmqCv2cOGUWmJs5\ngZ38oXSTjelyq8T7DTlHHILIJwycmGxzxsa7fatDDkLciFdK+qjDErhulzu4\nbzkAxVlxa3ImF/e+oWUHc9AoM8fpBX9ZOkHJt46fSrO6ishf8mxdnu0p+5V7\n2dmxZGAuQ/wb32Jbsy7W21Xi+TKlnpQYLk0IAK+5cxAjHMLAs3fthEjmyi8X\n19HBMO5vW4yorcp6BRwaFzF92G3awDN5cRv4nZrqoWy+ih4a5WbouKixNoWb\n0l1jxkdyvZNOGpIus/uVBxwXBdlIyBdqpgHOutkNMuJ7LrWfzKVVpACKpkNp\nKz5opXDC6hipitkrTJybQAbBTYcu5D3Ez1twIkrWcjINgu7M9Vqc0WjHisws\ngmjXdz74jiCbHwpfziYjcswTKFvWOLiNBUiy/2mGUYz66TDqgTdJVRkc9C0o\nTadS+rz/4NzTmyc6BXkchOlcc89zQ84hC8KlvjJ9mhtkV8ivlQyrssD7riKg\nTCivX2VKJP0srw/9vYbJTEEehcmoIWvXYHx0Bs9Oh+b6ouNtg1kesK7LNEW4\ny2ncgsKK83qTlh6pW1diYI+GVaIlQdDpo/3KIPAN4CEMoXW1ewaOR3NMXQ3z\npIId\r\n=ZrRF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-75ead24-1598101775909_1598101818890_0.9552791302850672","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-75ead24-1598101772693":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-75ead24-1598101772693","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-75ead24-1598101772693","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"82527bfc8239ac6aeadd87689f61d647e1631e03","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-75ead24-1598101772693.tgz","fileCount":7,"integrity":"sha512-oiVHgM+2reQSspSd6bCnEXbVYkD6DHdq5HqlB16BOeydOyq7hBo2raU2gVMuhw8FUUR8rtVWgsAGdx4/pEW2wQ==","signatures":[{"sig":"MEQCIAGloNeTBi9HeEjMJ8GRhVcJhn+kVqyyV5rqFiLt2Gg8AiBhgszHLZmYt/h0K812JMhwT5DXITF/F+kfZqQbkDFdHw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQRlMCRA9TVsSAnZWagAAu8MP/0XOOfxT+kaT/izBFCEY\n3Wsl9z4oMDuhyV24hx+PMK2FuxMAgv5tFRNvUl2Ccyl5Fsccme5EscWpAYhU\nUUgeQY+gTsoZ1BGx7zgQUrl9BzvHN40+wN4hvGpVAFD8+SLkNfgVJpQUpcqK\nMJXuwrkUa8VEkFa3rLJptuZLPtICafkKqvjNWAHU/s5ksM20WW+FKvaVCPyr\n2jLGTem31DA4RgJg/fbj2a9pjxQ56juB1LAjFks8pJKZDdLWtNQ20fzMHhbg\nXXwcj8+v7xLRJ8CJOJK6rpO+qrSexnPf4bOxd0fe9sGO9xlEEvCStUiEZl8d\nxlzUCJru3c9NryGGayNB+7ckcEwBb/jodFqFUvs6YhhIC74Q3Tdzt4dk3o32\nSdiB3rT6dj9a9MFhRcXkxu6fKpMislms8BfFNYf3KKbEBOiKK3OT0BHNkiws\nK+1sqa8L4a2nof/6cyKa8S3rr7pwCXqSamCxZOab6VvbhnTos5/Aq05zR6Lq\nehWNluRFmvg5GG/IWLTN9Vw3nvvgrhP7WeWe+Br61Ua4POEfLhPj9mTZDNB9\n1jcE3LXIL87GBJwBb8Dq5DFhnYr9ECawUP0H2w0CHGzflnHYym5Tm4BlBJCc\nRL5rXC22sZxNBkckGRQpTd6UWvVDoTnWNdznd9TaMLvJPvL7AWerq3/hFPPq\nbBry\r\n=EFQn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.2.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-75ead24-1598101772693_1598101836455_0.5553832368330367","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-43b0029-1598508135656":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-43b0029-1598508135656","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-43b0029-1598508135656","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"19457c2c4a69869022af97e28ea78eb965d8ea4f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-43b0029-1598508135656.tgz","fileCount":7,"integrity":"sha512-pjHti+kDLsFR0x57zR3mAosN7jXRQNZgAC7gXIgqn9kgrfDOqu6H0BOLxGH/FoA57UT3QNWsOoNXXNx9Gc7XWg==","signatures":[{"sig":"MEUCIF6kVzErhWGTw83iU9iw3dO15LPuwy/PVQRApxmP1mvZAiEAshpd6e2s025Ovo9l0E4QnQmIhUFm2WIl8GDc/uCszX4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR0yYCRA9TVsSAnZWagAAz3YP/j7E+oOt6ZUnY7jSHK97\n3TTkmrqLqe4trLt5abpuYZFjtDPaExMdo/GSh+uG4kmTUjG/rYnGtMJaD1R9\nBGpEThiYs8MPXpn8Evf5kDaCwk+y+QTCa1YRfRuvW6MPDPw0iZR7v1G79sRW\nDdTNhfl+4Ysdgs3RbaTobf1Catu5VvkHv+gmJSz6oZvL97/zG2YkNW9/asK2\nndwxPjmcfSRe+Swn7ovVViENOELoLDuKyUMvT3X2Qmss9ILELLT5YL7Or7At\nBFrLURMSJSEMu1U6gEQULQSkh69t2x1BfsSbnRA9rY2JX68cU8Q8+CS7Q5SU\niDYJzNfxQMqdZcfT/bzYIoaa1EG5a7rChIBzaM6tigLBLHDQwRUm75bDPVxU\nOsPOIPB4bFLTk05V+VtYpT8eoz5bvCB3J20wSFfBQdaNlP3l8kjLG1Wk4HMk\nxZXRNDrfn6zUVwCSthb/pwGR9924M2tC/HAq3ZiJ0YCBgmqhuZdIRbvZe8lj\n3iYXkrpcEzsTnJGJ8jwOTqTI2dPdbY7VAxlyOD12DSFGNZoAktmIRTaWOoKC\nB94UZkHiqVagppsjjACNzBud2QOVgTXZDrRs9QqFJZYbbVK/cz9U0suGZ/Qf\ndrryI/BlyIvyWMzJg0SMFLbFZD9UlgS7MsG1gTng7f3f64pExiGYFIU8ZGEt\nRQXV\r\n=Rmtt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-43b0029-1598508135656_1598508184435_0.32756078398452937","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-43b0029-1598508136298":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-43b0029-1598508136298","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-43b0029-1598508136298","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"65d380fc5123b91f93990cc7b72f10efc3182fa4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-43b0029-1598508136298.tgz","fileCount":7,"integrity":"sha512-EJGr7gCLAfkPWJHuSF5Wpsy9LKj/klQ96ohIydKmbkmH+7QWhbu/MOghbUk0ZiHRo3B5VO/xgcFobReCwXl5hA==","signatures":[{"sig":"MEQCICCmHb9r17GPjsxTQsG8ciXt8a/dX7E5y6nQMegYjVQ3AiBJpkINc/6fxvbvH5r4krXgMzjGfyutXETw/uooRnJ55A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR0yrCRA9TVsSAnZWagAAeloP/jOY8uGGVa73ZclOo61h\nFnc+idlEcqK98vQ5Z8r74mTHglbaUo2F40WR7NWaXCHfS01N45ACaSiH9z2u\nPIYKCiOSx/nHIlt4oPw9wBP078hbDwJ8U34MZj1OewarhOGHw38oxkYs0Dq/\ngHjNQX0jEHsMp47ck5qi6CwK9RnFpgoZl3XIV3OeEaZtudH8kOulaRlRgLOO\nKQn/OgERz1PT6WaQH3vlmJRFDAIscAl/3SZF8dA6lvRL3yZOv14e0hVmJQ2t\n3EWnJAgsxKcTyJ2uUCXE6KjT6rV5fmS6ZVysrnytSTJHNnDCxUUiUKm9xR1Q\na5pZWIq5xMSM3/TBKIfRGtvuRNFfFI2Qk1h90aAi07zbhE6BYlQG5xsBl1vH\ny2mTl7emX62gm3eXX/BScMRdju3UEiJGHes4H0X/URMw4paNV1VgbIZg8zEM\n7f5xJ0izTItdGMVlohgoY5PecgT1AMUvdBPzfzS6Bol0+6ykki3hkJfsP3Q6\nWf813LwIJ+UX6RdeMSCNZ9CqcF7pO2R2b8h4bLFlTzQ2k+5o4z4DSo82pO7s\nGXdhaFAIQxVyrzRy2qSgm9h/Cveqqd2PDcRxl78HXIy3OKmkD4ftTRbrFBjg\nw/aT0iexue1P1knowDCmkQQ/foyNXyheTGZtsjno4AoYY3rr+HzGhnizwv0r\ncftx\r\n=ZbK5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^3.9.7","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-43b0029-1598508136298_1598508203304_0.6858871204043391","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-58684f6-1598511208985":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-58684f6-1598511208985","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-58684f6-1598511208985","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"347f8bf1dcd1832da543e7032b07b7493bb58838","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-58684f6-1598511208985.tgz","fileCount":7,"integrity":"sha512-c9gBed2Cmx98cVLSBmf8OcePPgiBaeW+/5KLMbOvqPA9KiS2spcJcwCkHbAdyp87PRnNKp8Jua88dsoWEPqHfA==","signatures":[{"sig":"MEUCIH7e7a6/E8cl13fiGhVNkbgIPqvbAz7LHEDcHbLBzlT3AiEAyyXneug8dYLSotuKH2tLxL0FX3rQsUKF9G2Sw1fv3tU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR1iWCRA9TVsSAnZWagAATrUQAJoSDhgjSHphigRBUFhY\nqwnBmEQ5gKie7z1yTyCQqG/9AiPrQQNK3ZbZQu+Hy+YwLcHCOyCy5tVGB68n\nuhsUCBhFq4LTrvyO1G84/Vf3tTDH036lSaI9cC6nlErIsB+IVPz63hIiXRwn\nyyIxRaDrgPy/6L7IOpb41r57PQNuih2juBOiHDuO23TCYLRzj9crfzeQm1yz\nupN/QxXPVLb7qvycX2pYfOQDNrV5fU1K38+j2CKKM6+Bs/jzc6Pch+gTNk8J\nB4iwhGciNsovvsvwIrfo66TjhVCPKtULPbP+Os3ZuNZ2LJ8KDBa8zPJs2pnC\n2XNKrL1QH78yo4ILVHX5PJrwrfzwssgDw3TBGwhbCVdi2KjhqeXo7GLNmxKt\nciXgr3ubvNx5Xn/6xglJrFOPFdLY2e2H39iJvkuy64TT3ojGLcnjjmgyGwj1\nFCsTztwFClkfWK9ggaSh486O9ru/pIrzptBKqq2dw1TQiZaIt7/o+0wK/55Z\nXJ5dIFFub8cg+s5OQmBZrAyDFd8e8q6ZYl74MwdJQO48uFKSXPoIaQsEFR0c\n700/dsJ5z2V3GQP2bjjyLKQZA3NiDbd9aYhsNvmfZD4WNNNvQtrk9pxhpz9b\nJjeF64qRxPeMoelnPoD+RP53Upy5dcfRruP0J54F+2WyOHV8+VPf3IwYcIrj\nXSOe\r\n=Pr11\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-58684f6-1598511208985_1598511254423_0.7646092949624466","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-58684f6-1598511209293":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-58684f6-1598511209293","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-58684f6-1598511209293","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0e8fe9b746a539279884023c4c18e26a94c42f5d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-58684f6-1598511209293.tgz","fileCount":7,"integrity":"sha512-xAPa7qtHnNMmrDCw0QprQdtiOE0zAAXJga3pNUWpLUzAM4+dH3PhdWFSatSECHZSprYgNrOHHQwHCTMfXAnxJw==","signatures":[{"sig":"MEUCIGtGsjhKxp377SkumMez0+pKiDVDmkzu3bdfo9ehwXBIAiEAws0KUv6rlc0lVHOQ2RZm/ri4TzoXImXKSyxxs0NLISY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR1idCRA9TVsSAnZWagAAdfcP+gKprGqCtWZLX30SZ4y0\nDPlCkgl9ozm2eMfex46qUNAW/OjeO1oyDL9KQtyukF9octNftK+STY7PvZH0\n6EvgdMwTAL5tLSdFlsnqQbp2kQP86E252xkc02wMDTIITCdJeoYeM6mrblWq\nWqeA+iiCm3WbLylrOEHUXmrTLTegYhBpXmlIFoX/OZ5AY9lnJSPY/q8tEAoN\nFKH6X6cWCe5v9TowasZC//tz3Fd3hG1S942AVqrO0vFhx9XGGVb1THooSJzX\ngQYQeVEsuxqNPhuJqqeaU8fYRoRdO+IprxM3C1+8HRPvsuaeBdq8AEbGXW3N\nqIx/Y2qyaIjC1mNFjo4riv4TjrQS9ZepSyaHO3Z80igtQ89+7Vq+YSl8O2ie\nL7H0+WKKdNCdKC1JZ/BgjeaMxtURvEOjN52wTAXrGS2dXie+/DckLi7U4Of9\nsqyOT0H9gBy5goEE/6aMI8Q/MKhhrwZ6BGYvgWpwR5PsQ+X66hxYsge5DSAl\ng1hN6jwpWH+kPiwmqThhoSvrSxMv0K+XGPoBgc6iPujT9TJk3AOsqZEeiJ11\np9aNYhI7Yj8SD8Ysjx3gMqCPptzcnT83+q+aAnmqRJOBR12mLv/hUY8vuAVU\n0ABotBt5O73KRvtkxtxPiPXPVrM8wn4vzkLGYKG47N6KRsG1e+WcsOZ4blLA\nh6Mj\r\n=0xQH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-58684f6-1598511209293_1598511260734_0.020435243776092404","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-302cb2f-1598511379174":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-302cb2f-1598511379174","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-302cb2f-1598511379174","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"162250f978b92c716ad474ffad1101530953ed92","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-302cb2f-1598511379174.tgz","fileCount":7,"integrity":"sha512-13M+2kvnaGdqFkaAgGURNd9S7BtE9On4DP3qdJerZuCxLlqTKC900GseHpGzl8Iums2/07/XiPhn/2XSq4xP7g==","signatures":[{"sig":"MEYCIQD40AfiRSX0K2Po6aHTj6Vl8NlB1hF1h7i4lZiIGdaOyAIhAJDNoAphiASUOUWXIkUq1MESLcHq3SPahmikCYfGN71Q","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR1lUCRA9TVsSAnZWagAAPX4P/jjMZm53bgpF6zV8KN+H\na7wryEuZx8NFevXO7axonH4Z2MPLmWe1gZ6UE19CThY6/O08Sr2xcE4JgzVV\nfRqfZdH+edhhGtmdtHMNXBdY5SF2M9Zg1QMTH3QSx1vobnKjiP0KkpeEsUTq\nMJggv9sj3v1DX/9ZvnIPIxDDdc5HFH/Tp8cIb1P8NdlpTITM0E6dEAFcqoPW\n6g7DN12mQ+ZfD6ZcbYHfO4RPJLHkJr1MNbXcFuwCN2QQ4sDC5bTgO0H7CBAd\nQ7y6kfLmTRCIYTPxqm0Yhxq9f4vfjlNQZsE0jQ6dE4KS/RgJLePC5yF2VejZ\nlvgGMOr/QBQs8tbWmDUcTQYC2RTo1gGyqij5RKbYVBW8FFT7mSMBl3QuuJqu\nTDzpa4F27Xepjxxdi70K5OIQoI9kzVH6UxjpuZjQFYZgJyCxSKIzvsDAlO7N\nTPEa5aSEsFWg5iGI2NomY7ChZygdUW7F6ANfmXewjuxlnjhra9tU5mpfKkr8\nFF159evSJ7cwOQo5ALXdTens9iBHZhHXK9XNRKqpX/O1ruOECjIuCZSQsnO0\nTuldgP1RuhCxI95kUqeYA+srEZjuCU4J4XeSb84+mOVWP96NgpkiBc1TaHMW\nLJQeBNB2gZtkhFLa5lL4XKIBkv3qqCdfTKpjzMpJsfWyalQhEPUYrzr08kij\n0qbA\r\n=jr0k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.5","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-302cb2f-1598511379174_1598511443761_0.45053773453070134","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6897d81-1598592530680":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6897d81-1598592530680","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6897d81-1598592530680","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1ad2ac52b8b02257fb2025a3ab37acbaa3c97b84","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6897d81-1598592530680.tgz","fileCount":7,"integrity":"sha512-qaVGR5vUKq+NtHPB35nkKOGYW07nvZOCrekKrWs7D+A5XeIVk2egAYmynQL/XzvIc7euAuuzO2cCTvVSNBWfjQ==","signatures":[{"sig":"MEUCIH6oBLN4zQBG7t+4ON4FVvpvQu9V/A2ykmxpMWCFs2jNAiEA7FlJE/GuetEyBMgd+J+Fuzsm1im4vOoY4wa5Y7rrXYc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSJZACRA9TVsSAnZWagAADJ0P/3ldaKywrMcZFMz0GOIt\nI4iXAMG92X7u9ehdJYSg/aILFYHyW8sTpWonJAMHQP7JscSuXBKTsRnYOKNF\nID2BSTMA0fRIqP51xbo8sE9mwwxXBDuIb+EFsNvOXP63KdExKNJCFNJ9uNua\nA13/Im2sk279lidiOHfRKJGy1Xph8Y9a+L3RNuJ06gtp9rVoGIV38IMxrqNT\nt5nzHFjAv0hXMZUy4yy4mKj+j2q4RFXzfdJNgS6LzBOKO3FelD7Di6UXYpQc\nW0evxam/p7isEinP88sbrynqJcW5fTPcScS4bVAiVJ73Bd4q0LddRtCYljtA\nCrZkkWFMaCmkxzUoNhWF1UmuMl5HH/Kg+syrXu9LbH/vDy21BD0LW2uoQz51\ntSrSfjuB3nf/NlUgKyOenOV+W/iLmrLUg/2WVA2aJlC1zNAmfHNI5ucw2q7q\n1ZqxvYGYDQaLt2dHy4bfJ4xvwjl2pyNE1JCTRPLZ5ETiN4JtUo75Ltg/ae/X\npltQpyCgBhkZ89RP85bAU2xjvOCAwIxJzCs3sis95nSlTNyt6+t1LTAz1tD6\nQH2J+rVvAA7LCA5gyzlLyKIGbbUGhcyiHDVP3iBHXXLABJFK+m/Zp1ncnGoN\nijJ1NkT6dAye5TpCozTc48B3E9kkatkfyPOM321f7Afhp/VDXZ6fMa/2SO02\nmcL3\r\n=j77L\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6897d81-1598592530680_1598592576373_0.24400382089466421","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6897d81-1598592533896":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6897d81-1598592533896","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6897d81-1598592533896","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e79775dc6f605fbf09cdf3d1a58b8a20f8f11f14","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6897d81-1598592533896.tgz","fileCount":7,"integrity":"sha512-YpULtcMRfeKeRvEYtjPdO76rLFS2d70PAm8BCTocNXli0pmsI2xFoGYlQT4P0d2cWCq0COA/uvql4kXb8riCJA==","signatures":[{"sig":"MEUCIFxWbWX73v5yE7ugLSX5oTTK8NNIPilRoqu8LKmFEgAFAiEA8WM46l9B9WOWYqUtj1v012+ag9b/7rVJO1mwm/6pRY4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSJZJCRA9TVsSAnZWagAAnYIP/2V2R0ny/HCxRb/A00aI\nsw8QA8rtB1YZNV3Q1gePQeJlDn1ikWA2E/4AR4xov/Db3DZQb4l/h2X/1qkm\nU9sANosh5u7bKVQx54jNpvZi4nvpYuYLv799nCLqIawFrU1BBc+ut8x58dmN\nbKcsuPCkFhIH7q0J1F8PVCpFeLxAZCM0acwcdHPOceIxRN0APa6Ik4Xyi2ZQ\nAdTavZs2tM+UBrdIOgWTZlHcJVuBNL8q+ew/uwVYGOaqKNCZlwJvntb6BpsZ\nDeUDgUvRl9Q0mxKDBrmJBBYtd4JtNnIM0kxJdJjGO4Bq317KtYOkmhO9tzn/\n3fOCsfiX/eAySrO+MVybOLDsszb9sqdyyd6SZ4UXV3pC7BRQE6h/sP1R0SLB\nuyuoPaffzFOJ4fmhwwbmoGseYfNIT4M30NNoMcFrFpYbrTSwsirxqCDYiqde\nM3vK/LMowzVginkVYozQaEs1P1u8GJdpJ7p+vb0dHbtSCNML07d4tYS8vj4d\ny8fXrn7w5AxJudDLtcyV8rOVNScY8MwUpHM3nRb65FJ2Bi25HY4PyW2NNbtB\nweDUquvaJ9wkVMvMxbSUhkpXZvcMHMXpj2FOM6YuxeDAp1C8pHN4cVocdtFc\nf+KlgzjtGWkkzLkyRDM4QbAphCbpuqEZWCLxudsUpsOcIVFHz7nKNOugoHQS\n9gd7\r\n=wEzJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6897d81-1598592533896_1598592584637_0.38118083777745015","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9689f60-1598596145106":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9689f60-1598596145106","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9689f60-1598596145106","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"51cb5151a1e796e57b20d8c3456bade0bf447b25","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9689f60-1598596145106.tgz","fileCount":7,"integrity":"sha512-omRc4UmDkh9dIALtmUE8yQ3abijXLTS1eGcY3kqaGuTzuOO9mIg5t+tcymb9SHMMvB4SylNc8EX8crF22i47PQ==","signatures":[{"sig":"MEUCIBe9FkoLY4Q1nYknqQ7xh9BJ2aE2ap5EntUsxlj3ambbAiEAtihZKHpXsLVrlNauNW5KI/rjioW3bir+rmC8TxYCPok=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSKRaCRA9TVsSAnZWagAAgZEQAIOidgqj7ZvfggxQ9uEd\nczFUjxlLoFap1lMv6GW9vWLCazQR07diaaJG4JRckAcLZB1PVjGpIf2Jpc07\n7DVlQTqg/8cT+RZqZkOu3swViVxSk3DO/lbV08SZL+tgOP1KSHQbxKhykryP\ncgto/68bnM148YzvEQ/R3CIgoNwSSY4K1j3eWVsN0AtLP7xZ9/C/N9Op5Vxq\nEDFAox49wDu4yr9anwmlGnwIoQAZBLQ2pxZ67sUsDruJ9Ct+lzOLCFkhTXqY\npYrGvQIbDs9DOHSn/q4rBiDip5uz6pOirDMNqmFWm+KpF+d5C9V2stIevW/j\nZbDS8k5OLY9XzHL60GW8Uz4i5kAUqJkhDgPFV2vX+CXqWRUC/uILu2thYN8C\nZiJS4u/hJFYZOXlusfG2t00x9w5bkqp1+FEwmtQm/MRexe+XkGfNihorQX2W\nQAAUcNLAyrolJ4LcPc9FYcvjiF1g9Py5RV084D+WUMn12e8D9lbkFgwpCQEv\nShXwLO6jaiU+QivuMoF+MpeXBW44Tz8+u8ki/82DHRrHy9mWBXs6vO+B5TH8\nTorRZrNHgdU8jj0YTAvpv6iW48aCQ4zG1QLF0zrUZVjfA/KrLYfe7EiVp2Y/\nXd0B1rEWS7p0PTopj39EmopOY3wBOucSS2OIaQ7DEL5OJx38XpqeskTO2qZ3\n04rc\r\n=qrOy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9689f60-1598596145106_1598596185667_0.24958463685124066","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6199248-1598596356042":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6199248-1598596356042","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6199248-1598596356042","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1db896b96fdd9b67832b545242dda12f13af625e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6199248-1598596356042.tgz","fileCount":7,"integrity":"sha512-z8YmlWRBL/wgtQ2bzDDQzDCdkq2rj6AeJZhO3cBZEHB+VxYSuRfqSVqIg4FKNUs0B5IdWZli1OJgVTiaZPvebA==","signatures":[{"sig":"MEQCIHFeJ13DATx5XWyhcjsY4H1CHnlv7Rf+upIynWFsXDW3AiAaOH9BsgnrX2nqzWhgyEuU5o5vYgLqAVpeU3cs9pDC+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSKU6CRA9TVsSAnZWagAAiuQP/3pMtuQ6B6nqEdZVoQzl\n0TSgZwxqc4JUWO6vln9AiMdLzto5fDAQUmKjuR6J8GetI7LHkuRHxL5ZUvhm\nr8/3oQvNhNj5/I4oABlPpQo/wWMMKMowYYOTXQ1JZ3RYskxcsE/sSc7UgES8\n6wOduHFkoPY713lHa18TXws08GCH0iDZTjvWCCxmbMXxO2dW59eO2OK8qCAh\nUaDxpF4hH/ZTms40sAhvFvNDyNs8IwqeW67+Tw5/dRfI1flmJMz1Nc26Gb5X\nCpw4GzEPmuRCnJcVaRdzYb3CqBFT6Fzh/K/HSMGhwnvh7VXFjlOVos3IRu8V\nqZftiho3WMu0uDz5LWi3gE/J6hK24EgvnlvnXImVMkPhM5EbQYMd9tv6dkbf\njQ/3K8rcYbJgCF9ShDD1mwySzof9KLc82JWz27pKoYGlmAzyQfww9lDDup7e\npIQaQtdCqk7HWE5zxTsRsQCBDD6J7rZwUItEyV7lXTwIrJ9nON1F85QVXkil\npXDsXzJEsRB0jud5hvM/nuRS6OghW7LZCNm4Hd+yG1BFZqK1ONglFxNtR9cw\nC3idQUOIVYk3RoNCh+Pw3dj1octrFhWaXbvPAjRrxFtYGwvZ3oV8Km3Di+Y9\n862/zu1y/Ooi0CuZRoEJzJP6CnhyQdlTd+zxqCemevg4lzgQsPQp4xNqkYpU\nS2Ka\r\n=KgjX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6199248-1598596356042_1598596409558_0.8474288976741748","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6b88c0d-1598708236487":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6b88c0d-1598708236487","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6b88c0d-1598708236487","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b8eb3f99a1b43b83708818d3dd41328c0406b494","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6b88c0d-1598708236487.tgz","fileCount":7,"integrity":"sha512-H0QPK6WK6zIphKVIcLoLFT7UsfDZrKqo2hSHrTxMOhf0W0rlRTQ6TEb/cT1jYJMnHj/fnzyIz/z3C9vThFavDg==","signatures":[{"sig":"MEYCIQC1zY8cis3I5esbOMdxM4JhszTUyKTQJOZvPLAQOsNgugIhAKi9DeeftLtRHQuoMUGp3lg/z2ZiHemvy6s1yyfFBQ71","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSlo4CRA9TVsSAnZWagAATmYP/RmK2UAugsqsSEwn2BDA\nvJoBiZbNXQ1lYg3IkzoS1keu2E2H8V9hJJNBh4R8oRhJn2+l40xOk2oqL22Z\n1gNlGJXfkyn2Ue8hr4prEX8RhGrYTPl1lJ8ACklyjmsARECKG1LNRCMmkdf0\nm39b2i00f9HxdbIDLBOQac8G4HMpvh7n37Xg5+ONV3sm8KfpXkHrZatwUQWV\n4wf8XOab51pwnx5ZvOm3HuXUcWexmJfx5ITY4Cj/gHlrFUZ3dHt1M98yOaBp\nQOopeX0c+8r0VLkYPNJCP1Pyghz2ro7AcBq7+Xdd0IlulSk2AS0VukRjSwV5\nxrMfiAO2MH7acfrTm4o7RsdIN1MU+5YwFT4DmtuYwFvkaI2AAz5NRfJQYUfy\n+rtTXKk6U9l8uIXNHaelvsVv7X+3hWGioVx7l6YjY3ohjwB5D7baUvQDexeQ\nthAG/I9BFT0nzfB2WeeqRhjKsY99H72BRK64NNPW5UX1a8Omd87y2+Wsg32E\nuFCINzIBZK1hRnGAIVLLjktrgjfF5BNyNWcGnwm/5mbBcD/+Vs9tZvOYpAGn\nkSbQLflZZTs7GAoTnJOcwdaeeV6z9RXiOAXBmghe96avoTJg7kc5OiwbkReW\nvdebKM5P024i+pj915cuCzSPTFMFmxpFfwZ6mjAGYnrtx+dVIWgVs4Uev3Bs\ncehW\r\n=vZlT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6b88c0d-1598708236487_1598708279848_0.27149367643017475","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6b88c0d-1598708238957":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6b88c0d-1598708238957","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6b88c0d-1598708238957","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"68c51fe0341fde33b1f4fc469882d5d319a38d64","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6b88c0d-1598708238957.tgz","fileCount":7,"integrity":"sha512-xn+/mTRh5nLZcC0voK8JF6BjA6zSwQGBlqm46CrDR1qSUdMONQEN+rydNtVsccMvdp581OJt00WYZwSsV7BjkA==","signatures":[{"sig":"MEQCIBkWqlyzWS4oxVbO7qhIT7gJsgTpk1k+i+5RF7XlHOnFAiBwKrXOlHAqF4TcAKSnccx6Ts/GNJh/b+uvtKLI/3k3yw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSlo+CRA9TVsSAnZWagAAX9AP/jMcYwaS2Ya1HuOucZ9/\nm9fjBP5c3AdXv5pUtomXIsi/owklUuqio9YkpvvXUaayTK8YexIQg+zT5xCj\nHagK13Wvvr3xBQKDtmcY0uJWzuLtHf20UM01QOyC+L0K50B4YtwIc4dgA1WC\n087LBaQWThA1Za0zjc1V5r+BE5o5RPx8n5LdL7SbT7JWbf279tgrothGdmzy\nmVgYiForwy6SThySgvOO2tjwXS7ThxRgVfOuQISZFZN440bdEywo18vpA9n6\nCMIe7HmSfHqilpE+JNoJ4u625RUWz7nLj99bFRzEihZd7PP2QoqplikOYkGa\ngnzDNi+Gr1VZ/oiCYaV0vOA+chVSF2twrirTq8bDPWEWdBFtYcc1chlyRsiY\nen7ThVcc4kr95yo4hN93zlVNeSivc4K0nVQJ6sNSVdDBV843mseSmg9OmMz5\nuplBC9O9bTsljXlYJROWMe3+vBgb4DRhKvNcwIQPQ3rKbgpQJRvQQWbH0ejj\nYO9J8llsucWflZ2bmHgq7VAs0fS4MGDaFfTS2dButlM2/fJnjWQZASiEPTOZ\n/aTFzmX3EIl0Xvpu+a30/5uEU3gntTyNihx/VPJzMdPHTJfLUbCsqvQ5JfwA\nHLfbU5PXlIfcTSdRFd26X7xQxwzbGsqRrNp6cPbczrXP+cppAS0GnZw1IcE3\nLWw4\r\n=XRoM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6b88c0d-1598708238957_1598708286353_0.9148680369506286","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-28dfe14-1598710108101":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-28dfe14-1598710108101","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-28dfe14-1598710108101","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e757fafb0e2c9c10da4b1a886c6d98b3c518b547","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-28dfe14-1598710108101.tgz","fileCount":7,"integrity":"sha512-y02sDsoqU6SORPJFd2Zr10xqRcwUxvWw4ME0ajHtgEhqaLaiGdqbWJhIarrg59TkfWYPZ+ZjG5qN0hzA5KUrqQ==","signatures":[{"sig":"MEUCIGF2CYY0db4OMadYsAks5Uw/mw8Bxn3SKGadrWxvNQ9WAiEA3ZEge706p/nZSUN15MxGqhJ53vrWGH5/P/RTgY/mYs0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmGVCRA9TVsSAnZWagAAY7cQAKJzffdmt6zpchuoOJQV\nLU011qYjxJu76+u3OKB1uyEGlZCAMVs6cl/InKg3ECu+rA72F5g77x0HHMX/\nMbdkAJRGTWMB7jU4uyKXlHlmlIyNLMitrurmFQyuFSmCHFQLpWO6qqiDctFA\n4QuyQsDQ0PrtR78UsskPcJlnsxDBzs6EDcjwlnwPszvyg3QF2ahMwM+e72Je\n+i47g+0aLn0xQC8P5g6oesXx+1c5ZVlbxMlWcn3UApx5/iO75BaU3XAzhjD3\ndfAQN5GXuocvK41kVhkHn799A45jpEMp36WXTxDimn/5Bq6JcxX2WL6iDx4l\ntxY+5GVGZ+b4bKsgEKOvGYXTAoDDkT0W0GsYkEHr9ZmFUDjdDEszT8Dd6R5T\nBEgQ1cV5W7m7I6HhGlCbtnrAAdc0VwjXlm+K0L0wYvsNTpSws6Vy50FjZE1a\nFpklFo/bw2f+CHbKyEfbvu6edv41Y2XUUt6M9AltMGv2MRFbdWuAGr7JsvlV\nSzpfvL+0JDNK/E/cq51j3ksB7D2fADedZG3dPEpTl7ImDzm2BzsF+lSUDw95\nsm2ivOTpe4id2CbuyUqd5BOii7GfZV5LUJivfUOZq5fGCPX5vrJHQyCQ1fid\nHDPn+9nQ+1dw5NQJAtka4gvQDZCAr+I/5Q00qxu1keqdGPqe+9jaadffojXe\njnPw\r\n=otGl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-28dfe14-1598710108101_1598710165385_0.04415950240712596","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-28dfe14-1598710108757":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-28dfe14-1598710108757","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-28dfe14-1598710108757","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5a7f154ede0ae2202dfc469a9682dc098a6babcb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-28dfe14-1598710108757.tgz","fileCount":7,"integrity":"sha512-wtUpj5piH9rHCXNP4l7ZvJPKrm58o8RTETmNY6Bu++3JCg5Lzn4Qde64Vb8UnoTgPI+6pVnRXeXONoQ8ep2qew==","signatures":[{"sig":"MEYCIQCAveqCNaBzWKuhR8PlxHf0ZdDZcqlBq9czrbUvR4RHIwIhAIQkj1zwd69M5H/FuZkDPhI2+Az3cNbgDtyxYDXGnzpK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmGkCRA9TVsSAnZWagAA38oP/1Ghdgp9r/IlbBdIfdtE\nsl46vfj3MadPP0+emahzf8F/i+bq5AhWGPAnSYRVesLztag+WsvqRvkjsj7t\nNdIlIvu9oYNq/LqR7X/17XVZtBsV2lAU4XeD0uCdpnzo16q0EozvhSybkBX+\nrBkQX90DScZejJPQB/YhIV2uhVq/PSJf1dQaoBSg4te4sbBgktjjLNg6RU5V\nUU8+L4806ZsAWVlGfAri+qjP9vCu3OLV3BUtmfwuCX11SCYNdkfY1dDWoGoy\nA93I2v9GKL3qwZ/3GTWTCo4TZu+y4vDO4/pZI8Fj6HR1EDEfYVP8BTFTZdSM\nEiwuHhk2+MYmbpx8+779PwmGl9zWsxvksLaC42fOsX99vF+yguUSdPBc6qW8\n7A2vGmdj2lIB87mSkzZ8G3a8RxMEV5m3AiDtAsu0VjgQr8UiGVnTSktbB2Ph\nfyrIh0aFwWwL3N+UEs47keq5SoIQHm9JORP64VAwxZ1mvtDMNZD8NOMMpxEM\nfxPihIBejmWBwC3oqFmCIFR2Ks0hxF7whZZ9sgED0wKRCMVUt98BGanxbuYk\nDzpAY0vtwhpzrycyhZjygBEBbkHF33Ze0RDi4vSeN+dAwB1It10X3qiKxz3I\nKo9CeOm7YRZKI5KRp/067BY9dPzAt5PShVtEPSkwUnodyCKU85k57rR7lsxS\nkQdm\r\n=i2xA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-28dfe14-1598710108757_1598710179782_0.7350369622063206","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e0a33c4-1598712180924":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e0a33c4-1598712180924","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e0a33c4-1598712180924","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"93b6c754896f74f232ee4e254a57e87d47690410","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e0a33c4-1598712180924.tgz","fileCount":7,"integrity":"sha512-F+2EKgQ4+8v3CeNYUYxXsR6H7polrv9ngzlcgj2jeqUdLUov2ZdYnM0D5l8EuO/y+JAGfMLl91oyFo8/qKg2HA==","signatures":[{"sig":"MEYCIQDew3pNLtyulSHuRJaUp4BiHNFBIxuhVom2PHBSxVdEBAIhAJ8lW8N95rAKtO+7CNiIevbhwrSt13Ek/qRHnTW9+B71","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmmqCRA9TVsSAnZWagAAlQcP/2DKI+3XLkzqKCpeDbOp\nXOQhSjBmBin9p+5q3zH0itoPkptO4PS104RktmXvkLt0XP7uZeWM+71OCtGv\nB2sOqRuip3tVgF6ocgKYS65JIq2sL2shSYTLfbHZk3vyi3t2zQDY/12nqFDr\nbHzC5KVFnLPN5uTHlSyw73Vzi3YwsiKfgg9r4Xadqh+WfdeP4X7pdXH1gesm\naLr7z8eoMjFA8F3u442mCzFx4ZsEgrx7vk3Qx3Xvl1X5Jay6CNBtlts3lqpO\njdzMYqir0OrThtFmyjxdVhI+kLuBopcJXzKskTtd39sZBVMWgbKXYo1ioERM\nUNbrPH+qwgUnN46hFdV+Z0OQ7PkJH3ciPTo67qqcUcdkKKL1DfA1YMSS6Gm1\njItFvj/D40TUU7g1OeYeEa2rj6M5XTRZva5y+Kvixm6AK/ye/T5duxtRVKm1\nqf5BU3qiglR6vVqNAfxnAfR/jGtbZM7oD3A8ohOd0jFykn8jFMmi0Wm3Hm6t\n3ceQvb70LNKMH9fcsjDvuJEzf/J6vQ+zXzg/UMRTZL0zlvX53NOi2Tuckfw2\nJ8+eVRiqmh7uh2EOcbhi8097V+fx9oV/lWcdvbVuNddvpnCfQRObRubTs6Qf\nZ0g1DJq8CwfhYdhZswVvQpBSSEFiZS/jZfwlfjb7oIiyrlHh/+SPLMXMssZL\npDCV\r\n=XKOQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e0a33c4-1598712180924_1598712233846_0.7221001936134126","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e0a33c4-1598712180584":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e0a33c4-1598712180584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e0a33c4-1598712180584","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"afe3d25acb88a3c9a7be2b91fc39b05c77969034","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e0a33c4-1598712180584.tgz","fileCount":7,"integrity":"sha512-sftejAaLS70HhLcO5A/iFifJ3abMBR8Lp33HTKUUxdhIygxLn+c0pfCLN4ZSawpkdsAKjcZM+hj2qayzjPjFOw==","signatures":[{"sig":"MEYCIQDbF598qXWvZ0Y/6aU9gI0n9YUn2wIcF48a4jiVGtdfaQIhANvF48i5L0NjjY4d2+kCK3JrAzNXVgp73UHNT84TyUl6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmmzCRA9TVsSAnZWagAAs90P/RYOU8oGgVerFvbsvlnU\nQ4DVCMHpH9Xk3+PKHoVNX4n5AHbuP2EMGyaGYeQliJNXinzWcOULFAyeaSBF\nHejuKjqor0pWnyZ1KhH4g2PvthDOASXkySCo6OjmbcvOTUXr+VGsmyxFK+mG\nl3IJsTGmFupq/ZEGOS0CMZ/nEZMGhOvV/wjn+Bpuj9MWryNqEyaTtL8rwd6U\n4REV6vxd/kXix577NbLP8HY9UoEuUZVPy3yUiN40xr5ZXlgKG7vz0tMbYvLL\njGNK9ncNt5ypy4qL1qekRK+qse1BYmqLyIHzL9V/cB4frak7009xwk6oYKle\nUN/JJZTmEvX4S0jX6/oki7cXE3jn/Oq5Gt7JrsNe1190MaSmE59jSTwusVq+\nS4oXtzoUbqMOVXvFIZCuXlt5+XyWTRoCAiLGfxXiIv3KZRyZs0RMZkVIZFIR\nq2FjdQxaIOc6B9u9QuIII9nu2YxUSFjluowXMVnN+S3Npi0oWUUTCVmNQdtO\n3Cl+b6ScAwnWQJbhddsedSQx1eT9lUMF/gxSa4QsRQYsTDgs4ttQYgRSi7DD\n05sNrkubYt4VASM9MCjNk9+nWUGesWNR6WGL1/hdtfefEaYoGM8rIcGiy2jy\nXf2ub5MvDvN4bCrsTPP4v2xeX9mPrf06sHCJvmn5DpuBUo62iqORWm77OqaP\n5ZoU\r\n=GH+b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e0a33c4-1598712180584_1598712242895_0.16820309225805175","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-00fd3e9-1598814050788":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-00fd3e9-1598814050788","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-00fd3e9-1598814050788","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0e9b7a303ddcf0104c654a049cc2f06d4d6bac72","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-00fd3e9-1598814050788.tgz","fileCount":7,"integrity":"sha512-0IYV4CR6YfhcHi9c+L9DnlUx5RAzAf6ZOV7FifeVGCZUUV+6DY/rXBJIfytJaGcKvHlLvTbF/YlWA2puHcIRdg==","signatures":[{"sig":"MEUCIQCa6cPNWUrRONbwoREJT8FSHOKpetHX4NCt+pABu46b7QIgOofFo63YOfpUvXX6heYJYN7C2mDaKjj719rI7nDRwSU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/egCRA9TVsSAnZWagAAtBUP/RsPZ5hzCGmIYA0qUGOG\nQC9zSv14cUGos7GcT28EV4/vgP3rvr0CP0gyoSj+uwEtMvQglWU082+Q/adP\n0JPG7Uc42gDKQm8XHeAZmnWXHU+RHkPx5sCLzET7jZ6Ikul1eiK9kuN4jCwV\nqAUK2wqwz0VqjCyGGD7DrmwlxL9zxD2bu52akUD7LZlA1HqhN4M8UZfZPqkB\n5LufbvIqydan7Yxb24yeKdlFhFYUIiMZt73yqSkGLqqizlo/j6HnzVomrsTt\nSc9sMmUFU3Kw7i/PVsIQqGb5hmWxRox67Oq/qSPPPLayAKsRHl5x+EoyhOEx\n4twisCIAYFRziSpeluYfxfGJu7/5N/JHkNE5NB4QNIwXmxlG5EQ6tCbaNXFA\nWk/sTi6obaqcu8EGQRr69P1gszkqXpCzWdsuY30V2mGWMll2HJuZ+t8dWF4/\nan+R8UAoMRMbvjsXo6BmW8gTLnw5SipP1uus6vJIa/ptizUt7HMqN68B7HZD\n6ERUeCzNl5165ipo50FNYm3TEA7wlFnPnzOfDkPC7O8xK1m2CXKjvBLso/Ch\nAHja8jEgJB6hxvvKxBBBRBEfOxNM5Vbl5ew1wsRchm7xG6jRGo7BgXZjdjDm\nU6fxwfFqAa/niy0QCmVy0y5VPU9+QGlvDnWSgM8VWNPuj6g2aiFOnLLUSkht\n+iDp\r\n=8Yyi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-00fd3e9-1598814050788_1598814111878_0.7562809614594945","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a75e93c-1598814068384":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a75e93c-1598814068384","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a75e93c-1598814068384","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2d72ea978554b3aae780edb776b40c00f5c2cdd9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a75e93c-1598814068384.tgz","fileCount":7,"integrity":"sha512-pzc9GZ1bW+gYKJYdwiccusijwsUHeD7OUMpOEfAb//tlZEWrGR3sYpMT3M1UOwFioWLg2M8sdXsuEKv1+PRa6A==","signatures":[{"sig":"MEUCIDIyuhjr588EJtYKMDGToeHR6oRw1C82+0anMfFCyQYqAiEA62hQNwMziJaRxRod44579ey71qLUYLr1Q/QfpX8GxJY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/euCRA9TVsSAnZWagAAQyYP/36TkWZf/EoBVVtgTVlf\nHTnjR7kVXJlRGUjT2poottV59jiiZUpF+ZBt/WvijDRB9d6vT+qolGGT6+l4\nsxn6ZbAcu9uW1T804W1naVQYzDq0E42LJYz/eY0xg0nuW/6Epd48I0EmP0gf\nv8meMxEruV5tEJx7asC4pwFvyMKk94EZvDQDrvpq0bNkhoKPT83x4sJ01FfN\nWw7aoV/tDBDnqCxX4teApX0kFgB8AoGV/6UpVSySsLWSYTMs9nFlimJmUz7Q\nW70/iD4mkfbfhw7kbF1vt/QhpVLSQtsjR0N6mRWmjsNN0/qOFHtPTfb0M/Gf\nAqAASROXYP7pYungv25zn+IZHnQrtReucmffjeE4PjbAgzzFKih7L31A3FD/\ngCoOaKBA9lGp9oLhceSdFyDg0CBxCnKwMSRTx1NA+Q3+NaieKowIUsQ8nG6k\nGYOBbPd4fmQ+glixKPYVFXw1bF9icNCGZTR1b2kTsVATRFhFqV2JkhLCfJEQ\nuVgqKYBbrw+EyD6Iwve3XKpnoJtRLpU4xTz32mP64nxEEVN8hnqcz+GrTPyZ\n7/RLfpRxIEJfSjGosGqbTGLdVgIRItZSpHox7NDOnVQbwGyo9uOStCOemA6h\nycVL2pzty/yqq5t4vbtmgrNuQEDRxMFQPda/KQLZ83+cy7KBrZB0XvaeEiE8\nGp+P\r\n=2+Nm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a75e93c-1598814068384_1598814126400_0.6979648830967671","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-898f6b4-1598814018783":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-898f6b4-1598814018783","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-898f6b4-1598814018783","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ef8799a444cec24991777822b5ea77726a87ccc7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-898f6b4-1598814018783.tgz","fileCount":7,"integrity":"sha512-gy67tthIfjk7hWvs3MwjrxcikeHMXGz9wgnshtkt6Ij3L3rdAhf7IwBu9qQbJTaP7MkSn/+O8PvVmwMcp544yQ==","signatures":[{"sig":"MEQCIH5geLcHqO1Be5CsNXIaF01aN4ejd2ho5AlaMi7deBH6AiBLdAUY65rMROAlhUwDawSd3AZpUuNW2Iriov0i3PpRRw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/fvCRA9TVsSAnZWagAA2gsQAJZaGjbJkxfo8GVeNJib\nESu9rZVUXFDiKKlOBhxinVbTtI6z6D0NK4/1WGYCt5DJbwdX1qPCkQEuALYt\n69mZUFwTxi0P3EcmnhbKodDeIsr2p5/d62lDaK1BDUgWt13L/EEhTQsG+BuF\nUJCCtTcJ0qFQ0aDns0fGJ2XZjO3zVSKuIsM672Z/SU/ebA1tl2mBwNZ5qJZw\n2JTdOGGjqYcnMIUYT2wrLKMAh9l60XyJ3vjl0B2g/aG+fN39nhANMol7F6gl\npUUQQ7rptseFHo7bQ5F5PZt1kTa/3Cq1lQS1zfq2BK91UcbcC5yiCMNjENo/\nAccTYb1QbTx6xzSjuK1TQv8/3dvJcfuhmAVs2NbhSNk4zoNkK6XzOdtCCxNq\nGDB7AoWiQKihx/5+53c4jHlVP7PBunKIBRya9g/OSQ1UnHrukmRhmnuexbW9\nz/TB19qxsOgbe6Q9lSynaaClqpbl7gsZe1DAVeO1/Tc3peUj6eZd2peXELqb\nNhIlF1qeZPKsNcDcPHKS2nGoWKdbHTGuv1oUYgWiDFEnp9IkQpS+6lqXd9OT\nuyoSaZb0nP2C6vXDm0H8RuPiIvePQ3GJpNdGkZbgfgdRTD+HMd+Dh90w4taP\nSWZ426eynB/Y09JiiJUHXDAmydJ2MNuikV6AtsM2mx5E0p0Eet6dIdEE193S\nnEkd\r\n=O8wv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-898f6b4-1598814018783_1598814191192_0.03718106793407738","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-4efe7cd-1598814242233":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-4efe7cd-1598814242233","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-4efe7cd-1598814242233","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"75f4af75c77e80799777b3ce4d0d37821c56cb27","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-4efe7cd-1598814242233.tgz","fileCount":7,"integrity":"sha512-V7bdEd5YmIEaQzELhEm3y7sEwP+m6/AtDGVMNj9F/V9aHeyBCVIf2GNpA0OPPa/XL6oy+DAJuk+lz+T5cK6SFA==","signatures":[{"sig":"MEUCIQDlAfVBEHmk3VpUEKUncuItn/dNE7OsF3GNQu2oxqplHQIgHBa86FjfMpHmQnSvFtVPuUra8sG9lrFwar9yuyNeVRo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/hPCRA9TVsSAnZWagAAY+0P/2RHRYA07hKjCtjooKfj\nVMfykG9TYt2oGjdXWWsuyZpam31G4yma6csLnzq+vmGBxKpqeHUor29FC6QF\n+E+3bAdMJ/SG4UyHwy73qQKlTIuvjz6VljlLd8JAwlbClq5uglg4Pf1DuRSY\nc5/QtxzhneNcQfrTdBxgsgU6Fy705Ijlz6hnUvInyDdkvptmT2YEMXlYWG6/\nSMI5BEPTXi5YlydgH84/gm0nilKnTIrNcAiHuq+LI+3ZzTWvAa0Y0Nyg5y9Z\n/3BQsO0xaFjkAtFYV2Mf8wnjxYaa70JNuhiGjrNYNhl+IkgDf7gYVEXGNZtO\n/FZklB2rDOevo3yzIAp0JUFVmlryrrZAj0Lhq94hxe6d+q/SoBeSeCyBjdCp\nkwpE35dOwAvyvbVTIDF3MFWl0Xic8R96LKJsoM6giaMP9hx2dQRXXtdVyQxs\noqtIPDYybJBaNVmMZVRT4TugtqQsOtWm+cAoYRK7QiMRCnaoATcayhzDVaNV\ncz5vochiU2viOkuR/6J5suf3sF06ZB7bmC8MVkzAbAA6yDnWgHzONhaIqMJn\nn/gxvseHZQqhJAcE/EAvKadIlO/RXgNP3R7bwzDITwD/xLt15vY0Tj8MqAB3\nO/vxpWZsJfhQdAplpiV0GO1FyMSzseU5b41IVaQKru7uJZUvCwmjc8Kofl++\nlBs4\r\n=NI/N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-4efe7cd-1598814242233_1598814287099_0.5474159914461401","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e245248-1598814300145":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e245248-1598814300145","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e245248-1598814300145","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d1e47f811d02dbdd577b0c929e6deec5c222ddc0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e245248-1598814300145.tgz","fileCount":7,"integrity":"sha512-rgWDOp5t5eZZlw/mzwTA0mIR5bglsjbNz+8ZbLpoLONHufFQ2vXgVbDgC2I/nQeJ2qqKPjgXole2VTTVqjQqkg==","signatures":[{"sig":"MEQCIBQvufvsKYeV1RXjeQxSbksA5OwuBVBmhtBn4Qh4evuLAiBi1OY/PLEamFU5YnogN9R4aJGSWUt5g0bZZy0CjRndpA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/iNCRA9TVsSAnZWagAASygQAJzoNfZVLvG690GvSl0G\nldg2yNcYgB+ZwT/FrxPh7c8EDCU1YS9OvKto8Di5NpbWx7X1s+U5qqJLhxZb\nFpzndyE0aMoY8YqDT8k6kY6tuqSQkNgkQ98Q9hq5TwRS2QzidOkHcxEsHXYo\n9roOSqIaMdIHjclOCXz0SWBZ95H5It1IJzXD5lfmMNfR3AAwNIuAuaDXd9Rs\nqxQCH9eOqJQ4uInGdYDLIeSKKMiH7bXVkSn3CAuX44LA0SzN/z23ezibRYO4\n/VJo9VI+dWlcs7xCLvCwzWDFVgMw5WH+GR8tr12G54mPnTQaPDpa9sQCxxiM\nBdgOYO5IDJne/nBAuHbdAHaItTozbokDHdcJzyVb6i8sV8o+FuNFor7t1DdA\nU7Ne9Ek0oUgxSMDsLuW37Q9FrYcgiYBghVxg9XJ4pAgB3m8PqPfALUSzahNT\nFTljlG3/YqLMs+lbJCiw+T4N0R6+MfShCsiOXWK8HaDBEBtpiYPYvSEWxz1p\n24l3HINX9x1ogvHJdiGCCsN4DMK1wqf87NSn4h7wPN5O54syIbzjQml0zLtx\nn0Aww1OiXmRngKuq6KaPbtOQS8aTy2wNgafENu8wqfVn/VcsfyptFXMdVKqW\nzFLs01CS2mt8RypAUbT+17eOxAu7j+fyK5dQSV3ZTNtIYbhXek5hz92CtaND\nEFRM\r\n=Gsce\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e245248-1598814300145_1598814348929_0.35840160488983486","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9f2b9c5-1598814370340":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9f2b9c5-1598814370340","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9f2b9c5-1598814370340","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9a395aa0abdb54d8b9912a48032f2087836b03fc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9f2b9c5-1598814370340.tgz","fileCount":7,"integrity":"sha512-2fp8POPOGWrokjTFd8xoJz1fUXG5oMiEHOzPNJWZrJ7iludOnV+vSZ3j7gXAUs9ooAteEOBdwBC0Npi1aBsKcg==","signatures":[{"sig":"MEUCIQDargTIbEzH/gIc4wJVd4W0MMM9ggUsS1jF3OOEdtu0eQIgDuoDzaymy54lEXBlxNtAFz2nLgN+Sfh248pj+BMaUu0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/jWCRA9TVsSAnZWagAAkusP/A7ZsnDu5oTgieLJbJvo\nNOShbVFkgtZFCW4vqP8sdoWOoBF2egWpDbnCj2AIRSy13+cEL9EElz+c9UEO\n1yeY3pLxR54qiOKNgXQJ9E+JbxqvwZYb91x4MXmllpa7DzEGIbZcG8J9jP2n\n8vUXqqoB870m18Kfbe/iw4Wneh+UymKfIK9YkW5JEkxZrAoT0kxdBZ0e+C7q\nKxTSUOQNzWscREl/070/0857daG2j1rGoyaUtuxswIoO+kMwiSPcp2jst/11\noTFs9fnsTzK5xxi5bW2WYP2v3sghBkx2JBky7tXBqRkiO35SG3u60W9YSDdy\nG2KijhE8Q/wUo33ksIY8BwZz+Xb5gl3mIE0KYz3OsRPGxn6c8r2Bu2I/9jZV\niuvSaipp44jpyiPsOEpODD75oABBj9O78BHUg+0PQeCQCfkLaE9RUlBaXDHv\nu+7ZstS9315W2HxiW59DrfJXCAuaDkivwSvcvfeiGJbPmiNzMKh6xJ+YgqGi\nMbVNw30z8yi0Qxf8Tdin8+riJXQ+HlzMTil+z5Ry51twA7wxg0O4tcncRCn6\nJPfzndV5bq6az39iUyP/rXr22C8j5cHw4Ag37NGaQDrkjMN6DUOIo0RdSvRb\nuYsTaMKNgZTJ2pnoMZw0VkRdmdVLwP7zTk+ImqkafSAWhhKOol1p9Ppc+arz\nmyP+\r\n=CYVX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.18.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9f2b9c5-1598814370340_1598814421427_0.08373930598542967","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-91d1219-1598814441744":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-91d1219-1598814441744","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-91d1219-1598814441744","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dc2938dc80fc3e5f2bd406a0d0f791864be3fae6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-91d1219-1598814441744.tgz","fileCount":7,"integrity":"sha512-sA71BSE5J5+JYSGw1KzpVH0M+0VTK+pMRLmtWcg5oNxXhkIOimnbhAeKi/gLuJyol9kYuOjGuSCg7TSA8+U6SA==","signatures":[{"sig":"MEYCIQDmar5hu7hhdBQnTQS2zHmSA8v95pCRSEljyjvTqv36LQIhANbECpJomP34J4BB0KmxzAitb+tggddL8+9HKaI39LCJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/knCRA9TVsSAnZWagAAancP/1hZlrdo9WCS7XNie1fx\ni/xaCu8JG/j8xBSLIHxSdAzQz0zPAWgSAKKHzTR+97iLtM8N51YKOHvL1PpM\nadqsTk8laF/YXh+jl+7K0r60Tgo6d0M7S1DJ2/ljS9ut0vpZFpqmpkxM5jW5\ne2vAw6vjrAg/BQRwslTVFK1Mtn/qzMOVYIsrLKQdxo1tSnonoiCYBtEiATWj\nIfMBxnMk8Cos+6rGAJieONzhLF6guo4AVq1jOB8k4Kr9Txn/WbXYuZiBjqNV\nqTwQmVJXYeSlqKbhwseCv8F2Z7Hws5F3CJTl4q+PzCqUDXWnJVO1GUDMsWzJ\n+PP5hyNdQzsrAfsgXif2YBnDmC58WyYqnKiIb8RAcYhvPWPgwXQSE0vqP5sQ\n6YobzCIMtlCkb2FEQ05xRQiCs0ZvYl9XlsnJlxPiR0eITe1oxwLNv5N/K2wa\nA/QXuAJdXg0O3AG9FN1Bv5iQzRWbOgZSA7Rpm5TTgXuwpx65rGGQhCA1z6qy\nyCqsmhDBu3cwDw/W/eT6ttB1eagP13j/T/SPokTCWIOVYml+Q13O3iMluPQM\nNAgcBwyv4NUsV9nUydVoV81kUkCAhn7zx7IWKC4cSsDXBDQM3tnMY/BVKU//\nDPBcAa8jEd3L0AkO1TOiJuxEr7o2tpk75yg9yRqBjOc56cDaGPSjOZrF1DwX\nWofh\r\n=33c/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.0","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-91d1219-1598814441744_1598814503404_0.5781057178137876","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-60dff67-1598814452451":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-60dff67-1598814452451","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-60dff67-1598814452451","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cb02421f014f7d069b78eef539fa03806b759d28","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-60dff67-1598814452451.tgz","fileCount":7,"integrity":"sha512-Emnj0b+B5jBwyI+l0fiO6bArVd94GbSG1x/bfVsmaHqVeQt1nYDFI9Wr2oGNQfLNjg6/HIZ+8WBo2WnGZbj4gw==","signatures":[{"sig":"MEQCIGxgu/zPCU5H0d3ySXQRxs8sCqaNWfFj17ASwr3xZVFwAiBcoogFcvkQPjcv8uZH/ti2MoMiWXqU71GDl/Tq7ECBnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/k6CRA9TVsSAnZWagAAlIwQAKIu0f/f0egaTs9NpxVA\na6BaV16owThQyJei/mht05ytdfRwRoPHQaovsmRgFwDu3Vdt4Rk8Sqk51G+K\nuIlcR5bID+D1Z33bd9cr3pTQsvQ5WzGBnGvRxKfQsVVWp7/OeLtPxgXLP3sI\n2Ni135yNUd5EL+bNGz/wrHUcjajB9f6vIJUvn4ESlgOhuPcFucR3m/YP6A0f\n0zYDURGQHLPosb8EyzYOAb736ZOdCHA3mmQfdLBCZg7dZTsyaSU61XXnWGmX\nDZgsKWFjKoOd3ZWHTK3d2F6zT+rZY5wQGk6ImJnu+vFh0EmpHSbvDRAmUtO2\n6BVtJvQbF4euGn89iC+OUaJ7zrg28MFjz7rIGsWCqpPPikOJ8jqvEnt4SuAH\nYHDDDKWcMm37fuUJH+iByTucEoys0B00QtYgDp15Dprs2RiwzI+QednGZr+C\nj/TXHini1CqJqsJHuqNxtj+JzGDqfeXZFo/X4XqOeoy1p4aTV27qW/ygbVBs\nr+nostA+m10LDBIu+Tvgkev+nFFTu60rxQ+o2RW8Momc8il/8cMM58y/DJ+k\n1yGaS80E9oKlzGenAtvCtNq5SfoRktRNoqR5IQvWejqOHph37gKq3skX/UXh\nXLbSEvW7A0+DoEQzI11LJOKJebQbzSRlT54QuN8pJ1UQdd5tPQYUdP0Rr6sR\nbnlR\r\n=O+/4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.6","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-60dff67-1598814452451_1598814522432_0.9170943365246296","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1259609-1598814658339":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1259609-1598814658339","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1259609-1598814658339","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc7b2a002abbf0aee93c13a5ef91a80d040cf918","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1259609-1598814658339.tgz","fileCount":7,"integrity":"sha512-mHg6qqIbQ+Govx0qPFS6uBJq3LtRo4NYlNRK4lYFEpunFoxWR1t1/Fr251PxfaUQXs8NzXrES7E5iH/X/SmwSg==","signatures":[{"sig":"MEQCIHJkhiP41EFx3iUKpohoavo+B6wjJmB/YT4oki+6haXpAiB1g7u9qgCFRufWOnPMP24RflvNKzJ8yghoovcGZ+dg3Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/n1CRA9TVsSAnZWagAA8tAQAIj/gf3W7QaOCpb18jbh\nXswzEVvEXMuYQMKvkRa1TlJtykStdFlHR+6MnJf9YF2FRdV7bube+Uw3FbMT\n5EaoPsFKzH7cwvIcxigX5nUFyyBH4dnK3tJ3loZWt5DtMWU5e0jXTaT7f5nA\nsYS6Cgm1tXUMK7hhlfO91TaZ14iwAFPrNW/h/94ZjTdKe2aOoVu9v80YryQh\nKdtV8jDkPeVKnijGissWXLJeZVTFgfFrlfAlZ5MxNf37GCzo6xn4N8RlwK0y\nn0DEx9bedMpBFxiF2s0ySpZGAHLjskeTnfPCULVUap0CbYIRstDhVsBJFhuz\nuvaZGEuQT6q5+a3zAGk95cUteiYyGPEWk12IWiQoZtFo4AlxpCn0JIMef+F8\ntYsuAoQkNZ8VLZppw9XEurMYKawAOnK5lG1rAd+oPKoLVQz/z8OvoD0bJB57\nqF0zuy/1V8LlWB66G38i7H3mBlN7CEP/ifHuvJj/1Qv6vS87LzbAxnXPPAP3\nyFb0U63BbkE5Thi+ABIdn4YFUXMsvAJ1B8We5KG2+DCpab7UuJ7yS8WcvNKL\nELojoS5swItl7G/TW/JqW+gU8Z3l3kBVxXJoByf083mQ6e01v9fd0JF5vkmQ\nxuVPQqGDqxDW78zQl7AuBM1RlCnhbv9mxm1P3/+9Zmrds8TysJYrKWAQ737T\nE5a7\r\n=7V5s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1259609-1598814658339_1598814709508_0.46346562590280915","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b727291-1598814833332":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b727291-1598814833332","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b727291-1598814833332","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f869347567286a8a1daced00210da17909d94303","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b727291-1598814833332.tgz","fileCount":7,"integrity":"sha512-N5HILeiyi1GzKnmyPBKHQKnrdC6Zt8CfqT2ruxGhbp1ZePNHnSTyov5CAgY6uhS4lxDbFeg7iAfdvt3wrsyizw==","signatures":[{"sig":"MEUCIQDnTib/Vlfsl7KYtVSo03ON6uOPkuzQw7XGqj2KkOulkgIgGiecnbuenJzZ2vd/IhLhYdCkZYzOHWuNabAYhSKNQmE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/qpCRA9TVsSAnZWagAATFQP/10d5q5sB0BE6v7jg4f2\nK5DTVPmjLJcI9Za0Aabr0FfysVscYsx6OBcF4z7ShumSSQh8S+3i463eh8zy\nxYiQthZxY3ctw/56Nl+54Xd2NSOTj03QUasE5OKUyaKEj1WgF3kAkHtd+1eL\nyn1g3Gx00SBAkh2iRSv5JPI+E+2JZl/APNNAtxKYQYWrs7yhd2ePKNQHUxHL\n98Bkxw1RSDuGUWTE4kbgTSH43OcNHEggIsTwz68VS6WQm5vXPGvSexMmoV5z\n258wCvmC7AQsmC+uNygfN75biOi6JmyrMaHzDC0Ai1oRKy+cbShPm0t+niZX\njRtrnpK9ubFVAOukdP1yHNkHCUsaGU6Ka/q1ZLiBBn0fj6tf+6tCzrbjMzIf\nZFbC7vRFyTyMVyXiGVp/8ikvoAJ1Ifoms4NNf/QmTTNDtWJcbW9ut5YojGes\nzbSeuVQRZQ3urc2uvXf08ot/RXZR2W8IwoOvVX3fSDu8BJj2eQCWnnvjsQZm\nay4X0vK9zC+LHrrSK7eI6ugu99qxzMr4Ct1UkunxTovLcRFbYSzqjUWkQfO/\np1Gdt236l8MIlNJjUeQzclV3J0eiQVHEV8FCP3oy5Ex2oKgqn/ysVsYWem+W\nOGrVWPs2s02+xa/QoFL4aQiQKH4oLFPMDc7XHMJboIP1s1zaCMrxDd6Csvl7\nzain\r\n=1tZc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.10","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b727291-1598814833332_1598814889237_0.3160664471008714","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-93368f9-1598968508523":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-93368f9-1598968508523","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-93368f9-1598968508523","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b62ab5987c5a4b6b59dab0a268e57cfc086f850c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-93368f9-1598968508523.tgz","fileCount":7,"integrity":"sha512-Di57cqZyOp1ZOHwJw4nFNfTvc3AAK365/UHvbivf8S6mkUMHLLmb6ePx+1EQi5Mm1sBKCwwTKMmYTfpeUgYYpg==","signatures":[{"sig":"MEYCIQDknkMiKYda+ovPQTnbLA+9Ag9WUHiyWayrVFaoHwJTlgIhANnB3d/CqorcuywjBeyMXItsdFLUuDL8KD7mKrOXO1VE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTlL1CRA9TVsSAnZWagAAdFwP/1h0FndIMgRDzUAPz6cD\nQs5PAWbFIwyU1FBxwR+cXzmHcO5KTTDMaHqHAc4URbeZsyGkhY18j60o5ZGD\nvPbI4su6EnDz2S93j+9221YwQBO+ZTYg4jlMNwVLXSMt1t5qpng+UWV6FD+P\nVHB8N3XmduzHSMfog6a2+2qkKuAB5CWVwUuVoI01jGM4aeHU4p40CTTLjnQE\nHyL94Q4ptDHCH7JzAkM52QCpxz8lz8FRncAJzJD6V7opQTOIXCIjIM8RbEtk\nVwTTCK2PJHm5YTnoU4Mp4rAM+GkD0ml3Du1AKoaazsGV81Lr3MNgFaMNEA+7\nsmb/NHbK8m55/yjfOw+LoN74iW+VCOVwx8DKqOhHa43y3yEXiVDb9J7+V0NZ\n3sDYngv6yDBiSyYbnz7fZM5E0iXKyJqo8dHKfrAwOOKJa9mJDFzE4W/owpku\n6AV6GpuvpDe+RgaPujlqkcQBMBYR0n10/cwBxomk9OYlxtv0aHT96eWGAuZS\n7vk5mwQ3bm8BdGVwOHVIAL60Lxj0J6io1g77Q1Qqja/6ag8XdmsjhHb0fD44\nb78bkyX3WJFjf3H8L8F0/UE0yFYX2LNdJTlzitlIK55CBNamN/AQd/g/Fz20\nE6VcHhGljXejNzBa+Vu5gVmlXjGk7DmxDcPahJpw6gLgVnf5wQ6Qsk6xPWGZ\nYC0t\r\n=a/Vc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-93368f9-1598968508523_1598968565324_0.7431094776466023","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-93368f9-1598968509830":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-93368f9-1598968509830","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-93368f9-1598968509830","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"545448eed8299152f39c17095fe22e417537959f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-93368f9-1598968509830.tgz","fileCount":7,"integrity":"sha512-tYjzELuKCUqqHeD9Y44IBd+xTqyoZlokHcKIhAa9kvBOIoAO9xthEDJ3N1j6qhXQPjTxc75yoWEqGfnALhGRVA==","signatures":[{"sig":"MEYCIQCXyl7V11wtYFShClwI1mO4FfwtCvJmILT+UN/H2bYeCgIhAJjiK2auHawyIcSPqLpV+yhkuRp86nDeA0/D515fHe9d","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTlL+CRA9TVsSAnZWagAAmBcP/iCIQdVGk5PehPpCtl+E\n/qSa11Vtm4RzhhYgQ7ZCTx32Omto7DnUjWet41P77ZGsL0W6tvIWOdR8tNno\nnu+fQkRnSLI63pLsMXJgPgeBYpxqSIqyhM6uD5yz4h2JXi4250IRRrN0mctf\nNSxz/81ok9Fu71D3GjCYlzCb4Wj7XUcD1djyg30VHZbJdc967qBQ5rD+ySn8\nFuouuwkE99SODr4iVYKhqxfERjGYXAIUtcaXA8uNh62hakRSMjuNVw6J5Vwe\nrlvelGQmXPiC6Bdc5gCbkTxhLOaVqaUHqEpCmGeDTZEhFtO8rorihbYbmJnj\nlOCxIbjefoJGAmaYo/q1yFcOdTC9whYzLBb8uc1J+LH50f/TgOExK47kAilW\n2qCY1OiN2Ne/JHkf+/asDqIwKZFecjhVgcDGp+D1JHLKMz877PeG8btfwNu5\nME/5XQ9Z3gZF4w/gV/bTVFElRZPhgNWXBFyarwIm9Q/bePHdMwg8s+JTtUm0\n0teJOQZPdTf3duhikjWbToAU7pBRYu+SVKZGQOiMilIS6xQH5bCXL5q5XMkd\nT0MIDjRJu8KnmA7ZC8hWq9gtugs23zBiS2ZZ+cskJ//+foXWIJW+LURduts7\na6XJPPAW88iirCYFqBPdGWkwfcQIdYh9HD+gzgssuY2vx2HNcM2FQtelKpUm\n96Nk\r\n=5rky\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.7.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-93368f9-1598968509830_1598968573856_0.18287049673804612","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-179958d-1598975322761":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-179958d-1598975322761","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-179958d-1598975322761","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"064742989b66b4088f8377f7609bbc70a508f356","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-179958d-1598975322761.tgz","fileCount":7,"integrity":"sha512-povvqkc+9bgueXQP7N0oNmJZ8NduDLacESDwQVUgZuW9hWscxW4bATV5lFFhVFrBhPaJ22aG+o55/2AMMBQVKQ==","signatures":[{"sig":"MEUCIDe2KjmIYqrmgenk4bXV4kYiYKm90TYommAsZEc8NwKQAiEArYyOlo3pbiw6Gzu6dvuMO/oVMhKs6UXChY2nSx9MoJs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTm2JCRA9TVsSAnZWagAAhKYP/3KaBQJGvNu0t1lyVmoP\nirt3pMfcavzQEJd/2WHwpQZ51PCtJ4o8S4fGdix87uHmeupOIt+wDuCl8QHo\nDvHqi8YXespWohDjHjEYwWkJxK00PHCzKt7teaBvAaE7z5ZYjmXHiOHSlIAq\n3ckDwn6m85PtZJYqXtjIRKivNDNm9Xx+CCGvlg6fREpFqVtKo86/yOjVr3OI\nKw0jTLmDe3fF89lejMwZF2d1GW3XhRW3GyZlQ+W/iUNKfpQvJCJ/jeU8uiwd\niXz01CtCSwebKQgLu2BgWB686SAICQ8carfW2P0LvufXAgYz47Z9BLMx+ZGw\ndy115N3qMosSxRTCxTUDXykJYETXR68G9tXSh4LOV5jLpi2NsfQ/c5lvxny3\nR66jX1DWUffYxEkn7P92wYuNnMqu99OMrdyi9tAnoEHVPVmJvuFPoO7l9dPe\nGFOoBVfepUqEoFEi6eD8tuvt8i+zg0Kf1ACWAZH92hBnWABXtfkNHNpoHjce\n1BInta32oEzKuerO5rCy6A9sToqn11rxKcftCKKE7YyckKvWziOSWVv8cyBR\nEpuEpagxPE5jHOqH2b0UQ2Eq/C19fWzhyWf4LGiPnWaoJ7FddVVtxo/hk5Jc\nKAgnMcT9rsMbS48QKYoL1D3TODNSMyxEjLkqEuhZzOAhaWZSiB1wmz5NMyqY\n0Uok\r\n=SNe0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-179958d-1598975322761_1598975368948_0.41163999730535883","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-179958d-1598975321633":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-179958d-1598975321633","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-179958d-1598975321633","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f39b721957630b4569c071bc4aef872c18d917db","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-179958d-1598975321633.tgz","fileCount":7,"integrity":"sha512-SxB61E/AjH/i3He/NiXbCAMyZGObV8Xh3NasoVHIhjHuowXtTi7ARAdX5Hjp3nuY0RDtVKxxbUaWNnWq5/hFDQ==","signatures":[{"sig":"MEQCIFksKCyq4AV5KesZhfOoxS0xQpk2oMNsiG61W5yUozdpAiBsodz7YK9iD3EoZXEwtIzkiJk7t/jfHibFEo7k7QBQxA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTm2NCRA9TVsSAnZWagAAQfoQAIM1mVXkKo/wI7Jm1gS2\nLXV0AUn8V1TzrT/YW3+V8+o3NyV6stJqebVK5qF0dwrDS0zpxzTEh0ogzlZc\ni1PZPOfSQVEQ3T1q7KPQ1ViNiLPBrg7w0WEySnUgNq6AASxoH58wICPOsSxe\ntE3LsJi4IiwVnWZ5u0TtV/CpyTnShchJXP7zUM+kxeSwrPBRWeR4n+h5sBOf\n/NhR81YmSVGuLHMAuVWy2eVZIFhxM8VXGrPuuVjMccGTsq8XbUjZDQx8i42F\nZU73zpBk9jQiF2GYLPZO99TxCaa5JnMeMT/VjmdaGq/bPkFoWuYjQpwudBdl\nn40CulVjxpRkU1FfeapnBU3bj76Svvcy9dy7WAME1SjkRwhi1yvBkBKCuc/t\nYhup41JyLvx8+CeJxtnoxnu0e+E51WOlJbEtbegS0cc1Q6gd2fFIQlIVCKAb\nvr1iDJeaIhcoQScs0SnNW0MS5Pw+kqThOHXabEIlcEWVz5rhKw3npNRx0AjC\ngSGJy0uN8AGaSCW2pxJcSZraLrbc/v/GR2jsMzMj9ZCZmtldrSF9fX5a9wWU\n86aFBd8RkgMHavG+QPyztytr0XwKt6EYZ4e4S8UB7/Gf23iohgpCz90zgjh7\nxMSF/kKFEKtDafPFiC0fINwWmDypbqDa2mwmenpPK735i7bby8njyVQzxtK8\njOQ6\r\n=ujot\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.8","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-179958d-1598975321633_1598975372927_0.5724087784081993","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-20ea584-1599031353261":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-20ea584-1599031353261","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-20ea584-1599031353261","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"aae4a2f55af76d809bcbd6791cfb6fb0a919f7f3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-20ea584-1599031353261.tgz","fileCount":7,"integrity":"sha512-/eyuBdg1x7Gibf/CtOVjgnq+6A/j3qVP7CWgOjL1DyM1dLEsR2PVwWokm4HOIdLU3Uun8TaFns0RT8msK9kxpg==","signatures":[{"sig":"MEQCIDdLjcEEMDXq4KRaErfoGO3vzLqN8jTHYbTIOrJ7o49sAiBzg8LWmox4BebT6XDmRfTlQyfECrVOWXXKIMNcbHQRyw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT0hzCRA9TVsSAnZWagAAYQ4P/0pAc9WZnpkGPJMDPthw\nacIYDXOLLxUrgkAw++3XrKl7dZwkth2gngE476RsB0mr0Rup3iAacvCUGQ1/\n/iFM3/qXo8STKmn3vaY1V8XpRWCIgHS954K5hOZppgVI1kgjBMBCtKcF6cVN\ne4eCrLGtkfpjke7OQVxELE/hcAB6M9PIp5R3S6q1NeupwgveXAaebFjPekRR\nK0NBfNs2ciaWQfeaDcOYr6SSq4i+ejKXrANvcDWMf2JPfCd5IDiGoaYCgLyV\nfycx2oDbFPTZZy4unCEVOD1j7wPARGhKWMHDNduauq8JeUwWbFjIxtjQx7Q3\nWaf3OXBBoSLv9UJxtOwz4KTh9nUO5dhIdmysmdaDifvJNnpFHf5Spd5zgVue\nS3P9hVXi2GWPPbURu4E3l369mGIqsW+v9Xp1OAS/R8RSd1ZYxmm78zumkEw8\nj6xpIQZKerU/fArs6NyVAU/QmzHhgpFEdvYzIuftckh3dFQvviVUVfQG8Uyd\nLs0yYmQ7NdtDOFsmKOgTUNoFgM2NIMWqjjWRaFWul/NFYpMN2WOP2J8ZW7SX\nKyIMPvbD//kVlFSNTe+tl52We1IFuPu5bG/cR3ODNZLSPsJR3Zn4+lrrLXoc\n5gm13EKo1zOuXTxTwnMau5FN39nceQjx/J/J6WgTiqSnyisx1LAfcj5GWuri\nP8a6\r\n=RKGb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-20ea584-1599031353261_1599031410583_0.5240755503969632","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-20ea584-1599031353802":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-20ea584-1599031353802","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-20ea584-1599031353802","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5d35399c734480c025935863d863f54ef191caaf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-20ea584-1599031353802.tgz","fileCount":7,"integrity":"sha512-qpN9Gtr95bo3f7U5jQJLedkCjdZBv2jCXWpIIJOwZ5QXo9Hu1gOHGhGqX8Mx8X3OrO8Gcy0bnYFEsUsc7C4hyQ==","signatures":[{"sig":"MEYCIQC2wH1zYeGcv4DiEGi8szwXSTxZ1xLo0Cb7IYcsaQR/QAIhAOwke3/+eRgLZvtvt9uGkHOUlnnorNAUzLyDYH2Io5uF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT0iECRA9TVsSAnZWagAABX0P+wbb9QjrP3laRgnngzgp\nfeIEC24hF6p3CPOEbDxPavC0OgthnolAqf/nX0pntnxYbzlShJbj3XhjWBsq\n5u3OaOGaHna9THwqMxxOrQ+MvUWrqudU5qPwW+Hvvu3KPtK12d0uXhATXIsG\nxFONyIKAzgWlCuMZLw4XGw1th70efZHw+BxbZFJhIZ7YSOBxF32q4Nw966Dw\nUpLQofMc3kfV2bYn/EcrJ56+pH/LgsrSMy07dK1DY50Q7smnAQBmBuSJs6ZN\nbWtJnPeCWQAWJFWDUQAlCFyyb3wnE+yXI3+g0eTrdAv1b12uHuml7CiOHdn5\nqn5MSlrbLdzAI8AoNSFnsucDNf08se6S1rob9nVMRX55oMP0HSypekb2bcVg\nLPe69wOcLsZBeW5z11UzMwOAXyRe7BpeIlmgdoU6d4pntU5ncgnWMTveZhh8\nyivmzxhQjFw4e8thLHmEn//7J51Xtg7QBPTNSCr9r8er2fTFosLUuwmmnU8t\ndsqJSGuKF20kiUOIGJYVqKKjcQ5pBvqXlJZ7RoQIP74xotTrVNK2ITyGYtTZ\n7PuqZYE3ne6qOrgXBKsyYauPL7MYMLJeSu/M7rZJumMmNobI2d/mzRElt+Xg\n8w4K6WkgDR68f69pYA5q6lELNN2Y02fK8EzbfpkN7WJ/sNrwbor9n3eTcTEE\nu1dH\r\n=l4cs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-20ea584-1599031353802_1599031427741_0.39223973710016935","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7873fe6-1599035636524":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7873fe6-1599035636524","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7873fe6-1599035636524","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cb7a11dd90fa684b9e0f2d6ae36a113e530b2d66","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7873fe6-1599035636524.tgz","fileCount":7,"integrity":"sha512-XQuqENP+kZpJjuGoD1sZ7Jztya++IPhUX5U0a8OLDy8TiTx/lIbhfHEt91WKXNKYIAVynF/mB52B5unC5hW+3g==","signatures":[{"sig":"MEQCIEEU+AIRD04b8sSGvmCstiO6ZL23Z5PzANeoIGVn1Or8AiAEvL2hJ83YJLoiRgsJgtsnOsMjt6B1TupuN5TRarIggQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT1lcCRA9TVsSAnZWagAAmFQP/19/dY/3w+viX7ruo7j4\nDpSLTy0bUO/7zg0GHXI9MODl+pslKlbgmmlBDZhW4KSsJKnd7cp8asAgZgSM\nWQFeQWKsfNAnRhb3jx4WEVC/dRuUUiUYOw4OhRfUgnjocg5jQOZMog/9iAO0\nKCYirqqCAHF6RmsEHbURMeV87RDawlPFde/yCyoWf1isQ7vf7jLRj4bENZt3\nfIpyXR0PjiTzyj8iq4FFSWE3G8/rLo0hwmQi/deYLPq8oxgUiVv0i90Gxt+T\n2A3n/KIVbc3yoVZTz+HhSWitPkEqj4wZLlb6CSXQemMauBHy0TwmuL+vewLA\nVz4pARCsv77E5eRppJdS5du524dv8umZFa+MiHN0OH+jos7yWnFkdzLCKTLL\noKzGMDfLRZ7xmlzNcY4OEgt3nP35QmK+v1m0e8oKN76doZ4xJ/2fOnfVzn7P\nUj7zkqUG249ga4sHIjWALqOsEjPJEwRU66ZPnOmQFReZhVfUzG/fxjBI4jSs\nzAMLk6AgDRyV05ZyYDWHVJonVnlQqpVVqK7K8srnEjlL0UN2mQ6/gzGdc25o\nCy+CAz3kd7VIcVxPSs1Gj8GurYoeeroqlxYM6uXoz+8qlz6bTeNzBwKWGXnW\n7XjowMJIXmoBhBDBeytAV8Gt29/H5P+nKCVOEew1ecprFLuYUlQQkUw/jAtQ\naDrm\r\n=k3ut\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7873fe6-1599035636524_1599035740032_0.6313870044560967","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fecb9f9-1599035863913":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fecb9f9-1599035863913","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fecb9f9-1599035863913","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"04643b43fa20bd548858539d2f3fc8689f087413","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fecb9f9-1599035863913.tgz","fileCount":7,"integrity":"sha512-v+hGyDa3SmMlajpk/8jdwTd1lWCTLi7HGiR4YwDuydrEu3kfNSw1jQju0A0EKSyUZQMbw40MGFMs89DGI5Qz6Q==","signatures":[{"sig":"MEUCIQDzxyl8/6nGQ+wsivh1YWKc7me4kO8g1If4VjTtIHrDJAIgYQ/wAt2Z2iedXnOT1XjMfmKGWY+DqcQc9RQmdpjkP8g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT1oCCRA9TVsSAnZWagAAxVYQAJ2UTUqCFZG7NnY1yUHc\nweQPuXHxrKSC07mjP8Y5beCs0MseK1zI6xQZLGVhwykBrVwDmwkzvROMfnl3\ngBvIaASuShrBEkuZ0yyQUckLdLVFnMX19Elm0uk7N+g1qq64+whLrV6D4LJJ\na+jVAc+T6J/2nt0ASWjZ7KjQUd4ozUwlTSkhijYOnOEr5D5ARhBNRR4kgS45\n8qnnoW2TABqX64ANK4+iha2IUBhSx/4d1vZGbSjLtAS5kk3X6ONM20z1nTML\n6+JhqlrH4X3dSEwtgNqaHwqSi4S5XtNxBKxwGJo6Qu5JEuekmeTyS8pUvzvD\nCCBJudzkjYwtKUqUZ76WXq3rhC3LTThyZ0aj9uFFJtdpYdZdmsp3OzWoZhAQ\ncJJ8qR2rT3g2FyyrzTUpouavNZW5sie2hgxqBAVVqm26bjcVBDfYjgQbR2jN\n98fNqt6sYQzuRzFV2BNbit0jff5GsfOvmlDa5PsE/UAmBIYdNtynJFeJP/NU\nkQLQ+uH8q/EuL+F+7G2Ra6V4TjIYswMINguPLVNO7mREw1g3ZwLWqjaBlnSk\nIQFdzRbdEqUvmCwsw/GIUODKUGvEH+hGtoJLapn9HAAcVFZItz5D9N32vdBP\nwvjH8rl2lr+AGKKuAHx4VIEXU2/FgdBLJhPOuSigURL6u0nc9RBHPo2NuoIq\n9dMS\r\n=IEmL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fecb9f9-1599035863913_1599035905778_0.5715797861099301","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6c430a7-1599067321261":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6c430a7-1599067321261","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6c430a7-1599067321261","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b01423a57878664da771e3895c34b13a811ae182","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6c430a7-1599067321261.tgz","fileCount":7,"integrity":"sha512-9OLnpeS/XfRIJXs8Ixud944FNvsLyBzLPGIwMYzGUfNB+oyXmwtQbYH4mZjdca/XCBuP7+aQLYz1MYNkVPJc0w==","signatures":[{"sig":"MEUCIEGXaB4Ij4QMvgfI633ZCF9u1vNvIDSQX2wZFKnnWqiLAiEAnOxYkazxVRFUOmv9muPKUgD2qjEzmPEfbVeRoep3xO8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT9TqCRA9TVsSAnZWagAAN00P/R6Z58ai4934mvpaDc4R\n6AYIGYPwQDgHqidH7V7qss6pvjq43/Gy65+EdWd/tywtcnl/Ax7ew+RhlDz3\nBmvT7SsW0NxS7cVDWJUz/DUpPUkE72xApxVYXsV/0ANCNIysBVJlJHrG1o/f\nWBJQxzpllMFF1B3tKLVyhFtIEFLe+qsj2cvmrnuMcn/7yEKj33FgzZrErQY7\nH05fH2WaQJCRsYpUJEv1l9fd5XlzH7TRPyGXfL6ZDa1ubUBLqZoxGzjNW3Ej\nPRRuBx8MIMQh3CwDWlsvwZU8ouZ2WM89fHjf5mx91pipQxbAszhxYhWz0alH\n862eSEsQFuJc79Pk3SOvJiJM6muY4MYWkKWuO/IDft8nD9fPPC2D2HQL/zJQ\noVKifzVc18H+hLZTUEd0+uT4q1TVYERWnDBjmvwX6C3xaWWZ9v6zbnENGCpw\nuYdSaJFU3CD02xEXNqC3bwHesTGayQkm4YJUHvMfLjhN0pcM4rxZazfcG2sr\neZZELBl0vqdD2tulE5/VSxE9y01mUGgG/km9Tx3AIvtR9hIMmlixLis/64CU\nd9yOf8akxmGDCkN3P8EcQbf4IXB4P60OO8YP8nLiBYXFTuG9zD4vkDWU/ogH\n/x8OPQ+t3xVkIyhoi9WThbP6KwCmQzQ5gIIuNpZcdF1AECeoX/GpdogNv0ON\n2mjB\r\n=UCzt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6c430a7-1599067321261_1599067370285_0.784475473972206","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6c430a7-1599067324562":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6c430a7-1599067324562","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6c430a7-1599067324562","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fcddb34c618b5207142d01aaf5f1a25c042ea8e6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6c430a7-1599067324562.tgz","fileCount":7,"integrity":"sha512-2M4gy9hFQderc8O4P40movXru0Ft0xr+EGhoxQ5dzIBWbKb320v7J6O1k+9ybtwEnkk8wxWNKPhFMmCVSSSvsw==","signatures":[{"sig":"MEUCICIcB1WBKXzEOxc6lYxG7lGa22XRXIDI2AuI/E1jqX0fAiEAsbWTBMD7z4D5KhqqZGPc8F0HA95Qvemj4J7Wk5pYq6Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT9TyCRA9TVsSAnZWagAAa/gP/jdPHgXMw/V54/nG00z6\ns/c01Prpnlx+PGphK3bnxp0lDEE2D3/a2YsZJEvL64TmKPftby8D1Hd2H/z9\njp9N/dRoZiknd3Qy01Yw+0CxIDJAXI6VDLCnrx4YXamPnVqw84e+kj+YGvxt\ntJvvVTIlA37Nsa8CS8PfY5ew+PsIa3TWyW3y7qA/3zMzGQagbjm0yUkXU3HD\nIluuzPm4jE66aRKhLocHVwgbC6NHSlPoLdpmGmQDLrwvpgEie7X3zWEXEtNv\ns63A/XnBSkXUmWGSDEtwxx2KJ2pZ/9z7cxvdG6adJCwlaxBRAlv4CC9ouJ2d\nuu8dzXZ1MkYrYCoNFvw18G0QYVPzqJ6SL7J9Cef9B3DzfMXz6AYtsK7Sl08l\ndPf3AIiw8yMKaccyQxScS/34ypbYc+qfV8iGnBRKYz0P8OPwi3m+X3YOI84X\nLOAlzLxm8wRe73vMMo/6BJwFhxN0YI1lt2fkTQ5YEQfDkZecuRDORO6iHqTR\n5mUKmArzy3punPHklEIGH9mHca63dcohGMItBHVs3tbju3grEJyXwksCf7G+\nYuSr+E2B1ZqhJC8dBvunDAtEDzoss4IExrzncGA5xhysVpSqAAqIhKhIJpcE\npVrcj5qIUpNkJx+eK3Wt+UMIvtAdHutec/sa/nqBVYa8MTHL+ybZ2aXWVmC8\nFNzV\r\n=fLkN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.12","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6c430a7-1599067324562_1599067377691_0.5791901772765939","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-48cf9e2-1599145708326":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-48cf9e2-1599145708326","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-48cf9e2-1599145708326","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9feaf219d51876b1e59ce30018544e34d6925c8b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-48cf9e2-1599145708326.tgz","fileCount":7,"integrity":"sha512-KAIqthR3Q9Z2tPMwJ1ajxiAPlmCzS4qQyHpf60Ku9DDYZQMJSozE9jWaNaPzWywDbUKT5Mhaz5nCtRs/3uAIgA==","signatures":[{"sig":"MEYCIQC/qxDzKZqeL+/q43QI0Ykfn9aO6zsUgzlLUhIMtwqP9gIhALtSIbISP0GV4/wbiywZ3Qb51WxVCneZFtHIWmWJfzkM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUQciCRA9TVsSAnZWagAAq5MP/2iF7QwER/GMyfZxdpJM\n/Q9rJWCfNe8h4Na9HpRUMLxoE+w1h07VXlyyxpsB86npHFWROS7mY8UPliOh\nTwWFEKEhDDRnk4pjS+7mRcbF8LLzFfIMRlATc28m1dlwdcRVbaKv9geaIN7h\nRBEV01vSDqJPryD821J9dgRioRwVe/v5gqCWOOWoh+sC2kJwGwJ3tFnCaDOA\npnlAAN/BLdjA/SCHtGKjTqEEK3BvMCguH8Jawq9j6iKgzpzPye2/jsHU5uv5\nhJY9GT8MhriEFoe2SzYFT9hD0bw2u4wXBvvJ7WtEp1vJ7etNvS3+EgD05HQh\n9NYHJM5LGimCNeZ1bm0m7n8MxEhuuSQOXqD1h+TUoORG5iI1AziNHlSsrgUL\nfHiRBn2CmSqWk4dOf6r6Zi40LcDibJ3/CNhZTOlyicT/esyjlQQQaIxOUfuY\n6Z+OuIE/Rc2XQ92kXkEwIabCvzsXTtQ98x5haaFrkuZG8PDQSps+0lj4fjHs\nFi1pVAiUjZksUnxyTAYzR9o/tGSmQXg2Gn90cs19ZWgFN1T/734eohBYjfa4\nlLihqVjLJbWhgZVEGFjXVPXu2hzg/5lSCyZCKOxYW/GO03lrAbapWmsWPxpp\nxNNWlOcxdap85thtrIsINOb+9UBIJCtPZQJNY0YJl7oxkijGZU8d1Ye3FMDQ\n6X7s\r\n=pF30\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-48cf9e2-1599145708326_1599145762063_0.5686095009468193","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-48cf9e2-1599145712094":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-48cf9e2-1599145712094","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-48cf9e2-1599145712094","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"adfc673a67f65168b9fe74d0cd3a201505e9da94","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-48cf9e2-1599145712094.tgz","fileCount":7,"integrity":"sha512-dBVjLe/KY7FkSA0IRuUyIaiAHI42vxcKwplCePtLCXzxhi7HeRWBuctxCKgi2XwS7c8DCKROGn3/gbazOjYSDQ==","signatures":[{"sig":"MEUCIQDex/ic073WlSiQ3gjs61rFsBMeQ0yFHJZmXd/BBj3tIgIgfmAieTWy5RgPExgN1qhi1JCuNr3eTWmftnFOgkQH70I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUQczCRA9TVsSAnZWagAA3t4QAI8CwpeYE09yGMXEvhJI\nQZqTBOXitNSoEPBM/FvaDaI8i69Q2IN+Qtn0mgrSIBwFAdMrU/RNkMsBxSp2\nOOQelPxcczDxiSOQeBr5XBZNrl3YIjqYcRGtMXBCxoQtYRs/lVYgAb1se06O\nwnKK6UFaurrlQiWlpbxwo+44Ni+Mh2xKhgaFsIcq6+aoqCpk9rwSkU6gBpta\nnd4aJES69YoP+WWJG0EIEfqOJsLb959q0TuLjucDO9sonQ3txQa2O8OlEmZE\nHdEe/0vqENriDpeQ5HlCGNAGKxzEnwqBChmOcJf28hTqS6lzNoIC/HbhTfz5\nz1+lCWJfmHW9IA33VoHI2xumwPG/X5lMgoTWyD26xTVfbD249V5GoWroSWOJ\n9v8cWpRc+XCVPIrMR6F2r0f91urXgOL5Q3H+5qpZxFdl/XiAIzHt2HKg1b8A\nZoyXG/POm5eYujykkwPteaK0cokGeAGccSsilif/46RY1T10RjRagqNIVD56\n46xrUEMizk+E7bV1erU1vQGu3YAN6+2giuLLpgHl+WXCfI5ua/5LnbDD+dfJ\n9+2dggVCNTAUvqyeOxGgAh+fqysMQac0Bl1ySyefkOwk2xKtLnDnE6UYq38G\nsTXXtykn9ImuTas6BUUB/wthAq4w34dfFbGUr/w6ZZLoRPVVKCcHcrEfUTFB\nu69h\r\n=getZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-48cf9e2-1599145712094_1599145779422_0.9192593312324606","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-4eddecb-1599146632825":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-4eddecb-1599146632825","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-4eddecb-1599146632825","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"732d3c70f5e001da0bda0dde878a8c14cdde4c51","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-4eddecb-1599146632825.tgz","fileCount":7,"integrity":"sha512-OZ51sRaAIwems57EgtnT8gzJXiHd4LCq/VWJfzCoNN7D6LXlCyxEGivhq7gUwE0D+vsFUXsOAdMjxRR0ZoSwsg==","signatures":[{"sig":"MEQCIGxmMd1EswZ49pZmBRPb11H6y3IZrqt7rH2cw6mps788AiALqsvxEM/kTLlcHCVr2tq2k4+ajt0LNSKDvS/65AGS8g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUQq5CRA9TVsSAnZWagAAJlAQAIf59CFeCphuaIabD8/u\n0ar7NM7phcxqyhNUMM0gTOmr9H18qAaf9xGPyxS8Pddih7BN3AsHiqRmOpk7\nwAeg9pWf/OQgnBeaefROWnvfOzsLRa3BzBrjy9XQySUXHx5F4F83mDJTvJis\n+X3SHWk5L1hA1C/nQEdpQ/IkDidOJXH8D30NW3IOMLva6bmF7yTVkhKR51BZ\nEu6O6swx6Z/ZcThaTIURv6pJSCVYfPaSMhk1enuNhh1IjW5A+lmUTjp+jtfn\nmwztAt3GY1px4s1O5IvhoSHCSpWYUr0J6zjqxxMB+E/QwlQno5qf1gn0MO9z\nYmLUQlGTgG4wdHk/vDRa1YTL1W3y5vQxhOE0HBC3szQ4PO8bFda8dqRHavl5\nDwqzr4HcdAuAZrOOoLeOEcXmTHlKBY6mef/6R6zYRFW0spY7zyoLmEbS1NV2\nI0LsL2tYmP+nYm5WTpGbJp9vvxuRcyrAOLrlC8o85ZudMnYxWZDPfm/mxUxJ\nzdCcqWhdXBwy+L4KYQy979a2+f/RoMj8DOXFhxLwPt+/eQirIfIN7ft6YQa5\nBfI+N+OcYHENYutvW+jJPd2yp2hkWGg/2daEjgnmS+0IWsWh16QKWl72MPYD\n8ne3jtAGM7gGMmlvYERpwWI3b7A1wrz2/kuRV6vS58LHDX8mWf5UMnh4TCfI\nE43z\r\n=98Hc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.1","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-4eddecb-1599146632825_1599146681402_0.08522560511253507","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cfe90b1-1599330101855":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cfe90b1-1599330101855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cfe90b1-1599330101855","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"50baf4844729ca80517742d18545873542b4c34a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cfe90b1-1599330101855.tgz","fileCount":7,"integrity":"sha512-s3lCm5uZmCwZK/nfvuSpZsH3axmPcbFRH9txv/U/clQ4id6NvQxx+aM/7shnDCbtDb8N4XtJ/mD6U6ZNT9XU0A==","signatures":[{"sig":"MEUCIDhIQeCw5vfaaqO1nmOXfVelCoNoaC6YI2ppUAamn+Y3AiEAvKx2f8rjrY22o5vuYnsR3MhtNVPVg0kc3syHcGbfpX4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU9dnCRA9TVsSAnZWagAAey0P+gJwqi8fqfiV/AOBRWCW\nfF+VCI8ifsHkSBbX7x5xoxlJqzc3unqtksJTgSi8G5rCv525u9MtHxu2d1hL\ntmC+NTOUEepNYEz4L276oM0g+lN5u+58gAwkPQcBprgDTp3n+wxbhmb74IzF\nRwXsat1WsHbM/9DyZaMfEVMa5gjJWG8frkJ+NMOLzerWK1oGU6tNmrdi3Lvu\nkUroXSNnhtSL9QZkMwuUqKsdEcXUee1j5gm+wIYH5RoRLHuvA+42wpmy4yhf\n2lr/AYTJ6L/Rs3nNPjMHNKUfIwgCs01G9lS65u0vhLYQsZvx0R+7VelPeUvK\nhZAhDQPDdfwvlUoAzahfSTZ7FXP1ryg7V8Sd0l9sWrmUKiTIYSIJlsaLIWeJ\nN/yptrE1bPnhDjvHaDGrW+97dKyaaalJP3QC/gJSUmQ50qmmx+EnSKjFpLux\nfBaPqdkQxx/7qzYSJ6oEk8K//CPzHloV/LzSyIf/A0rKT1zHeRu0pRDZgXXI\ne2CGqxCUIaYE1olfmYh/Fb8++N94BPYx8cfo5yID2/QK+FcdkyfzcaldBmXc\nTPBA2KXpcC4Vf8sSHt3mzL++dx1wvFmGo9KxUf3SDhWRXMhXxArTe3MMhJ2N\nCKOSYaEAbKM4jESGmy4DzRGUHBTaEVQaQzlDfuWgNiiT/CvghcV6HfLqpqOi\nI+lf\r\n=+zqY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cfe90b1-1599330101855_1599330150720_0.5651143421106861","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cfe90b1-1599330108663":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cfe90b1-1599330108663","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cfe90b1-1599330108663","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"964d5f70769bca11d7c8e26a8b629b67c9a99685","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cfe90b1-1599330108663.tgz","fileCount":7,"integrity":"sha512-nPlDQBEHNm9vjtRsv7DUNQE7CLtb5L+0XrDa/oGb7YcFp/QBT6O1HVEQznftS6SXTnoHFDB3FcR7QlS9NQZpVA==","signatures":[{"sig":"MEUCIF9mFM/v61rK6X6cSLDUnAUv0Ab5i24U8VFy/PCsbZsyAiEAsAvW2nbaJlDnAWnaEj1FQ5WNar+9aGw8trXZGdkKDTg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU9dyCRA9TVsSAnZWagAAXGMQAJrCfTGGDZ+CaS1NDK3w\nwFjdYDvCMVQzNJnm6oTqFbw+TWWS3nrY6d0QxY/gRK4kCVXZlHErWsrSTGID\nvi3VmPJ3NMjV8hRbqNTvVwY9m1QSFnBhryb8sgL/6uIN3lJ04tGTonfsPQZ8\nwSkWhCOzEI2D6kP325SXd4Fk3VpUJeTTmhNU4TuHCnor3K+hTIgJYlKDAOMH\nLobqHEQYlrbWeNd3JKTrD8f+T0zdOlW324tjIUNYWEomRz8B25CdLNP346Ue\nK9P6QA5VR7/aeGGq5RYzuyC05xTyCXAgzJedIrjUapPUfajKcP0xr/tV+LTy\n9kGadqMQs6keLbWponjToo+/4Ke61UCs1swPXM2XBJDSX1jqnbUA4rEIHDkR\nR6KaungE5Ue9hJGhcZ4dHdazNulgTm4dFBmhx7qwG671CrWtoAEzYGUd4kDO\n1fQ9LdDeTRzuDtkCONUsE7xVuAd023IyYigFMPlTmpSc0UjtJM6QdplrJveO\ntwJpiwaIaEmV9odBqPt5iMnyyGrHEo0JKzqLwqPj8pxUug6eG/5H7YAE8EuN\n9Q3mkILpNoxJtNtbA9cdxDTCwIx39zYEyHsGVySTwK3RuDfb9xohoFbQmuwo\nuJJ9PQb3XGREmpVjqZqxxmi2p3QDSQFARskndhBzygGOlDt2l3uwes8WUvEd\n5tz/\r\n=FEzA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cfe90b1-1599330108663_1599330162172_0.22964190329072376","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d78862d-1599333660354":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d78862d-1599333660354","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d78862d-1599333660354","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0ca8be787724416b5213a09511d1598d6cd6c330","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d78862d-1599333660354.tgz","fileCount":7,"integrity":"sha512-wwXHiItMUWBnQ5+Ty/wp1wqIO2zXbpirWYlLFm38SD3DaKYgFjQnbswi7GqqQPyNQvj6uDkE4OM77pC+Bp0UHw==","signatures":[{"sig":"MEYCIQD1DS7TlYROMZwME7Abv7uYunFptyjK4TOtMYQ0t+8fMgIhAImqO6yVPoflwQWybYlF06AQxCjhtVJG0zeRPx+lZlvw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU+VMCRA9TVsSAnZWagAAqEYQAILp9ji2VvCvEMExmZf4\neUNjQYLI4VXZxVnjm8D2+USEvksgSz75767yNIxhWvnxs0kz9q01whI8P/2E\ns0K/+sQVngREz+tPYIE1YART5gBzUg9/LTVCTWpUdcdZtRE/dTI7L2VyuojI\ncaKfQsm171gHc2qydqkPsf+HOMGEbPelxOwjw+5wPyYFKHjRMqKWIdH7Bgap\nHC0BNrAjCJ7p2KZCYNuCmq12cozx9yK2q2M2TIg0RxX/6GzX0xfPVv44M8Y/\nHUCtX6YuPyG64C3rv5SUdpPRTQc6r9aO0P9S/zUhUd/rn5M1Nj8Ky/iTKBGf\n1biDGj9lGLOHggEhteFvNF3Tz+53H444HzQ1awevExxCqv0ijO9wpQEIfUTP\nUYqa7Yp02EHIYJ5jTPxd8rMYKax06gfn8fNTMxollr4V9oI0pSNpf6/YOIag\ns7keq6Nbev+G/UnvS5CKJUfwC/QcT2R60oS2QURZWOh5rgsWP0m/U1M5IBTA\nktCuPSJW8d205DrsB0iQUCQg2G0AmOXE8fWfBwzGA+6kSlCJTXsiIiKVe/AD\nd9eLLrgmbrAWQf4N5xiIWFJl8lJrFiCgAtlGI6nCEKBviUL2ah6m9FURAxvg\nRREpCfB8PvrwZ7aM9dFeJ9xAcMHyl2LPTOT8WdCweZWn15vBurvK7pyhMRMu\ntUXa\r\n=eXKX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.0","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d78862d-1599333660354_1599333707567_0.08797703686592873","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-978b682-1599339842002":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-978b682-1599339842002","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-978b682-1599339842002","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d75fd0268354a2f09ce7ced2090f1aea063763e2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-978b682-1599339842002.tgz","fileCount":7,"integrity":"sha512-fGo/eRcLn5UlABQW8gMZJuU5mIa/sscnxhZFMvLApYr0gZzzQBkSvawt1TvFr4IlTa6bLG73JcJ77cqXJExk8g==","signatures":[{"sig":"MEYCIQDA/nlXIsMhx6rlFW8czuHRjoUSOZwXvxe1bTvxQPokZgIhAJBCPnBor2e7AUFiLqMBjbuoVWCbSqxu9k5rnM8J7exl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU/13CRA9TVsSAnZWagAAk4IP/Rfl7PGg5cD6gLe8CyXs\nixN+mmczIBuhuWx6x4tbt31RPSpD8tEYZXXbFfZCzfX99o6fRAUtsmkQ71y7\nVj0s0LwUQAUtbZtxbRm6ekwyS6JON6hUzNSD1FtfQHLMBBrDYd5heHAs+Xxw\n8X0jAWgKfTsus1N8sRr/tpj6AHhlkY65vGB2RQn3jhZn3beZqDdrtENSxDlY\nrH3mKbz6roeNGd7w+fPRCZj2zIFCs6ImCnyUmUboCUYcRXyKmmlCcad6YwIa\nw3+eG6yTDHEc7QwC/U0VOnyibdIvYwQh0+k2L/5axmJ+2wjIWUcl1Yl0WPKu\nvwAubfAZsH+TeEsL5uc3Wsq170jJL5v9/YHiMNtwJw/KXGhO0KHAumPoXnNU\nOophexQMsvoQ+W3ZTKyA1YXg1pVEx/705uMDr+sZFASoPzALTWy0qkbo7UnM\nHzFwf10j30SnsBzIPBa8GkgH3EWxgJW539kbscRIyPC9Uqy6X5mippBgRkAC\nrR0Ua8hjEBSzbol8JBfQukhuk+XlhEZTLuQgO7h+lCsYdRoDEybPe5jo0I+1\nnRheeupB0rDvH5cKpG5quzd1mGSPtnMTT27oa1lWfVXxnMoVHk5zYxEoUGno\nXmmlUlOj2sIqjQLCcT0OSXRhtXHIHONMzC2vBB/kP3uKTG0723rxVdvX7dNG\nS/ve\r\n=BoAZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-978b682-1599339842002_1599339894833_0.9768463348948151","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-978b682-1599339847878":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-978b682-1599339847878","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-978b682-1599339847878","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ed162f3ba5adfd9efd07981d8db0485bdca743ca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-978b682-1599339847878.tgz","fileCount":7,"integrity":"sha512-TYguIqsL93G+Niq5/cFPL+TCMMU/mu2dQTmKY68PRFZHk4HFCpXPs7vq2lrPWUWLfvqM1Sx581U0uhpirhOJyw==","signatures":[{"sig":"MEUCIGKT34xu86deRMcrHDdHOvmV1LA6so5Kt/W4BSLxrUCBAiEAqFnLX4ft989X/1kYElEB7dGS8WBRBSZw2OBKx02mfPE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU/17CRA9TVsSAnZWagAAbrEP/2tE5zzAAOhMraQZKdnH\nvYsKTpxL/lWgX2iAUhugIXpyoNg/xjdRIWzQoqzYpPojoB+mkTq3b/ZZmJP7\nBYO0Z/2gqU1olrc6wPwjZyHhUzQ939hsF+SaGbV9dQcrM/jo7ro8vN364ZGX\nSD+Wi/ytn4cqXr/vZxHkoJYKt73Ns1RRNHY4p5cIbw4LJozYmgF0mTYQnfIr\nJoJ0HPdx1l7dkOWnu1LzCqi16e8Eq3poHl99jifbPC7rMp508ksrf1WkjQgh\nufqznGqmOVkLGcgPoazgFaQcDLZYrWPlRYmi5Sc9Ji7ubqmBDxCCR/zLgxa6\nXJQAwjZ1LdA6MBoyU9KmLPqwpj4mJUCsp87lC5Tjs2mjTbmcww/bDNyP2b0Y\nBEqy9DA8tyY8F/aSp/G5Z5iG2UAuNeh99keRVaSTGKkt1gqbHqx0E3wF5aoD\njOpqISNVa+4E0evEd/k94uxXylHfM0HwbBLbnHJBudWzXxXyLGIBlK5olbHf\nm5BwfFDbSMlKjG6EFa7R0YeTTl/DeGa+7H8zK8a2mynOO+3ZK7msZ1gBoV95\notY3NUACYqDxVe/2BKDjJmugFkXTPFizmUVAWLtyhqfHZpQ+FmQ3+MPnUqaD\nVIszvrN/di3ZVLIbhhu1XbPHxKGymbvzgg1Hung60+6hCKVzB0M7uN0SNFnD\nFopV\r\n=I8ji\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.8.1","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-978b682-1599339847878_1599339899017_0.9583794161239461","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a374874-1599936643095":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a374874-1599936643095","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a374874-1599936643095","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d449bfbb9252c7f9414f8620911222a921482108","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a374874-1599936643095.tgz","fileCount":7,"integrity":"sha512-LwD/XEGgpBH23UPJwYlTSfV9MfyRcIkbLnMT9rCFk3GcL3Q0Rr/oOEn8iIgTlZHgeckOaevdA9jv9LiKdRdkYA==","signatures":[{"sig":"MEYCIQDiOwUNrF8vfG++KurZcaoRbJiKWouLsS+nH1I0SGeQuQIhALtMxcQ+GU4B2DkRe88/ZxWpKIPAYrpgbx6MvonQDE/3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXRiwCRA9TVsSAnZWagAAoN0QAIr5c95t1mXoedr1f2s6\nkEiQBc1lV+H9qFgoM+lhjiK6R0RNbN3QLUXiI82yo8vMK37IYf/x6Lc4xB/n\nSlFnNTlKQ+hjAX8No6dV3gzvjdEBXZeWkgpXaqw6AoQRaPW5vtIwiOCWb49v\nvOi9eOx675dAERZwsTbeZ99pm5tj1Ljpsbxo9e/owMNSxMrrGD3OAAu+GOES\nuVdXCncUlNM3eVuAA5Sdm5bDcKY2HOjdBkx6wXmDIG9ZUQBi3xXotEdJhDQ+\nLFFKvBLtu9FuloE9E7JQIXueUbM5XzTHQhBpJgIegWJAxBUPIFFKqJ769Clt\n4thBlgloW/+juCuLwUbmFhoHii6iTodZeyEnjEh+OIGzsBul/wih89h/BM4W\n1t5CWrzH8QR6Hu9BOtqq0JU72B3gNEYfQRZHdpXszKpZLuoRAj3kgYJlGjb5\nLXR+Pv53qPjqaA65ewaWx/9AM+liDe89Rg56mXDq/6JnvxsRsriskkwyYlED\nbjGbYguIHcKbiFyM0oQjH8pX0QIuhKPsSJMKxU98MKuyc23mTn1b8VshNFzr\nPQa5op+lZ8xv0YsGUSIhfEFOG5LSuZGFHnEUiSv/Czh5zl8Zh/9kaNzUTDqK\n1r3Yd6UEpm/ef8BIBgeR8BTVFRfcTjEVHQLeNMAMJosmwioplRDSWsVbdQZN\nKNTA\r\n=JF1f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a374874-1599936643095_1599936688360_0.463892712946423","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a374874-1599936640605":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a374874-1599936640605","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a374874-1599936640605","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8dcc6dea3066e61ca276f3ed8fa02c98974b09f1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a374874-1599936640605.tgz","fileCount":7,"integrity":"sha512-vl0J0ghTje18zb/mNOnNiDEaUQLZouHrLR3PoHwffUZC2wC1ZIh2pVVdkODHlwl+L9l2F+iXxiMte8za+Rp3NA==","signatures":[{"sig":"MEYCIQCjP1Ibo4qNeN6YbcCguRgIpFg+zAk6a0gs5tGRhUZaMwIhALaen+IICnmsOtZeQmGSZS+EvdRREygdzmwvL63alX05","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXRi4CRA9TVsSAnZWagAAejwP/22f9M+rZiTZCxXToGoB\nE0quRTWLaTd566yRQuy0Yh7x+EXUaPI7Ix7jk/jUty79Fldfqfxt1bW6KcVj\nPN0zqoycOwY5MshQQgb93XzKhJZtxxPNLFQ52YmfTDzAIVWWVtV7DHzTvcO2\nP63Z/UGXcTjIZXykYDrKYDFmyRt7wFYOWtpEY1M89nK6rPGTD0NaP5rFB9Lz\nDTpJ5zVMDO9tl7DmnbMgc0pyGCRxsp17rE6sRibFJeZj5bXJ9VHQ4wPTlLIq\ncS+5lG3g9MAaqnirY031G7aX3Kz1D0OGMXmGbAL/QuD3xTr0vJKQAPVLwSLd\nUyNy11T7IvOnox5hk5T5usXl+Sv9WbXKB1clqfZssez+Q8vuBYlM0VnMQW9P\nvhdrlq+olaYKZeFCYQPGQ//umHyS91yruJYq3d5YY3VqrpASs9yCSCyxKWYt\nDlrGVtKV+YeRBh+f38+6BLTcEAdLqLjZgu2s5qPb2BDn9IuGR843osZv8QPk\nqabx932mg6Jn+GFsVU7CLuvwCYg1YWLlOym81X5wyOCbyJvxUJjpzJwpGYPT\npE6x1iVELmIPpTXZ90YpyG9qrqketHMecDasxBFBTeFPUMYzoVCFAEESsnv9\nD/NP6aOKz7RKhffGVL2Y53ZRzS1cskaubIoy2g0E1XJGzFtRXiLXYrHOnJi3\nj1D8\r\n=WTjO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a374874-1599936640605_1599936696031_0.22524021664699445","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-196f9bf-1600038347756":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-196f9bf-1600038347756","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-196f9bf-1600038347756","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"55615ca23faddd058ad52bb4b5b866287f8626b5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-196f9bf-1600038347756.tgz","fileCount":7,"integrity":"sha512-SZO+bnuSL6xqabhVDO87Mi96C6/cNXGTJj74PoKa4FHIAHsNSoDLhLl8D91JB8CfWD5VmceE/0IyE8QpP4mmnQ==","signatures":[{"sig":"MEUCIQDX5ChLsj2YlgUWP9w8ZnaPyBmaXI+nxCtSqcMo+bYfswIgKImtNilk8ynQYlpvcFhpyUR+2KK1/zB+OCRuP35KAKo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXqYGCRA9TVsSAnZWagAAPU4P/3Cjbw1gDfMcEZSt17Wb\nRajDROE0TZqIdvc38NZxciTulTaUjES9wauIz+BblDePhhKgJregcnODLMGT\n4Dtubmr/p3ybI9CzrNi8/RcyBkjYoypi19kWaQNExe/Rzry2D6NcrDM1JYbl\nVMK3KwIEqB/SUIjJADI8PbpNCiAOqi4TeJK0fMgf2ebj/d+fM6fsoUYYq0us\nonA+CRmTs5i/6he5xbsVzUMRZWLHsZJ1qhVQaigLkYiwwQS9uxfeD9HJyEHI\nxHgdkMN3jjj/gAek/7xfRD0IF5o3Xe36DS7o0hzxG1AoSko0BphzQcKB4Puc\nprVDunsdwGgZu35DNkkWWGDiftFH/Fa36mr4N1VIKIDg+HHFtkLIXhVBFsqi\nHjQOMfD4Qb4Acvg36lUa5oNCsyj0nbfqUxmPct059FSC/b5P/w/TFFnNoSiF\n0x5Tw7AI5aaeOxcVf5qhiUOy6pfIz9SS/6VUDuQ8BsfOpMt60xjIMkmy7Ton\nDsNyVjGicD+wPxUTEUI0FRNN4fkYv84ThB/oIaCOrOCT4lxNLAQdB9nDUtNk\nA+A1Jzy6JJ3FtiSQcfHrpgZdBW1McSSvsWLqN+c6zcOfXbSjR1YtZb8FEqOq\nYUbc5RS+epxl4BqZDePbG3fjQiFiKj+lcC2KuVcFIJkb0XJ5uKVfjCAgHqjS\nEhD/\r\n=yyOc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.13","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-196f9bf-1600038347756_1600038406016_0.8723837285621019","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-67661e6-1600350617017":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-67661e6-1600350617017","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-67661e6-1600350617017","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"33fd922dc1c5e584b9d63cae610cfc170f93027c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-67661e6-1600350617017.tgz","fileCount":7,"integrity":"sha512-hXRBfHVJ9A0mJmLSAqPQ1xcCJdqPCOihbpMDbqW77Zf54d8dO3jsxqDnOo8hHnXuARUyuyTkQ131B4iItBoVtw==","signatures":[{"sig":"MEUCIQDdvWIbbRMZiT2V+CeaN8eruSrKiBv0vqxQUt/wD3XddQIgOZaUOuMhtnQLYo3XziLMBp1ctkBXi7rObDhk6rZYveU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfY2nNCRA9TVsSAnZWagAAMOUP/2F9oqBP1GCAuWMT5GmM\nJXbVBQehFGD4lbQDoyWGAEklySWKJnSB4LUJzZVMvFC0CsOSwTR57gzizYGZ\nhGHZQuruCCb6kDqmjC+tRacr9AJY+2iGkRbbStrwaOZFJA6NSBFqsgJ/xgSH\n+JqMY6uMS1iu5nkHSr3KVkxAayThnF05arRISd4QLk2UmS3qGMzG/IEPTQRD\nPpgwVBk+OJUY5xnOtZA28NgsoGzyGsW0upg+8/TuUwglY5y796pchG+h+sKq\nJ0W1OlHVBIVjqr4uzWxKKcp0lzrjPwED0X0F8itRbXFXl91Nc6ug6Nmmx0Xs\niDva6U3cnRvONSE8Mv0RGEcSaY1mkJe0m62PRlKbNQhmybuIHbLQsmeLxTVs\nGainaLTXilWeptcpQtpoauwt2GhoIbMAs4ZFgIqLb/yHHEvzPFOUItccCXvL\nrDLi0As+lYr1SJZqTap4TMrUukmdPBdCGkMMiocts91MajBdA8lkLds10I+c\nHX5iuK1g5YUxYKhsxF/OKhWx8HhSCUQB0nIZmdXMF6brx59uGxxU/EbDQ0oW\nwRPIDGJPxCSeXWDdbFheWADOFCp5K7MtIQji1J1Sv9XM+n5q+3DHboYeQ/5W\neagz8rzcf0rY99WOfy31MiEW+cYDfxkA9mSCQOwFITd9E/Txl6zygIhxEy+C\nm2x8\r\n=2FbC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-67661e6-1600350617017_1600350667222_0.8508880538401471","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c1efd1d-1600350621428":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c1efd1d-1600350621428","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c1efd1d-1600350621428","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3717bb4745c0982214efa624e43f93b58f9d10c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c1efd1d-1600350621428.tgz","fileCount":7,"integrity":"sha512-uBH84a6yTwsRYGkayZ42sVqPhKrz/gHfoan0LIFXUP1djg/SSHhkgVNlLUELYq82wNrDAS1vl6im53dvn1PXqA==","signatures":[{"sig":"MEYCIQCgQ4O6RcmTto4whH5PzL5Fjlx03qfPVEhUppGUTYieJwIhAMzEbta03iPGpbB9U+GVJtju8ftdSlH7kS/+hwrftFWd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfY2noCRA9TVsSAnZWagAAYtQP+QDtIFEu3rdbmNQyShO+\n0WKlfxQiUZ/u0CziBGUAjQM3u8mhHIJOH98/57GIpTbcYjo++iUS1bmHTkpA\n4Csfny3i4wA6pPLbhGQKqaV0szya9ljESnbIZr0a6zeBtPeCc8jTYG8PYVxG\nQNwzPpLrcy3w+feV/WFzdTaZat44WD2bq2Vi9BkQXVrbz5RxXvEP69bYhhgE\n9iBuZAIbpUUB2VNB3vU2zu/LXcA9RWjIUBcwpGoEtCih60U0ahUL8NUpYeew\nohnK/6M+/JMVMJo/nf9qpRa4jrqcXx+ucyPQgdG85Z7R6T+H8j3ACn1DsdK0\nu2mxmMcVLH4nYFq7LYOkIgw58dnjgq5W0EFl/syv+/kbNB4mAe/tSJ1RL6Wf\nFTePpV4TI/mD/Mwk12ir4Bv5fXVVunF/+CaH1KVIdAHn2dAD+74dJBBVgKJ3\nr33Chyy39uUvzaBkjbhQ0svErEowEUjwYop+TPxqcTbqzwV9jYHAJwxtio/l\n6NWdlE/NsdkVju20VRe4aadc9Xw0n4kgXcXQLcCulHjh78bYhFhkWkKi7kIv\nDduKWCJ8njsaeBUxTb/8gP8fT2WwkLDQwF92yjrGY03kAIYPM82/nwDJuXNB\n77hrs+DqqM6SuolLUEs1479ELnPj5QBFiyb+nvjdKPjnrTPlV8OLD1jntHUs\nWVtT\r\n=i7+V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.2","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c1efd1d-1600350621428_1600350695705_0.3778912016459486","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7ff4b0f-1600526223693":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7ff4b0f-1600526223693","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7ff4b0f-1600526223693","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"48d2cb5f395ab9dff0648085dbce1d06a226aa94","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7ff4b0f-1600526223693.tgz","fileCount":7,"integrity":"sha512-OW8whIWfcMIYf4t0xtVIsJ8H5MsGdbtK0g1TU/UfcEDAH4O152y3aAbTz7vrbGijNlOtm0foxgSgbhDqdJLEjA==","signatures":[{"sig":"MEUCIQDx//skw2//vMMf2QSlfU1iKD8A7gQkaJVkOy+gWTChNgIgfVj924UlUQS02afYxz50rEHM4lCcYFtROYEgx28x8ac=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZhfACRA9TVsSAnZWagAAmDYP/1iPSiJ/sf0YVtRyTBFa\n/4YjJq+PLLcQOQHFpf7Nw4Sh9i3FpxFD+Epd+dKQOzGKIMN5s6KhzaDYMsOe\ndcmFt5nGj2sxaec/YH/38fACtoxKZfZBvMJdmosVS5lgNMKgKYtyo04l+1CB\nhzna67Lx3rHGsjz2QUZpt4XFknJo/zdJDKegh/0TFh9chR6xWPCm7JWI0U6U\nEgGU/4P7VsVxcb+zTpyBs++AB2zAC9o/SxuIt07HbX56lGYxSgKgzyzgWS92\n3VHN+U8ImFBN6aAfEuu4OC1HOT6j22RVR8mMP5k4Ji0ijOF3RjWfDE32LeO4\nonX4a6GObAReoRcvv1QKKaUEwrR8lam9HM8bKd5vJowcTK2X5wBVxGy5Zvp0\ntMUT0LZQYELskvihNscKDPHfwIzlnvw7xJlCrNcol8owCToCL9yYrcFyadNv\ntFBWtt5s8WNH9nWUjIBpaG09zsJG7yGuZ/WIp3PuhQBapWYRBcaEgG1OK52X\nHJSjge/ktq59azi+Ymm5QZPa+WA3qAZk7E0XYvHnzRbU5Q95dXrzaM9xzDmo\nmGDQVDxQ4Yc/o9S+1YifFuQVJkEW4I3ttDpki2c/d/hDKPh1xA4UlXEWxPOi\nGdcP4FVYRgiwzXQdeJEJD96PBzCj1tSc/X5pQ4d68caUqiURiCjPv/AwT0BZ\ncS8w\r\n=lt4J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7ff4b0f-1600526223693_1600526272357_0.6324151212085536","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7ff4b0f-1600526224209":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7ff4b0f-1600526224209","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7ff4b0f-1600526224209","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c43c54c0b8b552fed9457dbfeacb64e7a4320ecd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7ff4b0f-1600526224209.tgz","fileCount":7,"integrity":"sha512-B+tOrMtiLBBQGloKd/bT3b+Xy2Ot+DSh1CQdPtEMoDm9tHjz/a5Fa5GUjHVH1Q/uXGZAHD+N9HFF1nqAcRuaiw==","signatures":[{"sig":"MEUCIA4BUXSSchnG3sep6BEiPK1btZp8e9qME9S9SA/+AF4eAiEA4KA7DKN/UUkC2MsGX53F9PLzylGu7PGu/mK0Gt86XLs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZhfICRA9TVsSAnZWagAAZEgQAID9ulvpImGcRGFwtPGH\ndMvNPE6nfCra1S8KupkKqkVzOzjoeivHJu9J0ol/wdCd6DyDzLQsuMe4ePuw\n+6lA0bAK0tT03QecFuM/AHIEvDYHxn85uAr+qkRymRNfUFPpHJDAZxlfrrMo\nHFanZ4lSrQvLk1agLvqmzUBmGdsObWz4+NBZJHRWKYBwnyvl1FJxyL3Aw1G9\nVYG/pNaji+qvBeCYO1m01JJmYHl/Znun7yVh+9jPloGdq/h1dAQXtyxQ3OqM\nfyM2BsrQNTSeEi0TJ+Bfp3eqbJD7bn6Wttlb/tGFBItZuweu/sKtDwt4bLta\n1yi1zgZg8dd/O+Z9V3N1v5ALvlYB4qjLa5Y6Fyca1JteD5LfUKg4e3qjLwe1\n/pDU/74CwodXB8Dm4nZsgA+/p13LmtwiurHy1MP6K2TDJy/2BPeppZo4Aj35\n/CdJn6cpcZymSR4CYT+nzzdDaSU7RYu88DzAUYVeF07zpC3hDNNWXKzpj+85\nR9JCBbw2YnNn6IO38CDkLi+Tf2YTatSFkqqUGGqLublXmrqtyxh297HZPAjo\n6jrT7nfHSa6F8QtvtfPXa2eYKD8ciSvu6T5trA7Lo7+zAu+msGppoRU+eRzj\nyZ4I55ugfe5h2NIKLyim6bmivjXB8IFhxHHRD2KenOIu28Y0iwPJ8RbDaXHR\nIZ8a\r\n=j+G3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7ff4b0f-1600526224209_1600526280332_0.5346284377761303","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f50cb2a-1600532263453":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f50cb2a-1600532263453","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f50cb2a-1600532263453","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"45e68830f818e2211b3b2445d66effe5c252087b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f50cb2a-1600532263453.tgz","fileCount":7,"integrity":"sha512-5g/erymWSRdxKbpdHalSnU59NpelVFU1iMNmwXTgDD528PO9L6IX+sjsO+wGgCL0HPmv52cBGxywnbR7NMsCxQ==","signatures":[{"sig":"MEQCIGXQU9mB1yTCsiH33LbdsSARRAqZl3dDU10tbblgLb6HAiAJc0Lrq01PutA1rTywu7TW40RUPuZPTV5yObWMDm0TJA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZi9ZCRA9TVsSAnZWagAA0bsP/jUv7r3gCb9iouNacYUY\nfkcd2J1qrMKzMC5Vf5cumkbp9LmWAfV3qxyoWrhxl25SggH8b31bVrzIywvw\nCdQxlwXKs0EoJP+VMKgdRYc7KK7b+yFqNqtm3qudaN1x7xxldMMIOA77rYqy\nMxWBHOIgP4zrIeUx4UVhrdguB5OGQsQPbhBRVWL+VDHeyAU29GauQtwwe+sW\nAJo9hpY/9tJ/UKXMXAV/pOW5Jv7uYScmapTx1nLjfLUz2o5zz7BabN7wbiv7\nWrn1axkGWezbC01GnS3SihxI6QyjV5byLEVu5JNXs0a7e56ywNDREsN59Wla\nL2RMoo/uTG9gzZpsZw+hA//lIER8zq4hhi6FdM107mJWTZhbd0Z2zWTA9A3H\nidhHvvGMWjrYfzXGxphBhYSK93O0O8EbSpn7xmVIu3QSC7G2Mn8GEIDrp3ht\nIT1S7QBiyLMmpVjzYQNxexXkTyLiif+FGa5R4Y9zsr6tdGCME9hVTIWjF02g\nazTh2UDSX3EbDxUTyoZozQIzpP/uDjPNmaXCI295VJvdKwuppmWhf7rpd+sA\nOZ+rM2XayZuxy+nrVd5ooj4KuDKhDD+kO9yghDDDZSaCKQXtjXFtakDYP4UE\n5W4R+yLObh2r3zOlQNOmwlrvl0hlFI3sSv58F2l0qipX15IWMvfX4hUdpYcm\n4HMq\r\n=G9xh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f50cb2a-1600532263453_1600532313231_0.8611095826400559","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fc3c95b-1600532456987":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fc3c95b-1600532456987","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fc3c95b-1600532456987","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b4f99fd419318f7b9d314f12b41980b7773fd16d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fc3c95b-1600532456987.tgz","fileCount":7,"integrity":"sha512-tYuDD5G05Mm9IQr1JmgbtvtvtGpIs8cB9e6/rH5nFk2IklkvMFNDvKAIS0Lju8R0OHeu73NJrqgJzZrnIdN1Cw==","signatures":[{"sig":"MEUCIF04Tr0o5s+meLRs6g3jy3Dr8nGbKqKOnDJ7HhAsBuS+AiEAhEDjQFLSJ5xVCvxZ44K9WC25f0W7RXLklP9QbDYOSMo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZjAYCRA9TVsSAnZWagAADVEP/iPg22Pn3yxl3JccfEs0\nM1ytjT4aRQ6Ig5CzT8RppwiZYDNL4TNEnBG5fvoV4z2CjKb4Y1/sTN3v3MUD\n7h96+Az9GGvQb+1I3AP1VgSIHMQKKiqONOoCPWoc3GrpyFjcW4ch8Dx1NaLV\nNpNqsjujMC+P7P4sP2ZCumZ3BTDQqyDmgLAIwtbIQXnvYm7BlZaW1t0aRMG9\nC0EFQJ3lJ2KmWQ7hwKiuPg9vL5UexfLMSlber0J8wwSQ0kFGx9NnsUR9PTGI\n4OWLAjQyIV1MzcFA2/XUPMTBlzLgiw44FVSEGL6Sk14iNhbwXv12vD63UbAi\ntaOO+eFlsUTZwjHdRjDeSWEP3AXTDfHbt867U+scgFdkR8WsGvQLAA5ZhOs0\nloeMyeQEpB33kH5Hi8ttxJ8xpBzSdH0JOOXGuSy++Rw14gsZWJIn75WhGX6e\n/YqRF3VBLWulwQ0x2DhCQVFZs6HtOQLSqXLXAIP44EQT6EzNjj6PmZ8YMKuQ\nN4Cld8a6VQwWNf0ZokxhYyydgBjiXQxN82Jo7Dgcfe91fPTJnDdEb19HFgHM\nJ3qPNJjpoRlnPdiG0QpjCRSmxn8pcWfcAghb0su4X+njJRn3NQ9nppci9+/6\n505fN4kOEa4FUcCqyk6Jbmq3p4TJHQ4mqIh9/vFWAZv+raXrtsSwbgq3eePt\nwOot\r\n=pkEn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.3.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fc3c95b-1600532456987_1600532504461_0.827492034485745","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7885fd2-1600599358148":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7885fd2-1600599358148","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7885fd2-1600599358148","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"255b73a2364340c9dbb5426787cbbc2774aabedd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7885fd2-1600599358148.tgz","fileCount":7,"integrity":"sha512-WugpOpmlE3EKl1vGuRhRUA7DYHzgpy9BqTHPQzMZoJUyI6KvPSkPZhE80+U6t+9CVPFKeIxX7tQAYm7t/5UfTw==","signatures":[{"sig":"MEUCIQD5qhFCgcdX5v5GFYRY2tpJWLMpyxaG3W3xwH6aQb0GVwIgFNyncmLjHNIzOiRwxCOX4nB2XF2ashBgQa7uHOp9SR8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZzVuCRA9TVsSAnZWagAA8cYP/1WmOhIDpzzYm6RtMcPG\noAVjjntR/W17SaIJz3TL7GlVCpZDtTrH1cjv/TxfHUoT3Qw2VnkfM+5qFmcS\nZYiGKeDakNTaU/y0bYTZalcM+KkCsRSsC5TX7Ra/6bDc3QcOR70ZJaCgpANo\nBXU8t8SPx3KI55ZvE8SHG+wmMvfeXli5fD1QxaW19Mhn5/4ux3PcHcRtSroA\nDdClGunSzPq3eII3Wrq8LjsxVPJb+HK2xRmMW7qntWdZO9TFhS5SVMtCs8m+\n2Rf9s5wxUcl2soZQXxdCTw6SpAm9oI3VOrjLJFYya57txetwdZNqZ7VHR9za\nK5vhL6tuGcwsiFwy+ycfb1KKHZc+fzye+QPjgwIVJypFbC29xL+AVhT092nV\n8hmmZdnYSoeli5vUMx2N85T0VZa/0BfBUCwckwqp0aE5tv0R2o7CVqJCM8MC\nmkF24BAzqU4cfBdwnjZaFv4iq/KNldo2Cb3uNJ0ZOMkat1Lov++iRWjOI8YN\nKjtT2Eu2FiOfMg2NZqbtfi5f4655DU1ZkxaXeHDZdoTEKns5du+9jjNlqLlE\n4rVUvHB24yql4oq9KS3h7Ylj1GZNm96l4f6Nx+6HGk/SsgkX1KJ5/kCiw6PP\nKZmdAKO2kYw9UlFU65tGvlKju51k3lVVmfFM4QprTawhVg223Pwbl5MlPCFt\n8mLi\r\n=mZQG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7885fd2-1600599358148_1600599405555_0.8163915558955104","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7885fd2-1600599363854":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7885fd2-1600599363854","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7885fd2-1600599363854","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e40a869d7a7df31581bcb52101e12b9833c05bb1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7885fd2-1600599363854.tgz","fileCount":7,"integrity":"sha512-4Cj+wS9hfYOC/8L4QpYzKXGDnMa9IRZcR2Ne6HRUrealnX4VTB3sL8yalFOwMam/AGub+UEwY83pvbXIVRA0LA==","signatures":[{"sig":"MEUCIQC6J5TA15/JzzDkDbgFESBcOJ3T3z+axH5CBR31/cSL+wIgM/EWL1kCOgPnTSu5LZLmoGBSqTtVY6hQMxjwQkoROzk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZzV1CRA9TVsSAnZWagAAZ28P/RAQU+DZ9Zbn79sb0t2w\nKQNkrM15w/NgkeNZMKhTr2I1bcgklXMElMWlU6HW/vlAgEgByG7TFTi1B6Aq\nm1zrDyujvrGTX/JgXla3wqijn/x88l0jlnA7bdn0IzNG+y7mYacjHgoX6Fm+\nzEbHNirLXVr4ofJ94Pcg1FO/MxdsWuqE6kmCk8569bedWdnA9iQbFSNn2a8L\npCtr57Dcl7DzrfGyDWuhg6QsZV9wn07OZdtmsYGgnalKYJ4XHPEuGLZVZWET\n87/TKCIAsRx0AnvsWWxnGv8VyYHwe5d1som+MWtjqmowv9Om66G3vSxOiNju\noyRX+LHWF/brARcA1Y3R2OOmT+9q+mBTGVKOaOMRQdIsbwREPxNIeGkP38oe\nwNP5VnchUFR+Aqp/OeoN4FCdQDNhFYgiaQRS17+GVOT3XUM/HU145dWcP0En\nlIwP9Or4INfQ2NEPYjfNxEn6BY8GDyRx5HKZ1lAYX+amShSNvoOLm3fVYmZH\nBmoFSooUtZImvV07Msh+C2lN1WfgzHkyXYmiQIc/Mw2cLx2kEY04rPOeFt1M\niF+Rrqt4c43nr78XxJsakNfyYEIoEYeYSXIJSZm14BGQ/qoymb0v45Ms9CSi\nLn03aLGQfV00dclDUChmL4XKXwKp9CIbVudPr2z1JtBY15+kjj/KSkl+t+QI\nZPym\r\n=BVVn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.1","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7885fd2-1600599363854_1600599413506_0.8011082243487906","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-53dab58-1600653936493":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-53dab58-1600653936493","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-53dab58-1600653936493","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b593e0230177c5dc736bcbe585d870162deaaad0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-53dab58-1600653936493.tgz","fileCount":7,"integrity":"sha512-cVJnCcllFMtGp+7JgA4rLgF4oRdFpmJC+hk8aHmqkkjBkk0GjYjdtvXtOVq0FiHs/G40W93MqlZCVOOYrqvevw==","signatures":[{"sig":"MEYCIQCt/rYytiVJV77NDvPgQUuSXcQ65QfIEMA4y3/emO0UrwIhANuY6s1pGcR9i/yeoChXbeZBdIQeZ/Ofek82+H4QojmK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaAqnCRA9TVsSAnZWagAAyyYP/RD3HrL+EzcHHcqAc3P9\nd4N300WBU2pBjqYo7Nkuw1CWUq2Uqll5CEHxaiuFkBauDnUTuIa1lx6pp3iV\n7zsxYzwNxPQ1T0Twv7SE5T7vZubjSawR1FaKfW3bFH6XUquQtDTlC1mX91NM\nWZDdyT3Rk0QcEDBuxdvlXSO1hLgcF6fRs0zz7JYWbipB8y27vTJUoxx5XUkF\nprbFCL5IVrdoNL1hHTAtylUlkVWcM+UZMc8oGT13NW20rq6yx+Qz9bXoVxlU\noi/Rk8j+63QqPg7as9SoxkARAdzmjMHTx6pQL962sGslDTLr9U0pWfaL6tHv\nl965X9df/k2uZjBtSabW0hxTYJOWGZQdLeD5g+eEufKjPIe4mbFhHfOsSe04\npar+2BgR1HyYtlJEnpVGNKC3IAAoGdbBdH7Cvy7JWC/kDBq2iide5+FM3Gzw\nbIFpOU1t4df9iBPzFuftWxI5CmV3vOJk77eGxDiogItqru7CVHQ7OSGetMDx\nczluiwXVooCQPkZ7Xog7HialY+6WmWmQPu77KainSnz2PqDsI8os/Nv7NOW9\n5KAasGoQnVrRdrfAr0jFfrdhbmLNhmD392ZM63f0C5guLUVUg5CRbVCtzduL\nB3mccCxDgnjAVhpj9FheGUs8/2W4lDFo/9u9HLd3yEauA7GEfRAc8fCpRo47\nX96w\r\n=UMLQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-53dab58-1600653936493_1600653990720_0.901282850251184","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-53dab58-1600653937140":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-53dab58-1600653937140","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-53dab58-1600653937140","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cdaa62c6062634588ddda5b9f72b5e320c87665e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-53dab58-1600653937140.tgz","fileCount":7,"integrity":"sha512-CgXudD0uZIvymNMVdK3t7DztInWaCecEUnJoLPEO8+ED8vAV4fIuIj/zSBfFgBVB3H2zkrDCG5OywMS7j02CWw==","signatures":[{"sig":"MEYCIQCwIzbMD753ikHj4lJqnjsmTH/ljesuJgIvaOaSIH4adgIhAP5HHfyJcM2Rfmnz9hDjiDh0Rlo09nQ9X024Wcxi0Bff","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaAq+CRA9TVsSAnZWagAAfPcP+wdXDIinrM7IC0Gn5OEe\nAuSWNl+qmIFgXwvEowU3qn7X2Dperh9Dk0uaUNTLFSKa8HsuLZwhGQ8zclO6\nG/sU+6nE+fE8AhogRV3jdI/HqsCb92d2fmaQbA4QCmFG0FEbqUJwnW5OYn9I\nOas6OPzjDBYFUvds5mXUMF63TtssXlY/RZhsxJA4tD4mDf2meWK23bOKbW+F\n+AY1nv1ybuRtmLzXbR8eVveUVGv4xKBWLDEaC4vgO/h4mcBqnVhJ1bxIvZsJ\nP9NtRAlXslMRSXbJga0tTOlKGm8hHC6t9M83qQC40Vay5df16hxajEDYFyGU\nr7wJxJAW7UclJchCiJuf5ziHMzbeZ8VGIjLid4jaizRMjzZ2E+0Tvaf5KXaq\nArm6LvIWK6S/kGUz3oGRWfSghYzqYx0S6ye+cl0j6O+cPdk27mtxfzOeHIex\nICfC0Lm0GCmWLkd1D96Dji9VdFHg0IlSZuYl8saO64DWftpVPYktUxftL5Yq\n/JZRIgIqcF1zXTYu/tdyOyhaXYjzm5H0vFslPoLPHQ8LRX41pBNf/lpon/hR\nLQWiPaqLEmtqCTWtFkDQwZDu6f2p3UB392s7n03FaZAGdJRptTbnZm6G2B06\nKtw2b6x19Q2nmm41ApDzcL5+ndiLh9RAVoehqMUbdoSMKfNeqpV+JtUef5G4\nO2Sj\r\n=osZl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-53dab58-1600653937140_1600654014049_0.45004868230601036","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a5f9f0f-1600670413494":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a5f9f0f-1600670413494","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a5f9f0f-1600670413494","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5975ac459b90ccbf0aecf7117e41a8989757d9e1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a5f9f0f-1600670413494.tgz","fileCount":7,"integrity":"sha512-IJMkRCB3mSX28XYu7QQvoEjy7/wSh0/te7qAXFqD7ylDGtdggq6ClCcpAxCEGWNNucrxjB0XoaPRVhfw0ofC9g==","signatures":[{"sig":"MEUCIC/CtkNNoBLfEXjILUHWQSXbKfGtGIo7BG6kbpTfSojkAiEA8y+qtnWuGikwTA2Ogemm0IMUXbjJVcyno0zRB6H/Wso=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaEsCCRA9TVsSAnZWagAA78MP/jYpnpWQC0K7PAn5LK8i\nU3HiePyetyH7spRCdHNJgomeUAEEC7PnGvJSQBsUizlI1UoJIhr6Vy4QmT5M\nYXcuxqNA2kt6gs5PDPr7ARJdG997TVVofR0L9a5oKwg1cAv1lREaPowF91cB\neaeonWV2CFsFUHsFF/ZeRmw3mLAhbLCf3Ju5r5vBNYWhR2y/abyNxXmUzIKK\nE/bZwpcoXpKIbqyzjy34y8MClpyOrgNtKtzrb1xsNU21JE8hQXVXMhrILU52\n0pNJeLZSwiYOdO6PrHmcoRlZmr7Q5O2O+Rz6gEG7mWbteBUDevmztWHl0Xy6\nT0WPLoqwiBlfLX9q516KDA/O4zmoTpWG4+qV+m08Mad+tWB2ynoICJJOiFWJ\n4JqZMUW5otVSz8TjHSCdGMkfNr+PdNu6646Hd/NVGlW+JBBSZqqTNxuEgbzq\nk9dajCYyl2DTA/RBCADUcNhwYEOK9KG29zCZM7tbm5cwvT39TSQTEnEV1Yod\nJz4T+GF9N5pd7PLWlqorCjWLxJqf5EqEpfyEcw7v0jdmWe8kavSN3R+RxufD\nvBA9XIfJaUHF+YfHYNMdqyk/nQGnAA+ayLE7UpNRz4KCs+RCWmAlMiLGLyfJ\nsK1d7tT/HLmtEL2G3YqRdwNNz/Lgxl2FcDLs0eMPRM/b2UFB+WEIJ/fROMuq\nrnfp\r\n=ajA4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a5f9f0f-1600670413494_1600670465505_0.8638692275614948","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3dbacad-1600677846752":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3dbacad-1600677846752","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3dbacad-1600677846752","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"216cddbc76084644af1b628f6f6c5ba664359162","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3dbacad-1600677846752.tgz","fileCount":7,"integrity":"sha512-Ma6XyOy+4tzM1PQKOMXXRRGEGHTN/t3BcezxM9G2kyUeoSivbTWRNDmT8bN207alNzju5yQAaNLVrapgdZyH9g==","signatures":[{"sig":"MEQCIBRND8ghXX1GjcnlydUn3ZAH9x1uASKhUAjHcXr5TgJgAiAkg/ftE4CGhrtTUCXzuyORwRddRBAZBNZykSV02ypkdg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaGgFCRA9TVsSAnZWagAA80EQAJuwWa/blu4XVVRlwGWQ\nvnx9nURod+U4bgFWcl+Rod3DllzYkXXFOEJ10Pnun9aSTsASzBoy6bH92Vr9\nGxNuKt6HgiQsy3WQszJrNgNykIxu8Qj1Al28uuWKawDF/+Dz+/vCQhDZ1buS\npYoTM6uaZ5ScrDmRnYEqkDWG6CuP6Sv8IyfeqDNVxvL1XE5dOsQ9Kl6pIxFF\ntUfgyRWuXTWeTpErvqZEmbOG/TQn3E5O0w+J6LsjUYpGuG5Sl6uUgDjZR3Gk\nzcxRcC7Oi4e0+DtZf/rlKHhFlsR2UNG2l8I9UeiNf0a1sX1wJmgYfgDH1nVH\noRDO9rZafj/A4QLGPfx7cyYgA4taDuN/nRk+pl+X7zbqSTHc71KPYmsbIfVd\np2WdFFF6xx/bIiOWZmpI1P5VyY9noIniJ3AKdGC8QTn/rxzrzs0DXqAIiHZC\n7q+tuJ0wcnJt4AetKnudJPmQ0+clzIzfcviSh1ktoWG68RG9jPkYt0l6yh3z\nlEuz/WchJwjNPMlLPhWSdWAYxWUoyBCG23EmGBuGFKRIrkGBpNbwr6wSNAOI\nu6qA9jEiWDNhbJ4z7MdHKH120e3jZmu+C/O0pa1p/P32hhX9lA8dCYrZgpzb\nrmvA9HkzclpzO+6/AmvUgVx+sTpQHwHyUxkAGRhXgmWPY/xslvljTP/Ewedc\nxpPQ\r\n=x2xt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3dbacad-1600677846752_1600677892475_0.33113951107132245","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3dbacad-1600677845280":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3dbacad-1600677845280","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3dbacad-1600677845280","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a20e23119e4d0b858759bb811d33c077f15091b1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3dbacad-1600677845280.tgz","fileCount":7,"integrity":"sha512-DF7so4WwpA+KfID7j1a7EZuLp7gPT93X7V4Bl1TtsJR4TQhwkFcYUvzMrHVEluTVMdRR/0EfSMT8/nC/SCQUAA==","signatures":[{"sig":"MEQCICiWae4VU3oM5V8Mtjjryq9SXpg2Minn5SX3acNHDhKnAiA8byWDRrxz3ZkFBrhXhvsBWfr7jJ0eNTBKQvrES2Oqvg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaGgKCRA9TVsSAnZWagAA2SIQAIfZGgtFbZjAOckK20TQ\nT/kTjqtf3eHAcDF9dk1bwkutu4EUwZkOXh7o5fS+LNiAunTzpFy6mTPyYbJX\n1zEnG3H912ho87/Yvjo0laR57K9a9SFBqrzYSI2gbbr7CQK+Pgjc6d7xhGaN\nTo8CQ1OwOS3h6cG/n+CFrqhYpAlHFnq2FCO+783MpzpqTvwXsG78f14MMJm/\ncyVRTkM1yx/AL8yyHNbqWEpe4c2uGpRjVHPxJNq900f0rWnLXjl75J8rwtqD\n/ayTknHpGeR4MOrIfB1r8J8zxc5OmtNEI5gQiOXOVmv42ogBjpPif2iAghAo\nAsC096sel40J1rIZxD5Rnebcm8+o6hJOqkr+wBlPu2U/87cW1HDZBEklMZDj\nMPGRtltcwzibe6IyI2dFd1VAICxzvjxrv4Sx+ncxo+oiGn96jzniOw7ZgYaf\nbNFc7GRtihuhMaIDB4MvrfhPjsgVG+RSIlvr4GhZAxiW+uIM7JqBImHjXWqi\n2NaE3tVTEbdZtW8sqnsHql+DEufS+wx+c3qql3BDVka3PRlmsUeLKlk1VEEM\niQudrlm9yKF6bzKz36KVLnziUY3NpZyY6QhA7qkwRe3E47UR7g5ypo5+qkDs\n+4hl+Tlycb+/OKrWJZmHp4TrG02iKIsC8Q/qXMuGEkunh3ceLO/RJ7twkvXb\nxcjm\r\n=FTpS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3dbacad-1600677845280_1600677898132_0.36351020322118144","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-bfa0287-1601096686023":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-bfa0287-1601096686023","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-bfa0287-1601096686023","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"198d70311caa22253d1a55346c20f7aac41eaa29","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-bfa0287-1601096686023.tgz","fileCount":7,"integrity":"sha512-HjjveFitm73aFofEQr7fBmTgqpBd2WlidVKnTDWF1EET7Esjkg6HlDDLbWg78WwGR4cFg4lNEcQBFislspoenQ==","signatures":[{"sig":"MEQCIHtrF/4zF+KZvGVLT90PDEc/yIo56aqUrdJ9+FpvgQ2VAiAEFtRISxLZWxchlaL5ZjdJ9Xz2aPlAKTh96Q68UkhbuA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbswkCRA9TVsSAnZWagAAbqsQAJQAuYKiwXIDyfq9bNYJ\n/eklPdEfxOCyfPDeiwoA0Lzvd0u6j7Q1xwCDTbynhqJ9b2pIQEW46A2XtuRu\nhEZpOwGZKmdOiZW7Y6r2l9OJ0e6OeOBHyw2GSwB5aHZfaqN9qcmi72txJY0w\nEAj0qGGjK2dwIcG7ldZRSL559ZKro0XXNmBMYMMBrOAYWNGwuVtbJeYeygsH\nbvJDS8u44EeSGlS2wI4eMYdfSvGLYkFsyvYTYE8NjErVpxlvxIeY8ErgpANj\nRGl+8zfRWiES6L/MmgPsEGLMAehm3zEVPz0agrJ8BURdDc97aEfRC23pDuxB\n0AW8bWz6b4DnnMd9e6U+756+M8BF8D5pDGYkaR1AJj8+6kt9eGPMIf1SeP7W\n5SYPuCP4wA1a6Gbs1OeYsLC4zILM4JWwjAn+Mccc6GJ/e23d6DRV+rS+vxqI\nQGHpuAO6U/NZTBo6NMyZJXaiqSrakeq3UUUs3j4JnZjbxjtmebnfMshI1wpv\nA8742uHM3STCt/swYRkmfcjwQsChihp1n0wQ3O2d50ilfDwKZAhXT7er6CSb\n37YewiH+k1pEBMKmb+njmaqVHzNzC0ubZagX69rmQyDRJfRtcnpInBUJTiic\nvey2Qv5JEldmFdNwbEM9RoEGufCufYLSSMqozlT/J7z9kteWhE5iLB2WUFKL\nIn0Z\r\n=+UwZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-bfa0287-1601096686023_1601096740149_0.977723035498149","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-bfa0287-1601096684300":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-bfa0287-1601096684300","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-bfa0287-1601096684300","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"312db2b3c4c46ce8edb61afc76bcb18d05784485","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-bfa0287-1601096684300.tgz","fileCount":7,"integrity":"sha512-KbM5dPFo1jA2Vs9wAns7VwrgQh0iZ7tPaB81JM9y1zWaXDiwTzCbewU7v8AvU7qKBx3oaxMim1eOmNDV5bdy2g==","signatures":[{"sig":"MEQCIAlRDNa0mNBHG159jBu24EAk9PMkVnClCJ2TM4XcAF/oAiAdRQR5iNZZnOF/K22KhJsKuX8pcwdKRxKLxrCA0pHqKg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23784,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbswzCRA9TVsSAnZWagAAnNAP/3CEzN0zxubOveLQkRTP\nzdoA4RSrN6n3v9hoZkh2mASwF4PjmH6UdRX2FDSSHf1G/mtpfmd5oozzvDFA\nE6J3la1Pgn9hFvJkWC1Uh4gTKKNnDoDrxZXAbpExUlLZxbgRRNdxBN7jW6FU\nZqSm3FAg8VqiD63WjFnh8M0yIZNhuxvYhaHznRK/n7C+Z6ed4lGLijAznxiL\nn9LNAx21jsxNeaOWxwTmJhpRCusnSJSXx6wC/9sTVzkJ5kf3D77oRCIDnP2i\nHQiC7bZVEzO+Gl5qQ3U6KnanuzNJMfnr/k+F3O1av/AJp8kTzxot0MT6h82j\nFCVZpyIQ2xV2yPekp/3mXtq9wZ5O1jouyysoRA9YBFwDibPJ84BHKXMTa/83\nO1tqjqOixHNCLjWhjcGiRwFyBNjI+taoAGiDrll2k/I5Ywt2kY4+gM1QU03B\nTFOwBNdUsM9keWz08tI9qKk3YMvDNgeYrqAXJwo4mY2WFhCDkzlupH6K8rd8\nKOdhGfa9LNORFwq7hC+MqF6iCNzf4urxbI/t223o4uEBDofhPy0ZXwGYk8ie\nmpGVLUIKD+2U7A6HmuCjpBvRkZdDwpz9UQfXzll65/hk9Fk2eDj/Tm5ZePY5\nkFUp3Z58CVuQSwZ0GYIGhUtRXeuo2GrvmTAu2U46bmIZebNDckWGn8OJxVWY\nTLme\r\n=Fj9u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.9.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-bfa0287-1601096684300_1601096755345_0.7033947954041","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c9afc1-1601158472785":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c9afc1-1601158472785","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c9afc1-1601158472785","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"87f8dc3e36769642a631f350948ad0af42c3701a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c9afc1-1601158472785.tgz","fileCount":7,"integrity":"sha512-CrW1e4W3373JunMYnR/ojuk1WUe/lqNhKUy7wam0eyNjeVBT9/y+XARnU58CA/jQHugQMFryATsH7W/NuOnHoA==","signatures":[{"sig":"MEUCIFlZiZSlXOTsYN6FGaLYKdRzkLkz8NnoOEcisVzpQFldAiEA9EyfSuhMNDtZYhVw7Y2KiMtbTduIHEQoYgpxTv0Vq3M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfb711CRA9TVsSAnZWagAAFzEQAIb7Nh/GbikYxYpYLE5s\ny31vzOOXXpmP6r0OFZstRsXK/PlI6wdvT0orWsM39zTvE6F0b///OKUAEXeC\n4cJFiPJNoLTBzfs3pR5J/hbUKeDUQ5ofqXO0WA+Ct9iC0PQJjb3RlnO+kI6t\nMtttHuV6cKuJgWsJcn5sBoshC91EDG/+tDm3nIDRuIrqMgxW8g7iv5z28KPo\nMfUf3nZFCXU0vbZ0r/hx1AOhU/teoXShhd1HD2WMcBTE15EJDrhM2ynBY+ST\nEhu76nWb1anHmrnPiVWHXVybvUtikQnLb9vryfjAf/ZV26TcmVtJ2b9SJtsT\nq4U+4BfUDIoAKMNcT5OVmZyyWQy2Q48R1n1QRLk24iIxZhQlgOpedBEsUmtP\na57pr1TPguc7Hj/YpG87yx+GVQrvAKiVojN7YuujlKnk/9HKfY7OP8ec0HTU\n8wr3y7FPoPc+mhKdRvKg0Lios8cxicN1yX0SVgZZe9sohGxiwOxsynqzQKl4\nVEcd4QNE1b9tzS1Rh++9lOJVj1V90EKe16QNyHZonyjlW9p4FGHrYeU17Tp7\neF5gCt9CH6o3Ew4G8bFnZYmthVhjyUtsgoklbQNCvC25wS5ZJc3tKFMYTPlD\n9Ow4KowrPSC0m8H+YC+5vvq5BlqBDBKJ1cSFtDWPHndqWbLbm701c4FyVYLl\n5XPC\r\n=mE8r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c9afc1-1601158472785_1601158516677_0.33882276121253163","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5c9afc1-1601158474544":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5c9afc1-1601158474544","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5c9afc1-1601158474544","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bbf3957d25590a8f8cb532bd21fd9161c1b0215f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5c9afc1-1601158474544.tgz","fileCount":7,"integrity":"sha512-EuBK5OOm1X2H3kjErp6IPJwVkdUCx7QkeaZYSBdxQZN9y+FJapUwAeZi6IoiCfx0bUCt3iSj7B6e2LGzJgR71w==","signatures":[{"sig":"MEUCIQD7o/gxGp52/W+IxMklI2haOEzGsSNB/7tC/qlHZzc/rwIgbH2rUip+/3DCz2xfb/JBUwRXBbxTfvFcUUvtBaZajMw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfb72DCRA9TVsSAnZWagAAyWYP/1bU/6bZJr8miOnwUf9O\nCYukHK1b3qY4Elf+OSem0YzBgF8ssEeELJeJNp6rxJxENRxNpEexidNrXwDQ\nyf1HeRhIUUP/B+KNv8sozmYSp6klqEG8mecc0pDnHKZuL27OKpZLNtxr5mrn\nh9FVQx21c9iWZunUeWa0k+0iJWTQZHibJVumbAn2UU1CNuFcTSmWMN9uWBeN\n8HiM9pcCVlfXH/dWEJ0AmE9qEkFonnmcf9/YbCFyaJpYwX4AFDmUYXwEXdVW\neFMxma4oDxqbf0y5iG/0ZM2/v11+hgw/sekhZ0vMXGWhF3EjTLXDeCQ+JghX\nJRvWXx7yEbJahsYkVI9QF8IHizUzv2EWLPUeF2VG0m1BLf0Hr6IWvnTZTw1H\nQTCyUh/oEObNmi6/yAtNQw6i0ZbqLYlV/0+y2HzqMnSSGuRzTMe9zKmu8Fzt\n0HhZPg5UrTTNH1ZwDB/lr08fG2mzTavJ3wDGMGycsoIWv/JfdntLLVxMGvCd\nX8TLIJIVKV121NeNfkvbUwGKuVMGLwDYuFWW7fPfFHVzndljchY0bP5U9cDC\nFLRh8kpzbJa++JNMJrpWnPKSynUpsHfgq98hyrKJ7KMpBWkgQVL6cjnyDVsY\nK/5OK+3/D+6GLjhIYuG7ToYUODdvXSVYXpCtsXSPvTXKLPWPl7mpGCO3yhIV\nU4r1\r\n=PZyb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5c9afc1-1601158474544_1601158530955_0.3651440870963607","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fe7cb43-1601223881235":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fe7cb43-1601223881235","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fe7cb43-1601223881235","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"24dcfe7dfb381ccf2506005e18ed89777f7bc555","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fe7cb43-1601223881235.tgz","fileCount":7,"integrity":"sha512-cHwcUrxxcSXlYBwWi7tuFTPKuEmvPujaEDBbxNcPFXqbrNDbS51gE0FjI+LC+4aPdPLgeTUJS1FqwZsdkaaChw==","signatures":[{"sig":"MEUCIQDErLsVBUhy4fsJxEX2pDgGMEeAN3N8Vl3QDfostsyJEwIgIhVwClsMRcyEmtjWIsm9womulWDgK0yYsxpDcmVJ1uw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfcLz9CRA9TVsSAnZWagAAw6sQAICC0EoJBKf+AuUNd1Xo\nXFCkPVQEYfRdACbJMEQLxOifeTXgCiBSu5npUXs3G/cW5RCg3JW643UIU4Xs\nBT3Z0Jma3JepNQl8fXHzfl7LRlh0WgH1iKgbZojt92qxBTzuFPTDu3spvkYj\n5R4Jl9mFYBx0RFPkpTmatBwoQ3uh93R4+tbhow2+FoKBnAS11M/OeURueuMS\npvySLpf1U4aScdRc6vaOk8/AWilWYoEzLfeIq3Howzu1PhCwAAJwTV/q5o8P\n4gslUSApkZKpDZF9LXTv/mX9HH71ZeiH3w4nK7TRXfrUHHiX3Q1MkcOGgI0t\n71okNXssSsk40UH8Ar3Zkb2Fn4JYGvDWkT/AT7YQ5Kqjd5Bk+8PIN34ho8cu\nbdEQnJH7UVKEnDAboNCYsISQ85Wd7/XKbQxwjiYunINHxEf0KQk5FBLAxEZu\nMXEsl58ss2is915pn+xGRa5pqNM0AZ25Fm+Sp5T4SOp6pmKmFkeUaQfjNP3C\nBuCJcpIN+t2iDFHP8unTPVgmx6Cqo1OXr/hEj7gAA6H8Q080zbtsjDAaSb+e\nzVtGlkkZqbj97Ht0qQffOWqOmOAYLJ9MalIVXRztnTyKJDuWQIYcrFgMc4M3\nRD8iQlhgQrZXy8J+QrJtwXsBeqIHQG+lb5MtMIC2vvyNB4UpDAAOJnY6mtKr\nAc03\r\n=vhY3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.0","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fe7cb43-1601223881235_1601223932530_0.7420768000631435","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-54573f3-1601461240206":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-54573f3-1601461240206","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-54573f3-1601461240206","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"08e83ae902702be55146fb1ac7a7871ca0b7da2a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-54573f3-1601461240206.tgz","fileCount":7,"integrity":"sha512-ztvbjVZhLJk5EMy48v1V04z6MW2qVNc3pjqPGEb2a/bkowJW/SEylpPcUZZxUi3QgJi+Tr3mHyuWIyWElcmA6g==","signatures":[{"sig":"MEUCICsbOHIgjEPGIn9uw7nVpQbuC35oEWmeSPJwiO8DUeY8AiEAriVQ/XSW50lgQC2GOc50O3xxU4cm+rVBLSQQ0Aqmz4o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfdFwpCRA9TVsSAnZWagAAO74P/iIUMUtvnN/D0BbJ2guA\nw3tmTdQsXzyhKWH6Q3zEKTxU9YBln/ZDPK1Pu0fHZG9OAwNRxZcHzZCKnVQ7\nAgklJb3bIhFDFb6qVCCzyEaqw549e9Lebl8qJVAhS/lPFXls+JMxf7H+hmQc\ni9FjvUZLOnyv3U2TcoEl60BiRYv3C2VKij5C2ewn/J5+namXOjRHtX8ivyEf\nfCZjnM6z9YJLEI/1P0XnRFQIZwdEQdkQAFenefscHMhetfKgwULvMXhuszBT\nFQ0+kZybsaSISvB9PGvaHDEN8P9YQLRvVbFEOpVm0bun0oCDcMVa3pzW37m+\n/5h6SZa9rSwIZOz1EV05DJsNNcIKLg+JS8ozVRZgCXkDbwEUgiYkxWXoawC3\n71Q5alR9ew+mb3hK9wYrDoMyeE78JK4ZoZ3bUYevySlpCXdlw1ERpmcQNWUg\nwzK8TkK2H2EN5+Y0DZxHLWuh9FnX2fKmalgUNa0MulYdSgMBlPnaoeQCVmlw\ni39bV+iz5nyhMvbssfFYwGpVudRyHrxXfzWkQv4Iippmbv8F4V9h+LsMk3Hq\nb077JgapBoLnGziNdEknTZQlqCFqsvkMcbgcpVa+S322zcw1FjRAt9N95ZJp\nkfyjASSSB/PZ/Wu4cqLDTOFsMJENxE4N8YTnqLdZCVT7EKEp5AIt+YdeEOP1\nxv2E\r\n=Q7S+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-54573f3-1601461240206_1601461289458_0.6224392186020029","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-54573f3-1601461243537":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-54573f3-1601461243537","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-54573f3-1601461243537","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"549ca00ef334050c5cbcd57a20470e76c808e3ba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-54573f3-1601461243537.tgz","fileCount":7,"integrity":"sha512-xbPOd3UNq0xjMjEbOkmhk8Z4HH1FEFJwGzh3HhIeyg1XMKJQ7U5cbK9qYH+ZS3VHCuklzX76qPpMutaS2dabjA==","signatures":[{"sig":"MEUCIQDg3mZuuf++cjV1W6n2X+6jPmLo9X2JTA1KG+cnB9K1HAIgP1LS2u00QeaMYEwKfs1EFiBcuxOSVJFB6BRY1wSu/9w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfdFwwCRA9TVsSAnZWagAA16sP/A5nvWxTXZX6WVvliv2R\nWTsWou7H9TOtgDU9pxFf1W54OM2Wv/A+pzVb/AfaUzOo/XuuEBAt5k9y/T+b\nrb9x7qVR5ufo0Ek7aq8PjTLf1cnJGnBl/t+a2YbMnWXyTSVDru5Qfuhaml++\nF8Jkf+4KcBuGgrcD2O1H/xky1Lk4OUrDEsKBQlzGIy03+vSFPE70lIrMVM9L\nwJ+GJ9siEaUV43nR33LOz1b1YJNniAXzj3eJueioUwzFwmP/7desodq2OBHu\nIivWKAyO9RsqQ4ofUMYHsCap2WBYypPTjpFdS6Y8Dscd/YU5+JPw9u/0y1QU\nDVNJD30Qjx00LAOqTPx3KIKLmcPUbKU618HLY4P7ScX0wqv6rbpCwUYLStGV\nFvZMVRS8mUaqgTzpaZ6ZM4Vqvri4vGn2uj9NmaPqIcHYxiIaay7AChxUjnEO\nEUuVMUeT1bnoZQCAOrmEZadhW68JrsFJVZTAmRMbyXqZNiY6wiVWy0vBSHMQ\n4TXatCosc949Jid7gEdRt9jRL4CnCAhJw+eKXPymDCzEBLN3cYW2LLFIEOuz\nt5I5GlvYR3rF98Uf+obtRQrEB5CaLh3qSwNa6wEvX15d4mDdQRtiNekzht2c\nlSLxBBLa4Pw1EYHbo7na22742oN3FlzU2R3vucTUQjuV46o02oV6IMtSotb2\nvHBe\r\n=o0jP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.4.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-54573f3-1601461243537_1601461295791_0.08522770804127466","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0733957-1601948722979":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0733957-1601948722979","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0733957-1601948722979","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"324c560436dc63b130bbd5909f67103d1c496585","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0733957-1601948722979.tgz","fileCount":7,"integrity":"sha512-9vtDPiq16a1meV2OvAoqA/OjmdQ0zO1eX8KCjquRzrD4lMj2MWxLwKRXbeY2K7q4ZkHJtprDgRhGwC0oA06dlQ==","signatures":[{"sig":"MEMCIH2VWTxpnmfjf3QaVTH4w09Grsl5SAvvm2M69B1NQUqtAh91G+3RqSu8F/uHwzoNK6yLoaFBoZbBQJFxvOEl/2xC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfe8xpCRA9TVsSAnZWagAAEmYP/jz/YDaBDYPC8xi1/9qu\nVd9jf+jpTRpsqTbY05PbxxUmsoKtP1LRyCgi2BB2fqSPhgCBaFmZGxjtPHYp\nbCUzwjyBdsq2LNF25wFfj1n+gthwq+LHxSHokckg/wK65G1dqhEyXbb7EZ+/\nv8FTOqFDl1s1F9M9wWMsAfCgsxPrfpGZ48PjjbMtzWy2hYIIHC5gaVrs+jZy\n4TTPun7kvw+ij0AtVm7VF1xuDXF20M6mk7L+89SluRKSwW2Hdab/2eBCvK6K\noH1KX3PMnkNZk4/fCTdF2Bhq9GG3CmY0YEEtLgHXY55tPMwzC3gtNuzMZvLk\nN0+UGVlT2vjSWQhRy6sQ11tJik+8HPMYD+wKR9k5d0kpBaVgUePuhsXjF8jh\nLI/qGEYJsNd9oQ+ZOu2vGF+soZ1WXKHn4iFxpEbfTC+ECUaKTMlku+YZj4Zk\n3Tk5SXd0yXjB2OsCGBFz+NMCONz/cEjiy/c2n/I2TzTXad6LMP6tiIY+CAtg\nADQrmAGYJAP+rCR4+4Vt80ZcsaEJXfrXk0ifrZJONGe0bggzq3UpqFJC9awV\nVLXJHl+R6uN2lUuq6ZN7eokJ0KccLZHEaVKGaUI7iMBkAnSZgiSLRf+Lu7LL\nPZTO4P3gTLojSd0C2BWBzT27T9bETG7QvhWQN7N6Y16q4SIgU55LkbQzmv7D\nC0bg\r\n=NbnZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.0","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0733957-1601948722979_1601948776844_0.6953069161323553","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0733957-1601948726081":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0733957-1601948726081","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0733957-1601948726081","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ae3a2bc53b08028b222e0b52ca5c80673fc3f05b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0733957-1601948726081.tgz","fileCount":7,"integrity":"sha512-TCKKci7/qew1QG3Tr9z0n3NDJ6e/k9PsVuzDgvKZ77RVZ6xSjUJdR3pN8QjjkeqzKcJS1XkOPkNh8vf0ozwDTA==","signatures":[{"sig":"MEUCIQDDuIPpVLs+Dp8+vnCve8Q4PtS/kXJXUrUkuK0ZENJhhwIgWGBP3fdCsdV9Rw0Hy09Lj29/ri2JW6Gh0t1PQLghvHM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfe8x3CRA9TVsSAnZWagAAbzMP/jhn8JhEmkqlQgpt1APL\nI+Wm9RqfyAohJLbauMztU+eyJC9IO1aq9dTBnZHgt8dGSBqM7XZj5SY/6HJP\nOmswffTNBndjbo3kto+9sVtG8JOtq3NwSoylXvLk0e/UIS0pKCXiXmpORQBo\ncqIlYVpugqm+Uzy72oUS3HyLMgwSyvD+8xxGscMWe38tDYo1TrPmeY4LKsRt\n9upg9e1VMbswUjn6Yo9qfsboOyiU9y941ab1JVNQM3ddsF5ewlNUfMrcQYcP\nJO9bJa40hL6yNWfo295XGuoqW5uMW1FvbbH+2nKhoOU4wKT9ghgMYq8gCOJZ\nsvrwrvWrYGgSNz1Wn+PnNUigW81XERDPqOGHkHyKgjSBR6lNsDItL48OrdKo\nE8REMD7G1hm02+A13djuMaeziaSotNxN0dyOMuCBbiyXeZ4YGvosKmdhT8cc\nxhFulEsZuBQExVBTPuYOG9BoCDtBysFsMDdRLonpEzfY5/+43c92V4lsT1PE\nZJ1sO35U9LCxeVJJtcl1vNJY8URqSotZKb+Oov+p+k32iUup4od/nwyu88sx\nOP2K9QIuE1D4ZvZgCewkld57Wme0PmnVo8hd537kUKll4WlOMc/3wkRDA3v1\nMVVsbsnmbm6QCAv8h7JnXUtuLSjB91/b2B5MqB6zzfKmDA1F+SVow3EOLvzS\nca/s\r\n=7ai3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.0","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0733957-1601948726081_1601948791434_0.539440957886862","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-381fbfd-1602084705666":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-381fbfd-1602084705666","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-381fbfd-1602084705666","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b1dcf5f6a2a80619d359a4c5545fcf10d8ce0c10","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-381fbfd-1602084705666.tgz","fileCount":7,"integrity":"sha512-6mpQu/RMHRRlv05VeLm83MztSyu1Z1cN5VF2V8wKZuREzqzxNHrumaRsUuTzmGyztE8qS16q1PvibEj4+e6yBA==","signatures":[{"sig":"MEQCIGpusApxiKKU0MhFVPBL1Ep7ctQRN3LSgEdmNNfnMAxyAiAio7ZIc7E3kh+qV9K8GiXiJkjm4L/mN2nUDatR4x0j7Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffd+VCRA9TVsSAnZWagAAJb8QAIXiMqeVd/uao6llWC2U\n8Lejs7sPUKdyQy4jBIovj3rmDluz8Ck2VVRFrvamoH/uovQee+8krjooQWsm\nkwKRWNzRwCf95Tfz9us+T0lIvj0ypkrDdDl20Uzuv+HjzU/BmrgojPHpQXJh\nKLSdgONfP8td4a+yZg9F3iEM4qdkNti1Y3LFA8izcj4MZsMvc0nSs0hmWeuQ\n3AcwheGPEwvXxxiIAmBZP3EPBospztaVFy1exvlwyuxw82RFr/MCrXl3Iz/h\n1pGzyw0RbwxmZc/S3a2DfZQ2dH06lN06qjP4zpraKT3XGmcCjDgv5WJBQkHB\ndHG3IK+0JRgIhWas3UnDZz0soiYErGDgn6wjDcDSPUle2MqDebyb70ALHwQX\nEilMSz1peXoeg5GDPKeNaIzdKrp1JEoG78ngcC8A6zYSCNRS1ERCizBhkMeT\nI2Y47tXn4IcbNQO+BGyeC/mt8TWDbu1tTe5QKsqFsvwxgrEvyOEoPD3+QVKk\nReQa1gPAElyjyNN6fccILNJBb7zrxNs51f7SUcLsb3oTmQFZersowjRZpWXT\nZsIcWgGGp+Il/7aBL7gKY+wOcRN4T3h3YNAvYUarQhDfUJyMuvFRoLwi5Ruw\nYdhz6//OcirZSUhqNkKrO6XekDdY2EjzwvDpgZzRiC217K+MgyPdovbo8+9b\nw54U\r\n=RfoD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-381fbfd-1602084705666_1602084757183_0.13544168516391175","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-381fbfd-1602084704750":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-381fbfd-1602084704750","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-381fbfd-1602084704750","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d3d41241acc29897c86fdba734ea6a1fd88c5b1c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-381fbfd-1602084704750.tgz","fileCount":7,"integrity":"sha512-JkKaGl27HAUElPJnNFE2akstL9S30+SfQNAkwXSbH8rhjbP1F3kpvQ58UngmzVSGnkuSURede9cvfBSsOlZ8Zg==","signatures":[{"sig":"MEYCIQD8/GI+ibENNpQDv/wjTb4Mw/bhWQ7wH/Gthhz3w3H1GwIhAMBOvWOkg11sQrDOnfH/mEsAUrF8Rsf/YUyZtLoSUGz0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffd+fCRA9TVsSAnZWagAAunUQAItTOvtKKZtBXnPrX6ur\njL2eoOpNCUrBhOHAR/yM9rZW6JEDQukPUzF0g9Vr2MUaPCJpcasg+tdBuHK3\nHp3QjrZP80905Gz5IrkEkDbW//JWhK6uKfK1JLkqMt4/K4/O5i6X6ps2NvVQ\n59Muo6uJVZvpa1GGtDd1bhgPY3Gwfx5CB/Nz26qGovzzZ4Xv9Ud5BItpImb/\nxCzmbD/s81DCEKYX8H7+RCIigUe9QuxTjAWzYJ5DJX6dQTLzTHBq/FjBdsob\nwFWD/W+cGo+Jz8IHqNtLE/pF7lyGegM6WHEzcdvHW9to9WMXkkqV5kWcBgqm\n3FmoBVp2dySv7tZfpQ9AvhzFWLTMNLBr/sOufWqYkTeXsoVJR1k20/LXeRUo\n75IJ2UNrzkaUtxEekcPkZzW48CQNbyytlw0dMaOArXJGL88bMCl3skoQ5jNV\nhH5hSWuvT64AL6PRbDvNAmV635kg8uKNMHmrUZuL0Exwd8vZYre9CAcGRhbe\nLFc51J+IsOe+ikMtMFfu5Omn6qj8EabeGW8qMnc4JjRBFpImkG/d78P8zlgT\nP8eXb+jQKoWzkKueq2GY1gXOdUIeogXCkwJdLrakjoUzlMBpegevHQuTZACO\nF/h/Q3yFUv2nHaP0a1jD850AN5vqYV8ki9JXvoG5AnASdaFaBjIVaUI52vx1\niT05\r\n=L+cL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.1","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-381fbfd-1602084704750_1602084767062_0.49180406941816","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3308ad9-1602101761366":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3308ad9-1602101761366","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3308ad9-1602101761366","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"246a7091e435797a9f9c1bd686b518f13583808c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3308ad9-1602101761366.tgz","fileCount":7,"integrity":"sha512-A86/kqVtXOTz7h1y3fxpe5cLl6L2vVtyVpSUAt4c5z8rEOro5kuXOSx7mS05TYAcY1CxD1UtMrc4DZ8yqRXngA==","signatures":[{"sig":"MEQCIEEHlQXOZOnyACmJCwoYI0Vz5AfM7n/a39CbIQb2kdDxAiA8r7Wjn9kkYV+Ghn1gs5NX0tLKqaUanHebh7SQMi5URQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffiI/CRA9TVsSAnZWagAAvxQP/i3FT6CigRy/soOZMhQQ\nhrX0AJUJIppKTY3m9TIupSsYzui/WuCFJ6AnJ2rnDbg5jkQh5lIim87M79K1\nBr1inCFIagqEiYZZ/WZZ7gwQbYxr9wX77JpYjm2JGZtAIsHKUEMnnGUAyIKU\ndwAJhnSdQC/E/whgsU+kvrrvqIbEwFA0cNOLvo3rqgcCxGUPSh5UQ772YdK8\nd0wloWvdB7q8LmRDRTg1FVk1fsJ6e6C++vdU1Fp2eyPmXBSdyK9SANpdZSPs\nRZ8RHwXuScA7Vt33UJ6MbVUgZft25SJSOC0C8lKTnBinOiZpQF55mzBBj8Sx\n7mEcTHAkrlfxC3kYSzof0znweylPEmq4ABbeV7cd6QCai9DpXRWb+F9hSQj3\neXYXCn6hvlEHE9Gke5HqRbL3GpcThBjFovx6RcVw6gKMB1rDaD8Bybs3E4eU\nj3XAY/lC51K2jHUZahT59tDCbcon5GqFyStaSxfvPTLsYrFZwFEsf++pXxbl\ni4mQD6S4Q4d675kIGP1z7O6DKE0QDSY8V55TqYy2qJ9UBCWD2u32nmX/wUk0\n83C2hxPcvZU8l4J1HUbDqwoH7brT7/kA1SPkDpip6UlbB95q076vSMn5OoKC\n08LnK9hCoctk1h0TTcRjNSNlErNaMhvoQYWOkBib52I9CDQPCdBC2UWBjfMD\nMgUe\r\n=5Kpi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3308ad9-1602101761366_1602101822653_0.4869628952475611","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3308ad9-1602101764632":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3308ad9-1602101764632","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3308ad9-1602101764632","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"134dfc79b694883ecbdefd342ef2f777745e33a0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3308ad9-1602101764632.tgz","fileCount":7,"integrity":"sha512-MrQeyv8BmzlOaT4119N1Dus5+88dd/SAn3zpO1s30SsTLHC344rbu3WCR2F99tHketk5lZNQwPdhXIhbeB0peA==","signatures":[{"sig":"MEYCIQDnoIPE5WvGbdza83JAmLE9iqBCtyIuK0BPyWmPXJ5yJwIhAMqZ9ZUrBVmoyjWYFX6aXnKJLWvFoW12kGrrzVWnkpfy","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffiJDCRA9TVsSAnZWagAAeiAQAIAxWL2oQ0twm/4qoO0D\nUnRHNs8bUzUzRquG5gaiv+/idOlCnenpQUmM7qGJl5gz1mQ6xWgnnz1oSWYA\nnMAwr35RZkndF7B4hQ7iqcmhfNzgiUB0YWZtOFaQHlPo22iM0HGuDyHYOfNS\ndnG01ZnWtu/geQt/aLPwUG4R98x1QzPFysEbciSFVYwW6ZJVitc0UD2LkmvE\nWtbfR2kEdrOa5QvZJRRMmyrqYfgEXWazs8peJc4ipMJ3IBt5NF9DONKYPJbr\n3RCQ28L4KbdAh0Gh/1SaYcRTNAgv3qY7hd+RC4yl5gW70iPOHaQ3X3u6RXoh\nkmZc8v82dFeOwurzrv2Q7HxRC2LkcWwGu66x0s/9Igw0hUWH9u+mTE0rTvI6\nATUISJoPJg3+pLRiEN0NV0gj+lnxL5bOgqmmbOiXmId01k6Uukm1YOjFoUVK\niRqhnIvlpvBFdQ2PVdNx1FvWPqRCVvnPLHCG9qOZdMZ8M3hmf9Ma32HpSLKA\nRYpeXV7zMjV7XaYcbAp0M0HBjkf02q4Jjq3+hE5vy7MrhF1oXujEGj4Q0UpE\n5cIHhd3+6z2Kfkff5teRivmkUNZFoochlH9i4jqkVSnbWqN2uXjTMDlS/VpH\n65UqG2L+pMrKo3OxFlauiR8GOL4PPh2DZrFrtdjsveVV8MarovyoExO3e16d\nnijR\r\n=rwRN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.10.0","rollup":"^2.26.9","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3308ad9-1602101764632_1602101827364_0.5488258747061991","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3ec1053-1602243271924":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3ec1053-1602243271924","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3ec1053-1602243271924","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6f98ae7a20dcf388b1e3075e585ed5299d25a839","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3ec1053-1602243271924.tgz","fileCount":7,"integrity":"sha512-ODBh72IPh6C5RF6EYH+U0Euye8xqKQSAXFeXZuuO1AozfYCnC1cEYTUTTkCJD/QQ3saXA5uv+djVU+WPYWdaeA==","signatures":[{"sig":"MEQCIGxQL3K8C+Jy/VvGvYAo7yqBzyb6mQoR4/+W93YMfR4ZAiANOboKjLlR5QMjt/hSAoKFhR6rTQulKCZ6YRBIPYXVNg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgEr8CRA9TVsSAnZWagAADr8P/03eoBFwm619+NRGZXZD\nnND2b4G6l3RgFv4WGFtDgnP6JVPVuKlAjCM7hb8Hu6Sdm38quLjOi9dXRxvW\n0dvd5Z4iP/2/DIAQ9teLuL9Tfs7f6W1dLIM2AHsgIbVBoqVkej+bD+v2yKFW\ngV905XiDEo3aJJowDQOfqZWqDFkILZSx3hSJyY6wswxj8+3JbXL+p6jYHVxB\nGNXldyF8gD4n4PsUiBtbnHK3FKaKH8AC0Xu3Ca38OiGhvRkXvjVjJsPC35WD\na14vBTKYdPRp4VFJb+854nf9Vc3dCnVtN5agVfCUc9PwDz2b7FE4aeyddeab\nt12VoFlg7KFLYpNk2VtuI3tVJhnv6CefWKcLv0oGGwQJJ6MUGbiSNla07KIq\nGT0ZMhroUedErlhozjWNFEG9d/bYS3k852t8ZJcBGRmPaz5kUBKNOm0mRjEW\nYwpn+Uh469H1KAchLHlMPqMBYnFPN09Rpktzz6c+BmKaX1kje1wNuAvUK1tW\nNQPNmtO1dzbUBYaPBdkQdTqXg0ReYL6AHFBOcdFBDDar7LqbwfGLFbMxnt3k\nEJoeOEwT7augtV41Xylqr++RYhILgLMqCyHnatfeYl/vdO+ZG5yHkidI3LTv\nlqf1SfOAFsbfkYCEECr2fcXQHRkZiIl3npFto9scWUqZ8dWPzXqi8Arpgx9X\nidWn\r\n=8HdT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.10.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3ec1053-1602243271924_1602243323671_0.11848811123722602","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-3ec1053-1602243270932":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-3ec1053-1602243270932","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-3ec1053-1602243270932","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"05ba5bdf4d532bef46172b62a8b11c7c13ea03f7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-3ec1053-1602243270932.tgz","fileCount":7,"integrity":"sha512-FfpDvBnK+WKHprvRTGqVRcjH0K9LPI2nuzpA/5S4RCnDfnb6RiUPHVkZRCmSdcBomVY0ngiaTebd+nJQ9MuKig==","signatures":[{"sig":"MEQCIB78Qxz1BUjQFJLA40scHYaID4q36ZGmXvC7dXkWoRGmAiAfGoifGlbvuRJKUwi3C9vWufiqFsqtDO2ghZXdgWvJ0w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgEsNCRA9TVsSAnZWagAAqLwP/0nBiAaUYS43BT3vuyfK\nDUugGTrbEVbIP2/3smrPne3/ynvpS1iDARnJk4M6IoYgOqkTCb3p8JBctG3/\nwT4o6y8d+4tfDvzn7DLZpS/yZp/q9M9iUldwv+KVRe0Y6HrYIlyPMKqnPMwU\nwskpPHLTZkT3b1+un0CkbIhtgjIJJf5lHExZFCXwwvl+0fezUmUTUnypHCBR\nx52dW1XNXvCskz6KayXkF8sTKav8aHoXw+YPlY75ND7sezuoB/yvtC2SkA6C\nG+50pxuc3ywNOkOtmU1g9zknJEkYheqDHIm1iob4ty9DXkmhNBCgGXxaVqk2\nuLQ5sHsQIC2B14QpFm5y+eiMclstRGQXPsIF85xXbDL9iablSJ3OpKxU26Lt\ne38NGnQ7yqiL7mYEdt3XvqDIo7wQFpxFPnByDvlrbr3HjM0VYnz4D3lc2QY1\n5DUUlt1fTNQFkNXb7JXnDxvhW+Ou29ASp+MdlFDMCQyqzTW3X9rmBKebf/NP\nvNQMqztqOUWRqY64C8EbitrjhndDj3xGXGY0af22vPK+mOejEpnJHtkxp1qF\nbip40sBmckRNCUaXsexiQ8rjlVaW3V0JyebTfhQP9LpYv77znIEeBbq9SKn+\np41cQZPKjWPvVs5Ni6T2xjAHsFVUS+7tS6BfA4s/u5Y10Oenf6bvBi32Eijv\nEiiu\r\n=kFnu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.10.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-3ec1053-1602243270932_1602243340600_0.7766146259707094","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ab9ac0e-1602418192575":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ab9ac0e-1602418192575","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ab9ac0e-1602418192575","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e9ad6308d297ee56e1b079b8a9d834a9f37fc665","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ab9ac0e-1602418192575.tgz","fileCount":7,"integrity":"sha512-bnDOr+eCtIkSWdPx48cBulYvslQHAzzdgjEwBMOLcpSL5oMrlv2oQ+lCywYKoxHO0KAzcJH5q9AoAwyiEoeS8w==","signatures":[{"sig":"MEUCIQDbU0bQY31nyiM2r35A3cxNzN8P8fcO7gTM4NeFFgi1DQIgcO35Ui4ngqOOe0n1WEueh2gFOxdG0eaH+gJe+QNsEQE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgvZDCRA9TVsSAnZWagAAfDsP/iDZktSYsaFfZOUjYwjL\n4s8qmVihx9NlKjgYJCUX5OWU2fd2tcL9UreDHt8gTqXqo+qEXmVBgl9JTFuQ\n6ie8pQAuGMlMPh+xvFZPWAmIUpQd3rJb7SOV6RLyLI2U6BHPJLe8QEOD0YBR\nBy2GtS8BjpFLXAjmO4fJKjkETzi2XjiiAMELhgK7YNPqQXAJ+nS6kEqzrNxv\nNKWVcEY8N2s1O1CjOjhXxzv2JOvzhyDEV68B64siA0jdCC10hRHl4jVZUwjP\n76+3PXTet9IYUDedGCkP3M7H2SWqiQPtNuJoqvg/wpmS9HkLWCDf62z6Ex8U\nnUjowRKqtGlavpqEVBpOLzNX4m3ll0xFJTkzGIG9K6CzRRF6cotOH+y8NOiX\nzMColQMDZfX2IxvA6occmTKRkyeR4ugE+zeo3rm16lo8IM20OWZ+zNA7VF/k\nf/mw0NBOVk/S0YfN9lZgCvi9N26njTCMDFdDilNU2xz2yo/tE3nNIsXT/XRY\ntoFxmp4xEkDEjnyGi/Tt0yA6T5vdA3B8ZvGNeOcBRBv1vzmX3HnD4GCXyMgr\nmYFoXAEai+faz0wvmJdm4NvjQzEi69+b9Bp3p7EFU1YDMx3vyt/MaeNeP/Qf\nDd5la2kcyqSqQZ7BwufHgMAcIRn41PsPLVblAwigSV1AJjxNqkEmEOEqVqK/\nSXeR\r\n=aXjp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ab9ac0e-1602418192575_1602418243105_0.5940817749207172","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ab9ac0e-1602418192166":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ab9ac0e-1602418192166","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ab9ac0e-1602418192166","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8c4d476d6ed617f7a898dc8f6162ed038870f137","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ab9ac0e-1602418192166.tgz","fileCount":7,"integrity":"sha512-38gqnQRm0HgKDE493UNLmhl4E2OGmuXVH9rC9cOmVRYirK11ujVr+i2rSixbCoWcQVWagBnJ2hFaW6WEnlCeEQ==","signatures":[{"sig":"MEYCIQC9HNB+cr62BXxG4qGgc4GGHJdsBWMigl1vvZtNufMOsAIhANHyrBoTNIzSelhuS3KvYkx7hl+Ii/XUWH5zG3DFh/iT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgvZKCRA9TVsSAnZWagAAxvYP+QFLM5DGTOoZUZzc1Q7x\nSg6wSQNrxn/YHbsQKqGrdy3ovLuC7bdUczYBcd0CDbOb6QqbWIXEMszTIo9f\nNvMhscuzrW1+ggUTjA0x+iLFtEIdnldR9WMuJejSILie3tcUw/a9WMwRwElf\nOoCaeGYEIjQlYdOrd4vMOXBRtVLkbnAi/n7atW63tZ8bqZbUJtNSsrX66mrU\nJgqWGFAeOC1/iUIBXkKFZts9P2eA1TuwsAJJtY548D7bG8Om3XAv3wZcUbnc\ndqO5bcdZbhfBk51C9m+8RxCKxn19p5QKxDzQ+kCjaPhWzaTcWsKmkw6tCx2l\nrleesOZjd+7k2wsY2sHuiLMZ8pQKmaKLQARNNonREeScI8FUhqDsAwzgMEpj\nT7g8dzSqTmqM3kI5tri/AL5OUJoAAmL0ZNtQF0qBl5nwhdQ0m6NUHF3NN2LC\nFZ+xN5W4ahMa8PWTES6n760tIgFBqizcMzbMBaFxSptMayJZoPZR5vU8tV7o\nmzxo0mAojCR8UI5y5yzqzF3KxS2kM879LfJuRsu9xHaA/xLKM4rCWrB2f7L2\nD17C+81vOna7VSn7E1zTCvl6clECuHqP6XezrK7kBibAoRymdDl9Ln1/F2AA\nN+Oy7t46q+Oy7WzqcY/bu/psqlB3PGelqo2WJk0zwFrAKPRAA0poX/Rj8SIu\nAMse\r\n=9r3p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.2","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ab9ac0e-1602418192166_1602418249881_0.8354234568119852","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9fe675e-1602425573579":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9fe675e-1602425573579","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9fe675e-1602425573579","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"719112798b82b7e656bd5e4efa1b05a837aed3d8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9fe675e-1602425573579.tgz","fileCount":7,"integrity":"sha512-+160QVYTXclcjNlhIeb7SJ6KRKm8faSMfQQr2wEGrzc25wEAc8nImyf1ZQPr0PU8pSHG/plaUFOdx/6bbEsnxg==","signatures":[{"sig":"MEUCIC+cINCqKcbr8vo8ROPChxamAHDWhJmqXubWSBV6NxYAAiEAz964jU5ClM0S2tYXDOnTmgiBPeD5ASt++6xSwZyvFpQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgxMbCRA9TVsSAnZWagAAloYQAI4jBsjzWmyKrDD73mS1\nAVInRXBI7Yb47fEHxkO61WsEX23eXA15Xs4dtDKi/HzcRivfye24RB4PSspw\nrKoMyxKNTy0PSrjz4N82Q/KSzuoSMbPPjnStOsLC+5HLEJIcDymH7DDgIQZX\nWgY3ZH0mooVsrcUeKJrwVkFoB5X4iqwYtlNWo6X2mS77IPIp16Cb80pj+Z+G\nbPNeKjr0sYvPzPuLBimK5oymz0kHsNvtiLNV35sJ0UopOUKEMGhuY33TQZi7\nnsP7YjLoKVUqS12fX2HvCJKJM5i0kdLlkQ+njAYf//P9HcBrw/E1StXAoCt0\na4WLHQbajeDyN3YQYg4B7/FVJ5YKfKvJadNXhPwd3KOBZMwsSVitcMiEXQtD\nfEXC8K82PILpu0pnXFtWuaDxmYVksQ3n9vM5ARgWrzP+1WapIJiJ4R65myVM\nRe51uutnC4Kn2dpst4YVD+adHhpWuBst1stz/r3uKO/S004f9lfL5iIIroEy\nx6Z2PU0d8y1eXWaoR3fNb8kXf42cEz7XaYA4RhddbiFluKvxygXzrtl0m/1t\n2fH6OepDF2+usxzyZTvADalkeeqRX6Zp6flmT4rXSfs5PflvWVtVsUBND3DB\nVP0us2wxPdBou6mAyLIzU6J9xIxHpOnUsCgipk5KegR7yaqls0DASJzsGld6\nEXmg\r\n=MNCz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9fe675e-1602425573579_1602425627260_0.864762892743792","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9fe675e-1602425576737":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9fe675e-1602425576737","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9fe675e-1602425576737","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc870d76aaaf98d882e5bcd9b4f5d9c2f2845bd3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9fe675e-1602425576737.tgz","fileCount":7,"integrity":"sha512-nu1jsn+gJQZ/M/j1vShqZr37GmYCqBJr6StzaMJDaXqh+PQce77Y78N047EL/3gN9sFsTbuVmNSCl154xj9lsQ==","signatures":[{"sig":"MEYCIQCo0r4mWoRfyIa/7DeqYSrSWFFrBpDY1q1AoKKbX7E8yAIhAIj9ib4NpNc1fNnQWzWJZOVT0tuFgI+seD/RA2FvHgOy","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgxMuCRA9TVsSAnZWagAAgU8P/jSoKNYAZUzIXIvpUWH7\nJfNRejLjth7UCPoO9/2lXCwzouNmFtToU45KuCKWX3yyePacVr82Wve4gUlI\n1PiLMSxSl/Jl1pOBiXk13YY9Ol2CVL+5Zq8yndVbockFmfJdCR22DK3t9bmg\nl1Bv/gFfBiaDlG+CYmyZ411RV/TisiGDLdcGjRXBCFClB59/ODV+NMlFXPZe\nRjzrynQ17JXPN30gpck7Fvpov03i/6g2rbVUzglwlqhT9KRrMC8z0DVGNtwa\nsOc7m55+pXEGoIj9eBZM+3VlBx667el2KXYa8MXzQRwphl4fH+0AJRG55J+r\n3JKGQmiysOEV7VSjdbk+iAe4BLC0FdH6JOIsDuZeZa/rcV62zT/P5Q7Ii4TT\nbRozMdgHwsvQ9glufgcY8mWewkwI2ZNCtheYbyaEcUk99m8fGztFdvubYpFo\ndYG+vMW0CaqARSY21JRp9dxNtQSwgOAiT1PP6kqOaMTRqRUapop886hk2Plm\nANv0ghM7GyZU9DNwgMBhNEOoFFGBfCFwSYMEWmMBMf2cMI0euRz3Eu5pWtZ4\n5pjip6pywwCTzC8GdcjqoLK/JcfQNjOMJVCZ6B9839TnHpy9lp8tnf5jj2/j\nV8EmTQuSgBym0X3Wb86vsaPrHBhIJvl9J1wdt2ckaZ9qa/HEdUIhoXxvFFdz\npx78\r\n=GnUj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9fe675e-1602425576737_1602425645747_0.24493895091513718","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-8e9ea46-1602439728465":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-8e9ea46-1602439728465","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-8e9ea46-1602439728465","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c8cdac098ec5a48b5ea1091c775e85edb14939f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-8e9ea46-1602439728465.tgz","fileCount":7,"integrity":"sha512-Opt4HKzTjH9nq13NNRD4XphNHZzNZem1u/LjOvi2fiHVMCz/huaCcUAf6IwBsGz34PC0zIRyHgm8o8pukxJ3PA==","signatures":[{"sig":"MEYCIQDI+XT/ccJFjm3muVcItsvFfC8T//FdFkd2VaMMQ5ZrGwIhAOBd9iUuIje1M1wZiYVfTbXnVvWJitfH6jtITXjN1ROm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg0plCRA9TVsSAnZWagAAq/QQAJTtohrX5GKSseCZgQPc\nlr28HrXDnPbSM6zKbN3LTIJonyMA7GiEbU1RNUJ0llgMSy4Ypw729xy8DiEg\nnbW8rcBhLJLgH6UrA1Mudwi6TG0LIyH6z1zGbQblKG+mOXe47N3f0KJ0qqDj\ntdjqE7/Gsb0TdqBGLG1dGCdt/Y3oHpusF8Z/6m/Ikoi6nEGp7sfBrPRmlKCs\n4bsuJ+IICvOlUDmYW6cKeBDa2klrV2cyhTjNElDcGGTgTSkkgj4p6yjkMSVb\nRNTMIg87J90dpgc2U/SJVRd5OkiXoEcUnyBSb9ODafj1PiaFphokcnYq0anV\nfvWXNuzbhTGMQhLHzVSFS79kB4S+2EYD3bE5j1cBD1CJQeTTLNE7EqS1N04a\n9/8oOOAtOcuLda/IGIScaOK+7Z2oM/r8LbBVog6i+WkoLW0Xgd5Cy7bM/Q4P\nJHaXJrBuMfaSXclPDwLvnU35Yi0jsKeEMys4OLS7bMtaE+aPNcP2nbQdeyEo\neVuZOr5E9qgDSQiMJapAadJ1KJIKLCMiYee/F5yB5v7ndvDluPak9Ew6EXB5\nPZHdxHDLoZsA48vbKPRz9L3fDX1CekiqA8AD5PjOpdxf0uXquP5gQCAfeZ7m\n7qPPqZNoj6MTs9QL+txFjmuLLYP5d2Jqzxpita2FbHBCQgc8N/yVpyh+vE98\n9xXi\r\n=Na9L\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.2","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-8e9ea46-1602439728465_1602439780830_0.887427669078229","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-8e9ea46-1602439730529":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-8e9ea46-1602439730529","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-8e9ea46-1602439730529","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"90c3fa919ae1cc15b9512c6a8c7ccfaa786ee5db","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-8e9ea46-1602439730529.tgz","fileCount":7,"integrity":"sha512-v5wU76ZN6Zji4jFx6Q4F16XtID31S5I7XqCd6/cAwNJa/8wBHjOPymQoCmkbKfpaCaaVUziot4eNnMSqJay4GQ==","signatures":[{"sig":"MEUCIQCLMCmZOU76pzNtIBkm5htMXNxvAsPZyEGR4bWQrFcAIAIgc1dFvzB+cSmuQQtubh1k46c/JE7jkdmKTXb+SO6l8iU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg0p1CRA9TVsSAnZWagAAIAQQAIeUoWwdH1wg+H5tieZZ\nq8NE6P9UHRtZFhnF+CSB7mHbCvdbUHN1/D7THjHwoS+bNNf7HYgTyb3LnZJC\nQmsIkqnlB9Lmw6x/818MQUtxKw8J0FKLkKmJbRMbsy8/RoGnO6ETkwp+YDbL\nl/Zc5chLEIP/8C8SsAMbS9pQZRFYMPluun7jz3f7OUurVSeiaJ7hcnbr6J7b\n4SdrOumR8hOf4jl/f6A2IHWgMMjx+jC5tNus1gTm+whq9ff9GjRDn19MMtq7\nER3L9QHLCHO3sLas76p4aC55QxeN9o25+2K7BsJcFj0XBF7iGQjcMJPJb6FV\n/VHiIRW/Ewg1Q4Qk2h7IXsJ0663DMv+BGTqDbVQF54ADvQI8K9+GebH1CVIA\nhPyOdQ7xrBik8sRbz2+iHrD+92EOr9o26+Kp/P1+MKswgX5CUN6FwJhBRIAp\nxV4+sti8mGf3K3im9LDyMgeTuZ2qVKY69ialEePbD1dxxaQrjg1Ag6rFa5qB\nEfzwGXD2nrXSDK74ZNK6RQ3iWefNF77CZKAE67CIKU/OoxLw0170Dt28PGn6\nfGCYM/qsC8Bvcjoq3TamAeT5uxmckU8IMMjaRbkNtu8krPeVrfqo07h4Z/Pc\nwkLw5wXoc2+qOQ3UnGoaHc6ujpk+eVuzdHvPZVVefKqyAoLZVxq6QcN03S07\n0EFH\r\n=86CF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.2","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-8e9ea46-1602439730529_1602439796817_0.225735963418483","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c96f4ba-1602448353930":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c96f4ba-1602448353930","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c96f4ba-1602448353930","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3ab2bebe497346df56d314b73d08ddceeff26766","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c96f4ba-1602448353930.tgz","fileCount":7,"integrity":"sha512-JjcaoIwx4P0lq3BKiuXMKs0RllKUCOvILRWff180vlVyehP2TtwT8k29R8fmaihFlujno+McNsIlaa52vZqNZg==","signatures":[{"sig":"MEQCIAvBLXo45JjPYg9nkqXtv86GTWYwrKcvpcPzREbgKzYJAiAdF/wVQXP8YprPzUTQGkrH8jmvRRE5y4xidUIG47DXLQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg2wWCRA9TVsSAnZWagAABAMP/1ooM+hpUPTv1QoJDC6I\nFddCn3TBww4ur4u4lfrIkBTNKWolMoUABrsO/dt6rx+cC/GZnjfQskXeP/VK\nAOznvQ4S2pu1/KPr4RoKh9hAPPEQjHEj9nd4XPfaWMiRA62N+t8y1dxAqnHr\nZwPaeCIFLg4skaIX24TZFkjHd1cHldTvdsLfezdPBMHgHi7+i7rzYT0QYfJV\nLeFTQvQsaI1Hc/RhrSnNxCNnsc2oJ105XgYcAnVRUYWoq6uyRF0e12WOMtgC\na41Itnf55hH+dSazytWWnozEn5QE8eqmbyceTDVhfvIe8+PJR7m6hLAyGgzX\nmOFUhbD+yhzgguRbBuV92e1OO8mRqKAtE0uPv7jyHNCXrxlPEjfEEmCKH6N/\nE+uSLyobHA2RRiM6pd1pdRkT5p6mm+HCKPWYdI0TogyI03zVUAnEgLSRpHF5\nxphhAYrQICEoK9RxsDbuIfNW5i4yclR5JVeWvq62VwtLasNtkf25qob1k/V5\nEWNYtiXxHFQ1mbJNsF+PYfqVQ1wW09chXPCIdkdvAwhGzDtR6+U0e9MQZq8s\nqgzMyvjNvHPVK/yghmPSlQFTiEY0aJbgxpqpZHH0F++CFMEfN/HlRGkJA4sx\n210AY0ebtIBciaBwsxdNx224+lbPItxCETx+zoihXvwaFq5p1zaPXRIEmd8k\nmJmq\r\n=bOP6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.2","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c96f4ba-1602448353930_1602448405670_0.910963536546274","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1693660-1602448357683":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1693660-1602448357683","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1693660-1602448357683","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2e34e381ded72ff1951b818e747c8c7b2e08d621","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1693660-1602448357683.tgz","fileCount":7,"integrity":"sha512-mrCiyOm52KWftpUu/jgSXYRlhk8oJS1a79fHPcTpjeGfI/bFL4fNKxfmz8ddz5nkRdmOhrQrckjNYNLZ/B4VhA==","signatures":[{"sig":"MEYCIQCCbrPUhfryIqbRv0OKQb2OZzZEb9Hgx5mG0GHOQXXdwAIhAIrHJbujn49+Pf2iyN6Ry81zvb/W6MVr6xV1CGqTaQrG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg2wnCRA9TVsSAnZWagAAvwEP/0v+1Rgy3w6dDSifWVCv\nwi3ioDgcvwDgWVU4YiUi1P3Wxqw47rX4oMwk1UbZvD7KoqfXctV1+Ryht8RM\nnQQsPZOuf0cTAfkiWNaL/UN54blySK/KhZWwE6I229cfogRllN+AgpCK1lqY\n5SIPBEK5p/bcVutQ8/uK0HMheHa4zasqFHIIDMXp/nI8ZO1MNMAB33MYqbrI\n35/B+ZOuXerVAYTsD21GVhv+DPwcDInOJI0Y5VeC/S7aWrXZAZPTzHVaBIAl\nQorBJe0lQK/yFcDrd9A/GZj2aNO8aahT90HBe/+WZJq2eUObFyFMzTvSMfZY\nx2HkmbJb9raai8Ps9W17ln+meZziGJ7dpPNmDD/m9OI1Ks3Cheb8j2imvGgZ\nOm6nmZSqrs0BszlZNBdnlfkmpWWGJT5asBI5yERAaAjmg/9hKi6ki7r65D6R\nHxuFTyuSCgJiLjguYT8fyG/x1VrjCW410I65TtZAFlnZZvenHMmD+d7Hjmpb\n3mQwX1AZmmiAY6c7DdqLSOnCjqC+mj7DwvufW7jUMKVnjt2N+3bz1k95LETm\nGth5p96gskMwC2vqGs1EvcAdId4SGc4XZb6VamP5P6cNuyx4zGNT3zU0HVN5\n/o1F8HvwcAasBT97Nl79Q0/ynTL3exj+GWo/WOW6wlPTgjPEP9OkUvJupSF1\nwiUe\r\n=dwT9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.2","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1693660-1602448357683_1602448423437_0.7173082739297745","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-0c1a65e-1602448552513":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-0c1a65e-1602448552513","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-0c1a65e-1602448552513","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f317b682b28a43eeb5a6cc7adf1c1bf7dd2089c4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-0c1a65e-1602448552513.tgz","fileCount":7,"integrity":"sha512-rClvVzlP4iQNZrw71lQqBFIts0zPFp9e4WctsDBuKQSh7PD12Hbpwkzcvshdx7iHKFlkeZ1NvtRUxu8uiGO2MQ==","signatures":[{"sig":"MEUCID2wgpnwxO4NkT4KwXBfkDPbqthhTUQ8QVX+MD93TS5wAiEA6OheTq1Epck6Hn0FdE8mBtIMpsmcImhxYTcmFef+Ilg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg2ziCRA9TVsSAnZWagAAezgP/3a4UOka2lyquinA53Je\nt/rdjouP6foaz0O+t2zo2bUpsiw6g0SrXx5uUuurSsoffP+rqP6QUwVA03Xa\nqQnaKvPto0udPRd2UsgZa3X2wZjcZSNYGDJp8fPYpx2K1nxN9TbbJigEEqmB\nvvSe3X7Yd3CuouvXM+Zljy4yhdAC0s+44o4MgzZS8hQjaTQIbZ/EB9hl5jKa\n6LmeUaqyU/cM4BuUzyH3TzWJRDweE/b7HBeWjRlhxQBej6i4LM8cjffZEHCc\nYKb84hu9zJEEp1Z9SifjYvyo9RPVkiw2jdHhcht4sjodpHw4DPRYkTDmGAOy\nJcPH6Lzfh+a9q9O6ncQKmnJkDBexp8BKC99t5n3E1MgdWRdQtH7+V0x02hWG\nb2SJQF5/KTY7KOVLrkJn+Qf0lqmmPX91YAaoxONqrkclbnvLiTs/7Q2iDEBb\nJof54z9/RCM8pIDnZUxyab5jx8PTqxaUQHzrntgtyrkAVkXTO4z43i/IvoMD\nDZFGuD1+OUEeYXFQJbFC7j33FYPbfwzvCMSlMprQwQtQ8a7V7iHh9Hxoghkq\nrn4Ht200V30hkiwpoHxtQfAKFxn9XUe0G8SpH6gKhddKVZ6TYe4MfqUaOcUw\nYH3lmOQsAAt2+iT5QTMPYnSxNZ2gs1zzHxUKYtKujy3A5Lto+RJIue6/ALW6\nmfso\r\n=c4b/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.29.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-0c1a65e-1602448552513_1602448610482_0.09086904361955606","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-152815d-1602694695133":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-152815d-1602694695133","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-152815d-1602694695133","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f753da9badcaa4303bee7a8c58fc4e4e8617d48c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-152815d-1602694695133.tgz","fileCount":7,"integrity":"sha512-3s/zktK4JwIF9zuNRgiRc2lh9YUDYsj/mvg/GKqxC3isQh38yRny6A5tUCSFtq16QvS8tbKURm3G12P/AYmfgA==","signatures":[{"sig":"MEUCIQDbvlU3AI6sRcGwXuhSU+cnKSoalfhwgHhgt9DlYqKzeQIgfL4w4IAhBgp6YGX7MD16r0z1kW7pGKHg22J/vLcHheg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhy5XCRA9TVsSAnZWagAAufkQAJ8hi2XkiwVBHgajYBOv\nPCMnmyVRXC5admp1jQ3drYXGEC3WrO5/41PhotUtGndar/OVRuxpWvasuFqJ\nxcPjKzktGQB5WvOexJEH2hOqGOVbtP4dwz8HFAOESP41f+tVp909ZbLHQDGW\nX/zYkaMdxzhbcgeOhM7h4aCgH8E+tEsb3r2+xaoELylJLfpsQKj4fS9pG+lD\ncf5KSjeNsjmWJXDLhedLK2Srl80VzK0cYKje162SXXHpTN33nvkXwQRkk2r5\nX0Q//OyzrU0LcxkaEp/Et1Q1OsLntDS7asO3j/Ys10HA7pVrFnx5TZ+NhcsC\nN2NFq+QknFG97Ew233H+ax3tsgXPr2CNiYKSQDYNfD1FmcNjT2NL6NA93lI3\n6uQRXmaB9Q9fboiH86RbmoKib1s7jK/mXh1RCk66aOTGI/edhI4GrmTvHefg\neQZKLf4Wsfg85U+QFAIAMsqHzltFBUxj97NVP+1z7IaqJN4pkkFlOwDTCky+\nJOCu3HPuDyDsrg6jZNHAEtlkNj1ubLxUI/0GZmwaCi2ByIsRJKzIfGy4o+Jb\n0sS1CRo8HVqwrnZb2RjVRrB3AX6oH5yHsAoAOT5t9BLpj5A1CtPzDBj2wbFh\nMt89WnqBhNknyEHgxEwbtFK9lsqML71mrUkRVlcukvXe1rwnjOHbvP0DWbFC\nkM5W\r\n=0taH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-152815d-1602694695133_1602694743278_0.7278446704891286","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-152815d-1602694697256":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-152815d-1602694697256","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-152815d-1602694697256","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"44a4915cefbce553ca890fcf7102a8ed0ba2f80d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-152815d-1602694697256.tgz","fileCount":7,"integrity":"sha512-vy8dGAtkXz2i/XA1U+BP+I7KBa2ZAvnVasETXJNyOQrGEqC+CbV04eY0AB/vkDM1/kjK1jKMhiTZbI7oQyPtKw==","signatures":[{"sig":"MEQCIFrzmIZm60ZwWXPhZ97h20WaW3opm7qfWyP1uDDLJchhAiBu2pvXOR7TCNkjHycOuriPVSeca6tG07WWGf84Ti1brg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhy5gCRA9TVsSAnZWagAAkssQAJddiMSvJZ9NuVSrjP0g\nP8+5PU3fBY3OVpHVkq9Vcwax2zuKRvvZc1p+/MeqnhZiR3rv6cnoXLWICPgZ\nhbLCQuWlpcnwbJhOwP7eRtepCr2MNFQicty/+m+1pok0GtcyeRkeIdwuEMHs\ngb6djr193TdJVr4585BZvOCdCI27717Rl1dVM1A2NkE9rjRtKIL4SFxx0krH\nixoUg2prW3PnRzj7uArGcJDR1mSNAJ4ixKYHngzmRMNT4IUuMa92yxESid7a\nvSnpSG/PSWMK70XPvCWur0wWG4J8t0IXtyNqgRZgbqot2QAC+7jEh2yEfbbl\ngx7D3KrjobfWGuFC3neTQKNGWzPySrOQoZxzvO0qHW1vumcBjkbtMdM5CpJZ\n6t/1XTCCWW3WMWTkNng+oy5WEVGhE68BHkYCQ41saz45jRNeA5i4aj7YAD6w\nfWg1QlFpK16Zga24gtOIEwXbI7rhwDETTFCYwADJ35p4NPsbLAiHKAV+FCg0\nQq5YxT9vthdyH2m7/9f9JtjRj2U1N9SR65oJw6pRJx0zGralkKamfvTJ+mSR\n5JXsVcVUJwOxVeV0IgzYTybEaZe3JZFsRL6yqFPjlCD9XXJGQwmaIwaQfZJx\nfShtxLtEWQh3Z2rKtTTQnc6b4qodPKb4wajvA42ugah9UvHvjr6vN60Tnpp/\nj3St\r\n=lTcv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-152815d-1602694697256_1602694751708_0.8563146828542647","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7beab2e-1602713711468":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7beab2e-1602713711468","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7beab2e-1602713711468","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"185d9c9bdc7b69185dd7044dbeacfeef8043b35a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7beab2e-1602713711468.tgz","fileCount":7,"integrity":"sha512-4kV0a+sNc9cGOCqFaEHzffQUuYGBYi6cEsXuxfsMlcA18qAILGjc6vtlxo/DQMkH+jaBzz0ggJySZweaxBU/zQ==","signatures":[{"sig":"MEUCIQDsvNaPz+sTRw4Fb+rZB3ch/zyi7b78Mxgb+IlWZLEUOwIgTt58NONMLLZhQUML4buHUSAEUDxZPLGqN7tDJu20trc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfh3inCRA9TVsSAnZWagAA4wgQAJsFcqsHpr+QBR9vXcRz\nUWK6m/xfii0cj0VET1IiM5eCoWk8f34DkBHu1j9NIYj8s+ykN1ACxcc3a5KV\n/mDarC6WGiqcNgnxE7FTsbfqw0dI/6Fd6v/BfTTblq9HzeCipdhqszUJc/ya\nLdJoDHVKc91vx5ZS+qi2MJMUljQuQgLf2qob/dfIcmtIyFREEYvIQ5eB+im9\nJakiU4u9as6Z3MdABeRoTU16Rmwg6GZRIh5CoXKTR4qN0Occdmm5/gnRtR0Y\nPiOlyV7LL4wChrAxccSXX7vchGWjTgNq5FPxP65qQD6ODIeKOjN2KRpZOBj7\nBvd4q8cFWfX4tIe8yf8lUJ+CzHU3daiVyyukg/aTev65dlUw0ajQPoKOwXro\nkeRtHBBiysLpzGPPdoWj5TmQBiGwosKFJixpqubRmlqI6b+OFYPGoZ2QB0ua\nxT0F8sdairpB0p9wHoj3766qyowtk12/FAVCALyxjMzEtj2mBWUfOolYzDAA\nA2YzjD95yhNnnHn30nHz9KdWIFEDQxVII1cibcFch6VOiLP8+Gl47rAn2jkm\nLiuANSklSyvFiWo/hz3JquZyEOR1icnKuW5bDkWAyvg9siB20ta0BNJM/rjt\npsk/GkqCJnqnvL+XVcMLJjLzUugaNmXDbg6uExRQtMyEuFT/Y7zl0uiguhfw\nSL++\r\n=p6J6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7beab2e-1602713711468_1602713766519_0.6645941013186751","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b5c481c-1602767725686":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b5c481c-1602767725686","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b5c481c-1602767725686","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"afb38f6c08307a0da3e29b751a4df0486d20759f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b5c481c-1602767725686.tgz","fileCount":7,"integrity":"sha512-/T+514TXaiR+d3MQQcdNP3+F2bRm2GvZvKpY6Iy6sKQSlzvV47iCf7sagcpjZ0Go7o/uWzqZkH+i4o7yVNh5VQ==","signatures":[{"sig":"MEYCIQCCEcMemG0TZ4U2K2rx0u5Va+kS5E9UaJVLTTh8TcIxqwIhAMiYrhu8UP90lDuqx+xe4H0cxl/Vig3PLz1jAqOgjWQT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiEvACRA9TVsSAnZWagAAU0YP/R2+BZHJS2bUSbJMPZRm\nyKJ9XTBdsUBTdeM794Dh8dW5dyZ70w8QUGNAjk1YWILTFhGPJnvlx1AFUzMI\n8uogJ+N52bN99O38cLyE+ap2nI7crasVEXJunF1+aoO0wIg951j72TDnfsQ1\nej4e1EHGCTVwlF9XB+wL5843rT0nSkBV3qz36RLLVvZ/O/ZJRx5JJUQJKIDN\nCc8Arp2XW/dBof1jtU8fhbkYINEsOZVcvXEg+AuXDrj+6UQKNW5eCJFVbwdX\nVZBLCw7zQGL7Uf1S4ioMjSEzllRDCCpJW+0jDKe5my9qmNfEZSFVfrnb3Nnm\n1GGR9RQeF2n1SVPnI5S5yTWAvDPtPYs/ph8E9ATqfCD0KbMyI9rfdzO4siNp\nNTjm51Ctm4fquARdoh+kA6qkgy+dquduwBgyLVKchZNKYOheibL2K6Te/fG9\nhTqfmatzHynAMIudCQuOTBl1EokOUikoPY82zwrQrmlJcxy605upKFf4z2AI\nVbq250lAzCP4MM0GTToTFCaCB4HsRzqbirJtEBe0cRcwr0X7vWqCJ2zEaWSR\n/s/YquFc1CRWx5jd5zL4p/TuiQpU9kQyDYajo/x7q1ubLKQKP7gyviFJCrxg\nw5R06ZqJZlbT2Azmx96EdxVYjXc6hGfR1cjWb2kHhxIRTQazJzjDsPikhXeF\nRJVR\r\n=mk60\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b5c481c-1602767725686_1602767807918_0.08308475709713758","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-33e7e8f-1602797116973":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-33e7e8f-1602797116973","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-33e7e8f-1602797116973","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4f52d62951ece637b83b4f6b78189391e6a27189","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-33e7e8f-1602797116973.tgz","fileCount":7,"integrity":"sha512-XN0NN9m+AHah1xcNa6uuv7f1a6asZJhOPnnUGa/NZTwpAtFuWyUGfPjg9+0F1dV6GoTMxhSAD1bIvYOfHobloQ==","signatures":[{"sig":"MEQCICgtp3+eyHZ19bNZY0zv7IOVWalCowEA4p5HlXYsqi+0AiBJ6ND1EE13p7sQ3M6C5Ybvs3X2nvpyNFtQz5xx0hF1ZA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiL53CRA9TVsSAnZWagAAe1EP/jsGFoXATc9vFvHADF5h\nfnrb07oPYA1k+dICDbkAx/9jj6SdcKEOZPRT+ROcyj14jBzyMkhxCteVmXww\nQrZIfziVtxcvn/T0Z2/jv2Rm9vHhwiEeQ/fTQN+0nsWSsogXtko07MGaSpSf\n9w4ACAtFi40BYykhwWRzmHoVnJx+lEbNDcmiwJ1ZIq6tjDqkvX6iroVEP4KG\nwAYiNXedx27qXmhqlGmb9Fi1AEAQ0jRfUs3n5bPUw5vEsuDSISqqayON7iXx\nTRVT2PdgfevetpWOJ+b4dUJm6adtsIgcATwmcjQKCn6kKW7qotvYbIOWOteP\ngouxt1tGCZxb1gyrf+7GPdl6P1weXoZhoTcmr1+b+2Cp8vWI6+3FPCW74KFl\nBLJLXcKfPmAOW9/JUC2hjeuz/daWuXPL0W3hJmbTlgrL/Sl3Pguq3PijiVtW\nR0ByiZPIUsfkG89cx9nWNgiTXXhkl3USNZWUfat/WSSU4oKzgQHSi1FGbrtH\nTm3piTaXMVgVL2cHP1Xjd84+LCJxBVr4WohbvK12v0n4KV70PaWwoedH76+1\nGbKgkO4Sb9TyzGnGgaoqhrfbqe2wL8EqUIeFOzIA+4aMueg1lNM0FX2Fvuv1\nCdeVvoVki8axcXFpYdFmi7YBtssR+v/3UndFGT5Mrqi8dpR9v8mE6g6bEz6G\na8eT\r\n=WKRB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-33e7e8f-1602797116973_1602797174955_0.017029567555883585","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-33e7e8f-1602797113994":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-33e7e8f-1602797113994","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-33e7e8f-1602797113994","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8f5a80af95d03a88daa8427defa295318d3827b5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-33e7e8f-1602797113994.tgz","fileCount":7,"integrity":"sha512-rI+UCVeyFzTfLY6W7lempXEuHKYjSAYaCD9jnQ9mx4O/eTAYl6Y1YBQDXuK2S4ALwKHL3ephSlGRPV/2W26UIQ==","signatures":[{"sig":"MEQCID6vLiCCVT8v2qoWPsyBJtcQyPv5U6qMjlweeeKUih5GAiAkKogda0JgGzPCRA73gNCS4AiHDA7nLNUHdfjaJCBYNQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiL58CRA9TVsSAnZWagAAIroP/jk06+YP8jcNX6NHgSA4\nrDc2V3s77c/ysrBzYvdT1i716jqurbg+IrVp/JJhO8d0ymGRNgjKZNfgr8fw\niH6r4/8E+8A4bnIX6LD2zeUL+VdqtdRrC+E8lGNhnKHEAfshy5cl5mjmo5wi\nt7k0zMq18TQl4idjDk8GlJCDcvrhVOvT0L9etMIyMbARgWBBsxM0GCzeAhii\nARAvcc7XEArIE8qeehVyqSmY9ZFiI6LiPWFhMBsn2RFcGOm0eD1sqJdIGssn\ntEcPWuPTauRY1MoBNxZ12AnrSpCZeuCHe2oDhiEzVmDHRUvecKMz/lSXlSLx\nlJABjp0p9A523t8TxH3o2NiULPcAYvrOMU2lq6JoLmf2TvbeVYONddrP6kSp\nD25fnGfRaYp16qBhhO3rSHdWawvn6HReu+g65BcdGrCOlbtzDAF4PfTC4cmF\nyzFX+hQsu+dqBzypLErf5ftD1JSoO3cqIZx1sMVA5fGunQCM8lI5dJa8sCWy\nSqC7PKfw1XND/2HbuoGEpRYw8mOBrl7chq4RhKOnAW0KUO1fcF7w/jWkluVS\nzNwXbSVSW43YIkDxCOF1UJiZ+q7SJiEyzWsJDGvZolhL3nFoPnR1tviWxLDx\nw/zVZiLrpZ2N9SsGJhx5c13M07DlVdBm1yNVgoO63s/L71L6fTQEND2lhxGo\nkhjH\r\n=s+WM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-33e7e8f-1602797113994_1602797179942_0.15400759781020845","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c2ebe94-1602798174729":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c2ebe94-1602798174729","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c2ebe94-1602798174729","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce3bf9609bd2ff4e8679418b9345b12b7fdb73e4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c2ebe94-1602798174729.tgz","fileCount":7,"integrity":"sha512-c9aYgf5VXIAHsD8jrO5MTCVheCaZeIBEt7EPH1wYXcWvJSzvm+jsj+jwEazBPlY0RpNRnNNnYZx6edNx2CGZPQ==","signatures":[{"sig":"MEUCIDuDPLu7kDRA3ESkT5LNcjtIqY5SvmASmAaIR1mj158NAiEAptvzeXi+au6Z7YJl6hlHJ+aVegWxarld0fLzF7N9xBg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiMKRCRA9TVsSAnZWagAAoykQAJkRNReX1rzaJkTru3QD\nYAE3OHrwL2te4/WxMLKik/2BjCT/2lRmyGago5MktQ1UBy+HO4nZuQlp6GEw\nieuRyHPQV/lk9uoJ/lz9hNN8YuK+47+V2ruxw4bpR3S+3LzR6niIpHoec260\nZjdjRAVJz5po84kY5WabS3+IJUCIKw5GvUuASJT68A6mlX4ZEODmr8UBMCjM\nNxsML79g78mQ0HJVLInmLyrRguudwiwHXGPBQgtYAGtgGn+lLT+NS2SGzCPW\n46ccEK0/hL4AOo2m7FigRG5WmJY6Bs87RdT7PAvjjefZOg8KAcCLtEV8uo7U\ni/ewAc47PHESlhov0s2Q9zsFP3RwOjk7+uveqo67jmUi4aHMW2qhNo0WwWnv\nmaKJYxFZUxH19c6XQes6e4N6xRixQNXgfg8j9ZEWx7f6rOhffZ4vjUMT/VEL\nrWWt48DPqdUOaB9bbwguTSkGKp9X+tLqVqX0jj2fqVlN574Kl8rElq101bE6\nBkiE22Dz0FWW1uAGhnMhY/X55mcjmp9j4BvmBg9WqTvDtu0IQK1tOxZZKi6Z\nI+yauk1cSH5TOnr/gbsreTbDiDzGtVveG29RT4CBZDwElnAN2+RTkKsaa0il\nzPY6IZi4mUgZFPc8BfSVZz5us3w56mhL2q/DqPNNc2Ivogn6QAORu5ufTYG6\n92So\r\n=kvqz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c2ebe94-1602798174729_1602798224772_0.2746397788576793","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c2ebe94-1602798178147":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c2ebe94-1602798178147","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c2ebe94-1602798178147","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"25104500b0dc85a7d92570e4d1efd2521cfbff85","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c2ebe94-1602798178147.tgz","fileCount":7,"integrity":"sha512-1HvXzjVqhTqT92VPOzAe3hVLyPfBox77RwbwVkjyjDaSK7U4pok4U5NWsl9wn0kkAo+50lns4Ev3C/W5e/V5hg==","signatures":[{"sig":"MEUCIQCo4StRTH15ou2F6gxgAaEB2vCXNSDco1u9F2JiSC4kUAIgOQwiCphz9iAEf8yHXM0Y/nwCiQyphAIzvIZPCw4WLrU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiMKfCRA9TVsSAnZWagAA3UEP+gPRIGQmvQtguM8S3iPD\no31oqmjPbMoo9E2P+o96xcCHFjNd3bnawGFextDswLttDkOXKPT8wIf22e1z\n2Ta5SwoHkXxwBhO8fG4PNKofDRYM2ge0IPIA1ZCy+28kdWoCRtd0emj8dK5t\n8hUysgqC77t5WU17aQyh5t9QrqgkVAuHKPCuMV7ctwnRXt94UtYJ1snHaYG9\nbGVlMWH/9LIxaTF/Pt1t9UZZO4RugqtB4QcZGPUTDi3pSkVYTAe2VKlzB8hI\ni6t/8orurTHRejCvZJcYhtjFhHrgy/Z/4SL3otq6QCcN2ootDvSpwqeVl22M\nRqKF41SfO1Djk6eXYO8rQ0rkBSkF0TZEpHRV0domTzO2eL1oBowaAGbbwRFp\ngcQy/UTbeLQjFE9xTwO3JY0YW2gierfQXMN2eZu4MmHII/xvGoiTEkDm0nsu\nLhEthXn4Pzhdb4hdUmfZSXaU+JIxPI9aWHXoEvXQXClumcB3YqoCs9WsfQaH\nClI5a4ve2IjtfXWEFT59StL/cKaaqJRymHAg2ifWkacu74QPsbEwopC+BKL1\nNqn5eMSRfI5f9GiCHs77M72q4kq3ZVb1UInCDolm9JPPHQeZ0admkUZjbWSp\ngwekTKKS8xCTBG72AWMLBC5B0ZbfyEgRQisqUm6E/dZjnPX8dohMOUxscxCw\nVYkb\r\n=XKMo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c2ebe94-1602798178147_1602798239247_0.1562613271305966","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7b553a3-1602819032151":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7b553a3-1602819032151","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7b553a3-1602819032151","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b4c54984fadab97052f649ec24a71e6dd68c89ec","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7b553a3-1602819032151.tgz","fileCount":7,"integrity":"sha512-ETfKiBgooiK5W/jT+SGq4GjIxt5M7Zzm2QOneFf1D748EroiDjfD7bEFeEvlaYYzB+d5aHH7u+IpawQqA8qb8w==","signatures":[{"sig":"MEUCIGpk6LDcvK4NYrrvh5w61l98LWOPrZuVkADc7tyqmekkAiEAvIwXDJU8fyA6BEA3B/z+7ZKYLug3cZ9zPQxpZ4d32mY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiRQUCRA9TVsSAnZWagAAh9YQAJ4JhDOCI+Le+UA4EMCh\n05aIVsYc5Y9VB0jsCxkXEZmXQggTjRwGrkuhRdqfIKWFy5bLx1gX5F2Rd2xp\n7g1dM+0NzVJ8RuW1IgEXMQU7hfQb5ley+2yQuhDtuts0iMcVMu9N557vX8b0\nU6Qbm0FAzrgrQv6TbkPzQJWBiRqNyr8hqYyJv/npDmtwvMaPtbsRkncKZWDt\nf88Jbrpkrxrx6wwb6lsfLsNnBWlo2yA+CyNRk94gfsjSPdulw0I7MMNy8xe3\nSGeg0SbbQLKCwuIusITNsdLfRVS/2foIK0wRRlIjz35wjKJO0e5XY4OakLRs\nrujYpOfxBIQ94cgUdTrCAP0ywhWK/jViaIqEn3CrCSH2RoH+ewC6/OeFTvxx\nDqwemwPD337I3IzeFqM0bSO43HnRIeQF3ki23cQB4IDR1t69FlgmaK1LNjXG\n+RzQhSzi1HfRLhvETI0vsRW6+kq1dFlGFOR4RyuA7eloyiDNgAFhWC+ziGTt\nCw/R/Oi3v0rDJDHKtRxr102I5/7qbDvMgjA2wETPmHvNbBOe9DFsS0FUZi2K\ncc+SNs+HaOIOXiDaJDjdrpUUEhj/WWcEG++cMIRZgPrVl1GQML/Okh5kyBLz\n7WP5Yyct2mpVZUesgozfxOva0oNL9Z3b3AbF95ysGBIrgNAMouSNXB830Vxy\n8Y3D\r\n=JQxY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.30.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7b553a3-1602819032151_1602819091670_0.5754101438344605","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e710c02-1602919231114":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e710c02-1602919231114","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e710c02-1602919231114","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e9d8f998c9423ce5d93d38adfe6143f1508f133b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e710c02-1602919231114.tgz","fileCount":7,"integrity":"sha512-BTOescS3uZfkQUUNBe93h39Vsl9YTFpZ0Tb5uVKUuJ9Gz39ZOUsfkDWkjppJDkElmZeATXtXKwlyK+lcjb4+CA==","signatures":[{"sig":"MEQCIHHAV/YKKg5eP5DFN+gF9/ulOV7CMOWsJLItKFbbd/fWAiAOclPArg0YKUnz4seC1aXg7RuJiTAgAfqUP3GG24sp4Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiptuCRA9TVsSAnZWagAAFzMP/3ADXGly4R3C9TxwepIh\ndkj+xn9SGMejhQxaizRyzpCoI01maogdYJ97c8Tvhsd1yZrRj3Raafh0lo7b\nRYVctK+a7jQAA2oxDR9u3uPxwoQloPone3bDzro4EtEB7DUQcwKr/448X1JX\nfxEp/rRmfiALObuLkjfz1nXADz47/MmzuX79bLqLubowBR4AJ3BBXTQveMJP\n5bXKIo5yXWC5a1VNCyVcJDbsT6c6z5G+CJO3S1c0Dr+oxu+U3Z8vC3GeXboB\nlone+dcPryyoFBphnlnVtMQJobz952DkA46OgaEMLKu68KTe2T465asol3N4\nyukqlfbd0/s7f9+sVuUuVlHwYGo1vxBwMLHleHGrc00TVXMYQ2Aw6kOUka2/\nZv9ZPnKO83vfFNQpUTLQLCl3G0Q45vU69sM7eetPYXl8QCzNvGuquq1Ua/jj\nzmEVdjSq7e/HdzrHd3MpWlamqLaHukBj1fLxsR4r70r5rL88sB/GuIwbzqmM\ndPU/IQUDUXjOVbWP2XnufSkKaRE+diddy7uK2Zla+/7SOMkBLrr3dv1aE4Np\nGGHjINEPWjRUzVuHF10r3L0mMYRiMuoArBLIhu6Y75+sHOPHxlLl9e1BljD+\ngzgTJSbd06qTG3wpsGJB8cW7BwfpA0Lg/ZU8fz10vXnvtJz4rqN7uDSyg4cQ\nCyvU\r\n=Ys0N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e710c02-1602919231114_1602919278226_0.9542001924031231","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-e710c02-1602919234464":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-e710c02-1602919234464","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-e710c02-1602919234464","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ca759f5001efa616d4a23ec3c9f89748651fdd26","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-e710c02-1602919234464.tgz","fileCount":7,"integrity":"sha512-scUKwjexeM6dgLNYA+Jq3Gez0BSeGXPuszSlJYDceUySmOZduEz/ZfLfQ1on/As9ViISxKUEr4WSVXp6GbB+YA==","signatures":[{"sig":"MEUCICrXvQmA5HYIf0To8FMPFNYCAWC4J0ymHIsD1BPsuYv/AiEA33coG1+krpe+QMRpzcbXf1Jio0xlJ+UcxATLb6WYwA0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfipt8CRA9TVsSAnZWagAAGOoQAIk46Nd3eZTIFcK36ZwJ\nb7UNr8iCoCnHRKDfKtU7DghN/EZo85Y9BMYuhUBPMGjAOSj7gP/4CWaDhrR+\n50g7zzlLKxjxSBJxOlP0d5690enAzLhcCnBcnEoVD8kIxXRuh8KWTUe/ATQb\npKBS9Atb+YYXxxvigB1tdmkp5Szt3h6HIk2lkAz5Hd4Gd2PjUH0nA/BFEtD5\nTcSa21OTudo9HMpDYCIUGVplZdQ9SjyBDwebU8+TXZ3XvHaUa3h/FOXnBeBR\n4HDD9m0u7WsZguvOeoHDTN1PXViJOpXKwrb8Gpncl8XSO9/AGWYVktt7gXRU\nmsnB7AfkD0sg+mNz3nrpa9s78wpSaPfoe30EuBo+RBHu1USMVkzP4pAfxcnV\nmZjpvlfUlyYPizz+89QRSajpNBfO9jYMlant5cJx8aQU/NgeMv3I5dhR5x6W\nYknwyS6wWwd0lq6PlFSgUbHnU+5luw0CoZokOtrQjSAh4QgEakj/TJjNOnmG\nyyYqEafiG6R37qSylmPNMBMXAM3yeSiM7zNZlnbWHqJBRzed+9owLnpSymN9\nPP/8SvQiHKqHjlt1RtAip964rg3BdFGo3/qxQU9GexOLdUaQOV7V5reY6W3q\nvzaAyMpeQWIdyL33jRZHaTtVuIU8yqFImSnF8YRil5ZZHwNEBEs2WE1R19IM\nOwSU\r\n=y1n5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-e710c02-1602919234464_1602919292384_0.3696157791648118","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b8cca2b-1603032136207":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b8cca2b-1603032136207","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b8cca2b-1603032136207","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8e955b4f6211cdd2a9078db9dd388886aea74337","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b8cca2b-1603032136207.tgz","fileCount":7,"integrity":"sha512-F7YaYcUDGMZolTDZ99NzdyYch/AR8wkw8x3ArVk68+LwfUvn3gKSrSD5zo7JoWBz73GjC+5p+XYjWhb9AgihQw==","signatures":[{"sig":"MEYCIQCqNJ42cGM5ZEBErMURTOEoWPGCzGpjPSAh87Q619BcsAIhAMrIu4VbwVOvfRi6qZ8c6FINcMXfDb5580MT0vDnfW4g","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjFR5CRA9TVsSAnZWagAAtWoP/1O5BiJQftSgXNkG6mlq\nT0s8I3NGZFPuG37AJQiN8DyFknt99tdqkedxLZNvxdFi9j0qoDu2R1V/2EqG\nwDMY7TkZFxHzO9tWfAvxt1RDSr6q0aZomRFisAWIYaFT2Eu0DfeuWjr5Pq53\nGUSuChSBuV00r7SGd0tMB3Ee1GxfEtBy0pe4OOhU+MF+i+cSccGZgRjPPGLn\nT9L0IzFHmom+cODASjO/e2Ba3WZ9bPtQpiqBLEsbYxtcgAqC+kF3udIWEDzQ\n0zW+d+g6YMcqoSMlfIbL8+jG4JB0n2pkqC2FnTBkCCHcE5TOmhhWFoF13DjN\nCoYQSk9Fa9yjT4jUnsBym+JWCsZ5C/vwSDW1ORaUTPryzuU9rwIIfZ+2tmJW\n/YScdJYh/PU9m3jqjvpTP4mq8BVkeOWzv9/9NBO8q3+YqmHVfm/U03sw3iom\n77BuEga25uSzk89BqCAlAtVnqVuash0qyQcGzwU/5hme3f/wAsipEtd/61Wu\ng27oW7yc0ahyhASDGD2YeLGD76y2i9GL0WkZlxJTWI6QvQ7OTF2FFvXMxIZm\n8ek7gpc5EcZoADaF05iwzNlMbdO7+jCF/chK6qbO+Oe4Bfd+8xQMlyFdJnhF\nYgaD8sZ7wxofdr4FLK6mzZNY6NIMmISC/tSqBEkFIg8lkbtg+ZGjaQFh3o/c\nF30k\r\n=8zBq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b8cca2b-1603032136207_1603032184572_0.9677985831459852","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b8cca2b-1603032136594":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b8cca2b-1603032136594","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b8cca2b-1603032136594","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d7c635fae62a666fbb6271be68f8cafa711040fe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b8cca2b-1603032136594.tgz","fileCount":7,"integrity":"sha512-gBDVe/mg6rJ1+2HTpQNCay7O3yCdzi/1aw0Aj+qhILF7BH5gDseIovFIaoLf4QQcW1B7JeXZWg10kJXg15NG7Q==","signatures":[{"sig":"MEYCIQCwaOW1Be20OtBTDP8qAefV4XKvpZrgWJzew5NK04VhQwIhAPR4H37c3Tm/9b6UWnWFA5ovx1nb7waCOdIAml6eFrRf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjFSACRA9TVsSAnZWagAAEoEP/iqyoDR6FfPOZDMY9knq\nEKMAW77b9ucTP7m3t7iSVjAzjBR/eho7nhrazB9ZkMaDFIiqUTVVL5JXo56E\nGvllt95Sy/k11BniWvUw+DgfDH6M0JffqbN7Fg01GGi2JCX8dhaOrzT/2X9D\nHiYPqVyuIFzYRLxtMayZUaYSz6edyrP7qrZVchsJc2IKfDDjsF2xDZzptmxN\nGv/U8VihgvSCzETLSE0ef1skqK432c8CuTBJhabwsX1pYETlJqiOg1ndDQ33\n7wUlr+QDtUykv3Jo5sJSZHgdCS+J3abB5um6TXaVu788r2o3M/Iv6F8wfQi6\nEFJafkzPoJJVrZhe6if2MfGndkCJ8kvrCES71ZJpgizaS/QofCBqE4j6ZudB\nC0V8if+icfqTM2pXJne24SyutlB70eSY/ZwC2LFaUawCdmgTJRB73ydKsm1D\nLI7OEy23MfcpT9aKzosirTQsAf9BVAC7FcQS51WUmj33rHEZ+VJucnesW26O\nKHRs/7YiIobfj0kD8nRrdYQJCsLoNP7fJUf5nfwWXNa3ajYUMtloBTJFCOyl\nhUZMZW25CC6HEq0zPj7Blg3l7FiNIeLkpKTyujczf2GEqJY3it434dbOhoKm\nb2JFr/nl1wEQSo+zAe++BNi90aW+jOHFYGE4BNjhPz494BOHdT5xHAsu9J85\njjx6\r\n=jPjt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b8cca2b-1603032136594_1603032191958_0.467611495977293","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ce8d42e-1603093098559":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ce8d42e-1603093098559","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ce8d42e-1603093098559","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"58759f2e2cb28ceba612ae118f03e1ed914b5225","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ce8d42e-1603093098559.tgz","fileCount":7,"integrity":"sha512-Hf6WVoFLa32oCZlg+d9PWe1dvUFR7CgtKykk4ehTH2z1aWvXeUnoZRm5LA4edEnqJpE71lhWe4e3m7mERGgKVg==","signatures":[{"sig":"MEYCIQC8vyYKeD8SYrxysTtcesCXKnkNWVy8er6Q2DpFug5xXgIhAOySgG7pevoeCWpy8TuVSQMTzCo05rC1nHYsHZnD67tt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjUKtCRA9TVsSAnZWagAAKQcQAJQLhV5wOzaX2bagqqh4\nF/U4ZhjzhQo0UP1rb1H/4amEJxTC2WgnYOofK5UdOgRDG1ZxBwSK8iJc8sei\n25IA+TmBrZKR84DTr6mYqo/lTndNTnslMa1jPynRMApLTOwWNW+/EwTe3cMI\nqu4risavU7nhoVM/m+0mvX0ZShsuqtfdQBdEbTi4aQhN0Rx1sCpJ4Q/RvHRa\nV5zVxsMycUxm8XtFBpdF//cvxGw3xuLYOG+ZqQlZsJuHy04dKXyYaHZOi5Tx\nQ85v6geIuo4+e5yTavq2J6yCIpRhK0xzLVQ8Ymqh97s2WgpKjs4nDjUx2PKu\nM6z8sibDbCIAQOvmZNKxcDhSLpDY9Pt/o22CswtABDmE7BZ8qnugUJJrl7QU\nE1czeCC683tQD5Sn/Dg6ySnBeg6qrfF7rNTS9j1FGztUXcKG1LGCb+JbIZFC\n3goLoLPrLA0K4An6BGkPQwE7t1Kmpa9NltaqVPfK6Eb/dTFhr5CcPKaj+9UY\n+C48G+NyrfF5RNJp12QCGvvIxEG/nehSR0nFVOwbVnDE5J8sTu+P8NqjDFB2\nM6HMPL93nE9fQTSltGWMwLcJ2e3wJF8ihCS3sLrThhmpb4dPCBrcPk7ziLb1\nAoDFyv1z7ndN4Uq1oH3qGi+w+MjI0SHkz0pQ+OvGkogiSy0if5e/Fmlg5gXp\njiRw\r\n=HAsu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.5.3","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ce8d42e-1603093098559_1603093164810_0.09597761922843051","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5ada8ad-1603177651383":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5ada8ad-1603177651383","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5ada8ad-1603177651383","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d72c6e20b6c5fdb0d11d69f229c7bd25ade3fd36","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5ada8ad-1603177651383.tgz","fileCount":7,"integrity":"sha512-bWN5xKCxTmzGFGwqMmiPm+k+qAir8bOvHU8SK762nfSv7NkHbP7JPtLUyn3dLD8GTGAK20KNxiuf6pNA5vZqmg==","signatures":[{"sig":"MEUCIQDMWNz3yEGfl4xvaLCfrlQ9dzwIyEHt2C2Ae/WyH60eZwIgGequS4Th6z2NgeWj/83HZ5KHAJEKakM1HPmNC4CZETY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjozlCRA9TVsSAnZWagAA2XwQAJbLdxB0623BAunqTb+x\nzFDA5TSjijTxmSkwwLwMK07z26uJ2jDYCPhdWzy3Ic4qzskjHi5U0iM7nlLZ\n28VkvSolY98AkDZ8LCgVnGgZfuq6G2YSxX1UyV3izlAbl+uIOi9HzQCyzNHm\nxnaWRdsvBEHiGfVm+PhO5N7mQoATGcHVNxjy2fQHUTOS6f23aCEb4tu2p7h7\nRzb3FHeM8TXWJoBVBcHp07XsWrdL7Phh8af3j9r1hGFaMNQvKK7wOCJK2zgL\nnIzSnQQfBRgYuICnp0XNElMOt6MO/X6h199EgywaT/9l1aRuy19uuNYfqNn1\nPhQiG3f3dSilJyczAR+7tga8yEWeSayhZ1EqI2tcqCPDjn5OC/OxWbJ6LzNd\n4l+N82rHAGoMZfawh6WVarbDUfgcufeCsSFZ5nSHA4S2Ofc4OQwJhBF5Q9aq\nBIcw0mu2vjvBbM27/56FyCzSrFAff2i9VNDt/gZ4fwHfyADsxBUq1fK6oIyL\nPt0vkwZB3x9/dHeVci9g1Z8EWsxI4GjpQV7Julic6t2fU0V9zUmNS5JSwPPd\nJKJn6hZV+tv+uJEUh0haisTfIytmj/muVHj81pR7pHb6gGOo4ZWOhScjil0h\nVQogtmuhbJb+vME6OdZAsSWRUwNPBRSuuNcAxWZIUASs1ILK8T3YVXa5NwwW\nn6B1\r\n=T5Tu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5ada8ad-1603177651383_1603177701452_0.3362435888981907","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5ada8ad-1603177653544":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5ada8ad-1603177653544","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5ada8ad-1603177653544","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"52da1fafe10ac4b42e05b54a427fbfe8096aa989","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5ada8ad-1603177653544.tgz","fileCount":7,"integrity":"sha512-pthTe0Wde2pXO242MJCSXx4WQAiywA1LkP/uolrRrxejPy6jfLraPy6iaVMxkE2DIBUr7THLG++t012CkSkxww==","signatures":[{"sig":"MEQCIDW1YYRjowAUxHVwUNuvAJYDh398e1+y5e2ihPikYNRFAiAakqr19us6bkeJVGv7K4FFSChC04CDebQxAQYWTV8wAw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjozvCRA9TVsSAnZWagAA298P/1yE6xQDffjgv0waJTy1\nrhNOwz26OrDmwCDEMVSQz4B/e6iG4RcP3oPk7AtZbAyDEcFq7F5ChVdnviyI\nmubF17rc62/7XlAlabx8ElhNlqjQVJRocwscYIeAg9GREF+eZDTLFgs3aBAW\nvHU/hWVpHGPstaTiO7//0eKh550/lk+cSBtTqmPONZ/IXzaQdFnQJXLcGTH7\nlhksu5cQVQIJGUhUodTSSNpMZSQW+27RGTyhBotkoexA+f5/zPN1q05KEquD\npJYg+rgmYfAkLzCkjcz4a4FMbFWTiMBMzyWwnS58Ag1x9+HOQ1kWwPCh397h\nAEydkrz1Jn81KB1/AoDFRYRnIVb5vY1kZR5icdMCWhP3hmWKkLRE5uEBmcOn\nqvzq+Y7nzomj1YUDVCSsQRyOxQzGFqifbanGsppF5XmMboERu/szEcf2PLa8\n01WPXTYPcgwS6wlCxn7mmrbSPFP/S9fKTthXy7ZJalpS8as4v3ykbwpztJsV\n1dGIK193OfN2lKCgdrbwV5Ih99bCbu7CYofRYCoqFnBNTvZQYIDCx41cPQPi\nAZCrFkr9dSDtYV6zulTaPcmihIrYEiMU2MAbAgbTighaocBIW26I/Pb5krjV\nLTiTjDgnldRhOmtKG3W1DwBXDM4ryQSrpJeS+hh1+8Yu2Jfw/ctg+et1ylJq\nAV5S\r\n=XdQ2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5ada8ad-1603177653544_1603177710901_0.7628606510922409","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-58e42d9-1603181165470":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-58e42d9-1603181165470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-58e42d9-1603181165470","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a80cf5897ab4e198441a115be1944855898d6c5b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-58e42d9-1603181165470.tgz","fileCount":7,"integrity":"sha512-SM1tWOx16O5I18JBdj5hyonodSua6GYs27l0PPZDlbgfnWFd1SKXWVW2hl6N3IWLR7jROM/Pj0Ij5EoiXNhcLg==","signatures":[{"sig":"MEUCIQDmaFMru+/HFcKRdb8uohUTxwdrHDktcKdKVPJG2DZEVwIgDqjJKYJP+aCi1he3T/PfukUpLTy3IkFEiYdgI6sSkGA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjpqeCRA9TVsSAnZWagAAUuIP/2TVp66ey1/ZvFMFb4la\nUEwWmtHYth48WhFScOmvbKySe55gqFdo/0+h//rx9it4xW39SGnvkG5Uqo/a\nQrA2QG9TJT0k3hTb4Zdgpe6ZWhn16URvzPDWZhm8nCDPn2I84BrpijRluUS8\nzedACIr04rQzG1wkysR0mdZLV4B/dVgdLk4i4fyDMLqPIb1CPEIhI8fLXCfP\nG18spFcJXruHGAc5hJgFrj1bDA3yxh7eD4ZO3ulgkE08EjWHjeSbAW9aPfca\nXCP0oVlSiidmsFZ+wy8bh2fPFbBnDAFHnahVLCCCBtvjWE3Uam7c6RGUhgl1\nVjUpAkV0IOEkSB/oW179BrRHO3g8j6N6U9cNIofX3bWpVlf6KE1ldiFltx3x\n7dloadqFHEd9ECH0VAxr/K+vmXp2Mo0qPLsM8SNLo7yF7iYVWmus0xvCKuiL\nKO7DqYrU4L6n3cSCxwIZ3MEjHP2Wn2O1o1nLyqwiR3rNozDSO3Hj1klnau6m\nbCW2L+s199imInSwr3mWMzO7Y009Z5i47YpNXMm3Pp7qom/DeEkk3qYEvt5j\nWlzPxxFghqswVW7tTvwuTuDfiRU8UKItuZqd2wd3nqBqht2EeKFqoH+3jVPw\nKrKD5gFd+LcbZoLgUniQ4JtR3d2A9+K1tDYgLGrmYPSQlP66K7kX4p2+ek6x\nF1eh\r\n=rdRP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.14","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-58e42d9-1603181165470_1603181214463_0.75822296353527","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a425c62-1603293284350":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a425c62-1603293284350","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a425c62-1603293284350","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9e082050d08c0bdd9c41c3739b3c4190357bd7f2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a425c62-1603293284350.tgz","fileCount":7,"integrity":"sha512-nSuz1qHK1GOWw+XDS7b/Mc/bIcsXFsOhoQVJ487fBsCBU+N15pEeZ88PJs1Knu1VT/jVCPdpi/8QxkmrP3ABJg==","signatures":[{"sig":"MEUCIAnJDJs2LPji4ardzKol0IUnFFgudYwisKRkJndbqte0AiEA8XHHKCQxI77Y8QpknzMiDWjfP9E10wdbC3l6P99Mb9w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkFCZCRA9TVsSAnZWagAAGl4QAKHRM6jYgOAD88IZUGdu\nidDTSkBJ4BJLUwtw6NNfABrqpEbxtD0RnM9xDyjyQzIreJu78jsBG+MxWoAl\nK7SOTG/pvYHGU2FjYzkoKR5YbfNLMsmm+u5JdOyEfeyOEWq/J2e4am4/pXGh\nQLdd/Q2wzD8SCYh7KcmDqhMuMLtYOsz68f6adr6fPoJpofk70zr9lqfo9zTk\nt/SA6HmbWWY4pDW9MGOsnOwfLlGnckUV60v9NLShBq/y8RtIYeavVyT9mMFj\naTo21WQLZCRLnk14j/Iri4EsYDv3GnLpE6AIJ/9AH7Bz3tB462BS9cgLFyPQ\nuuyNOA5xMT5NZga8NZXMr9TGB76dN9sXxx0IoYV2tJqsrMCXiArYK4xSlDMm\n+4kpkPUGMi6JtgJ3+tT5++O0r7hNpX1qKSDsubWt7oka3aPpcrjjYyKKFkYD\nW6rVfZ9RZOUGPahlDyv1SfPk9Ejk2Go/tKO0+AG/QGmNh9yd7wa+8c9/MmWo\n6KLyCIeIc2iiQIGlAKB8AibPLsUv4+sko+TrvN/V/OHxtd1pslU2I+v8bKrn\nhyJJSIBWJkJDLRNnvo99/6aLvLNRY3fEAb9qUZMGpoI+P3DaXfGmUOylccV9\nkx/ZdZebvwVNhObOo5YgI9wfQjPtvQjqgH41W+fiKpgdikxCNCrm9Zkbv2mZ\n6tgw\r\n=2cDn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a425c62-1603293284350_1603293337235_0.04026499542744766","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a425c62-1603293285871":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a425c62-1603293285871","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a425c62-1603293285871","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2a0d77231304e597247a0196a889b61d94d10cb1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a425c62-1603293285871.tgz","fileCount":7,"integrity":"sha512-FaEjCxLjqMQ7aubrkWvtiqVtfDZAzeGY53zK6mlA0G2pJPUFG0lZ3WvA0Wg16dm7L+CEU4infSJnnw25Il7rNg==","signatures":[{"sig":"MEYCIQDzyKKSvN+EkgdZf2WPSy7iOZVyP6k810Kg6uSSD5FNxAIhAKOAXLr7vKVZUtQy2FnQUu6lJnTuCzsyl0M8IJuj33ah","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkFCiCRA9TVsSAnZWagAAC2kP/26yXk5uA+RPZt1+08gN\nnJEQY2s/+GsLgato9WZE55S9mFHUdL1WF5OQ6fODC7oIaSfM/pOfJdpiX24G\noAaaKtnIsBjqCv8a1Jm13rKpjsRYfaac0LkfAWDj84TUb3hWT1mqTyRkd9B0\n8LV/5rdYsVmZMFXbzMRDsl0UxS9iFqU9OVp+RIeQsRF3225JDb5QjRHMk5cQ\npppNAzoIz6mhobJxk3mwdmRZe1fl/FnQW9zauq7J/bT5LmnipyqpJVwg1pja\nlTxvF2pYTLPJfSqFzvc1KekOwRVqowz0xsp/V/yqKxu1gMXtV1GFAURiGeDv\nGQ5ND6NC6j9bIvtg7xx9ABHGQvgpMgklmB4Zl0SyyULhPM9kjjEoGyRReO79\nYq46ya6Jk5X+VTHkg3RJSxt0XxqqmXI8pcGKHnXO4ucPU64wptqNED/kBvwU\n/+//PvD17+/MR+xy/Cdw7EQW0f0i2C+EvzQz5zrkwF74xJ7kUFfzbQ/wNOPb\nsGofpI/y78EraDIGCYh5dptjX9MB4FsbdLK6QIiSrsnEfNXlHeZVKUCXmvPL\nC0yBG/nxU2XRP/UIHuix+AGhsbYMy2AFlJFWmx8fcXA+IST917D7vdPCdEnj\nZvykL7fPRzFxGASMYvLZq2p2t11hHBLDCtUAcjCfRnD0g3h8V4z5vy/U0WjR\nCbC+\r\n=2lVR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.0","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a425c62-1603293285871_1603293345875_0.05226707721585977","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cccb9fc-1603355719722":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cccb9fc-1603355719722","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cccb9fc-1603355719722","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"face59926df9604f76118f2c48392993ce049a45","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cccb9fc-1603355719722.tgz","fileCount":7,"integrity":"sha512-lMl0DyDhtgB7XKTbbdvQpCKvoLS1VVmB1fR6MsT51pBHeCa8yjZvE9iGzlMuVNVy7mSuBfGC4iDCPrrYrv+aEQ==","signatures":[{"sig":"MEUCIGjXQ0n+AsAFEWp+o1+crS8eVbVCC2qKXEYaKkALThRNAiEAmxfgi0qHBpjzSLFt2zaUJgwCQC9hEWUQK5JTZKtrtEU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkUSGCRA9TVsSAnZWagAAPc0P/iTY8W/pEmTzrXFHu6oO\nuXPAagGImNJSUdY8NK8K5z5VvQgrZCCzihQ4gO7+qGIamTPH7z3Sv6CfFFR1\nsoo4uxAbkkX5crGekiTAbEz7GNhY8MUX9eNBWI7S9JabPn7kePppYbUaZ+c8\nIOJFtVvN3FhnbB/STLciCuCYCA6h0s/toRI3xxsqSyp8IhWguVRXZ29Cnfq3\ny+T4ZWF96j6D1eJ1b1E86SiE7dBP0Wuz64J+mBzmQpNSniRsGnDksWLqf0e3\nohMjDGw8PNofve6TtVobs/PPAI9QAPTJKDnjQvWClXmMKMgXpD/3gFABlBkU\npdf38kgXGlPx8Z1WCqydP/k/87Cf+lmtM3xsnpLXyMf4LzVeu2/ee/q1hzWP\nFudq+ELbwT/FE7/DG5lWhIKx6ArbCAkKRqUvRpoFCHzFlLd2FrnGxgTL8amw\nCYORESxqbCJfMWpLCDMcM75oqfq0fl42AQBGo6ziczFdm19VcK5xKsOrhVvW\nGnxl74ibmv9k9qd6qpmHD95iRQccU08iMRAQS5tv1Ae5UAobn0PyPiBCBqwZ\ndBCFvpk2XivamgcYFwUXCvlC8ykHaae1iTkZOJXV1xb+aQKY7ZLWwzzru0Yi\ndTdktG+t/T7+sVQy2JqPLrnqhlxA7xmRKa3ThNZV3v1TMpof5f0qT8wUkP/7\nBxfq\r\n=7HzW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cccb9fc-1603355719722_1603355781890_0.23609027405560767","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-cccb9fc-1603355721493":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-cccb9fc-1603355721493","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-cccb9fc-1603355721493","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"25fe4151c15a25330763ba2dde39d49065c07eb0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-cccb9fc-1603355721493.tgz","fileCount":7,"integrity":"sha512-uQ1ATAjXAWJxhy50il2HEnn9n8noAtwWhAAjXIaPGvekt4xIjLQX8Mrokkw8SQ7n6TqehMZun+/xwZZWbhlO6w==","signatures":[{"sig":"MEQCIAwYvf+ioYc+vM2uornOeRW/KI4xQ4DaUPm2KPtyq+8TAiB7iZuoMILdc5Q7dGv1ezZz2RrqocDaREInr9rzuQTZzA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkUSXCRA9TVsSAnZWagAASLAP/Rfh36Xkva2UeYmq4unB\nIEP49jfmu1sl1/f9zipeq9wL2+7Wi611ZRa7cQnahHhJxj5nUTuS9Lqym0QG\nt5w31ofjIFWUlhPfGNtiAEfd69vmRJsJGZVYdmSVVKnfRkV0pdoZGfzfS+Uk\nH8hRAHcqOHNJasoDny/291aPnj85LDrEb3QDJITery+4Fk6x3mGmvrVpnJNP\nA6T9jqGaTTVrv0PXEc1LzC8oJBNg6u4FEjCHR/HX4VjvNZMiUOH+zUkyxI3z\nluGDQ0p0DZSvj0JVrbQ35obVuoL3gwJZRrqohVjekJMgqKzFe6duPVOmj+4d\nb0tAKxcit7mfZtoyAjm+nH64bC3/UGFQX4qKFRFkTVMV5BArmJ+fHX8Vvssr\nIfYHyuyRLafKzzB1uMkr+wheEUDHz9bgXdeRNsNwK10OZxC9HO3OdtCLn70H\nbSomG9UNQPNi78C5gTIrJsnbW/fntp0z0yxnCoacTQE8DazeBRv+BCRu5u2Y\n9UekuHObQ+J6uvwgVDHCbAE7HsbNQFEoQiWDt9MUjHApc89od66hirmKvPZP\nVbXTCBUY9toHaU8wjdvwbk+w8wzxxsHR0BZiZPKnVc0iQznRayvEa2zZ7tXB\nXI0T1zMgJEeuNoxYDnH9evwRMR8b3Ho+vnp4l7E0BZ9coosbHqttyHAiBUqo\nSLg0\r\n=axjm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-cccb9fc-1603355721493_1603355799556_0.3170753402635642","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-bf93fbd-1603391418573":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-bf93fbd-1603391418573","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-bf93fbd-1603391418573","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2a1fab93b1b00ec8198d0745d651d3ef8c8c5a60","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-bf93fbd-1603391418573.tgz","fileCount":7,"integrity":"sha512-HHgYizyw+OWR7SA5XWfFDgXhgElZMHI9xTsdRnBnVHDWRir0E5Cyx6ayp3WR6wZ/itD7KwXVa41LLS/vPLAPag==","signatures":[{"sig":"MEYCIQC07QDcfGtGjtRO93sTBw+B6IliXWsaj+hMN34CkU21YwIhALUpJ9py1ZW+7LbR2CCzoHdTCweCFTUk9FqnNnkdfFmY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkc/uCRA9TVsSAnZWagAAXw8P/jL+5fCFGr4kEXV8xfl4\nhGWFzFM1aQPf3NuWbYWL28di2ptfU2V7l/hcPMaDo0/6N0iwhFCyEUYuBLmB\nZiX2sFFd8D8gANi6YqvU1eI/b1GUN908XVsbyKH3Bg1K9iFSujDSZps6eqOK\n2BZXuee8Sn6jL8Fvv+uS6kbAAa2+oHP8rh4/8ntqmA5RAdH8sWYbudPKL+HR\nLKRLEyYKK3as2m2HOaAvS2drrkeqasliNzn8XdYjFXO2VKTeNzgspQkNqPOf\n8eFgCBJ2DSkBA0So83OeXamOKQ820gvfLGROwkOJClppw4k0kONrJLaKCyoD\ntuqjGqPZeKy614lr3Z2mpsa4DJr3aQccYaMPTSFnvyiqy7Eszxv5Rto2rhMV\nT6pCp8Trqpu0VHD/IWFL1vhfNEN1KdyrkbP1iFF+iyyBThdMuQPR5aIgB95p\n2+5L4gt6lTbv/ZenlW9gVlBH86ph+yGcIixmP1IL2B3tk0cNUBpMltvPSAU+\nXRqC98zflB0OVjSr/FQyUVBeXAOYmCJuXX+eNjbn247r943y7LEqGi1I0OKP\nBGnpIgwyXhcd6dv5+JRiqxy+COy877+0v99d4P888xIp91rCzS9hkHyMaAyG\nrcHRKQNPfIx/BspaZJx5+Fc1YS5ybUUseCGt3JXZoTp1FzIbWKODs5DtsqqU\niW90\r\n=pTcQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-bf93fbd-1603391418573_1603391469535_0.6230312285964175","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7b79242-1603546469918":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7b79242-1603546469918","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7b79242-1603546469918","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9372b1691e6c98c3246e8ff61f076c51c1c2ff82","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7b79242-1603546469918.tgz","fileCount":7,"integrity":"sha512-dr/pDe2jhWtJV09S641Jz4G+yTmBr6M/3cX0BckIj8xPQr1ZVTAxwJod7A7iuWZdJjoPuMl+YKCGELPzHOd2MQ==","signatures":[{"sig":"MEQCID66w0IJ7yzZdTJ2GNjqM1LwDdzjn6fWyDrsPLUI3j1BAiBK2B1mSegDDhyPt+3zLxmiN2fxbbn8g07f1hjb94BpRQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflC2UCRA9TVsSAnZWagAAM2UP/i06FVO6fexI+FgmkiSI\n9a9BbSYYHGLyZUyn/nDCGbJKaiT04PvdkHPLo2LNDlji1P+U8yWxpvQSB3XG\nupl/PO8byx1h1e+JtAJEgLlbcq1eeYz2mxB7BvGEwSBZ2W2TIeO/KWX0O1o/\nCHfrhz1gxrneYnzUbBtcufPBSgCum0e4zWyx6SUMQXvlJ66ZNjtZuVOgFaAt\nhVaeLcCJ0sjxZxJSHOcVbY8u6X+Td+mn9pdEnZ+lKpAp+aCiIIzuzLX+fiNm\n95lqs7BtP7tTy3su3qI5I2JyBeBdpp71m2CdGrC8khEP43sluoeU/aFcd39h\nllxMttwP92l3vXdnpUjXIlnvZgd0SWdjTU2+gs0D8D6LIiVQBIc/Z+Uk5znx\n0TBMMHckn4lRmHuM3jGOW2qxRkr2NPjkbLIEPbaSWGa5mfNxrN1CsdrB+2dh\nFGYJPwkmyzP57UgQ/kVcvMkE4xsaoK8yO7kKZOcnOH8K+vLZ1Zyjj57BM4Qb\nUASlNE9tmV3FMeVy2bkhTlLD7dzkgxbCqII8msxk+BSwHaITbZ2bAJgpf3DA\n98H5KJDlHAnSvhXdBmfqC3rYMof5MvFM2wE037HN/9KlZuOJ8EE4l54FFej1\n+WtYURi/d0U3DdzpmUueFMFZmlALLhU+EOe0N7hyV3ljArM8Tsd3QgtS49Oh\nVomU\r\n=HU3U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7b79242-1603546469918_1603546515676_0.5541140870655195","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7b79242-1603546472380":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7b79242-1603546472380","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7b79242-1603546472380","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e99e4e454881eccd1e27c220495903668606f14c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7b79242-1603546472380.tgz","fileCount":7,"integrity":"sha512-Mc/gsWlOGLeS2MYQAUmmRqgDc7Du5utW0G8m7UG+UWIbF6VUDtzYBULEPYCjo88uckQuQ58HRSIJPzlg6V9y8A==","signatures":[{"sig":"MEUCIC3J6ivF0927ppPW45V8hXj3HdEm+2mVKGivMSwlt5yWAiEAi1YdrlfXmCM5OJtW+hakNoLSqT5K0RENu+RDaTRmlJg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflC2rCRA9TVsSAnZWagAAMcwQAIRGq2hp1lGPD+VEPgrL\nhE5XMypfQT5uAVV/rH5we1A8gVIu7Gz/9mFu3+p6tu1wDAHbRYSZn8h0FMGM\nTOun35UFebo91r8eoqs06a/jrvnyXqBnvp9uW8FoUjhmaaTuk+lfT3TIpcII\nAKb6y0hflkRdrBS+ESWyUvfetcc0tbkbppaWEJAA4nELH7aEDt1iNC1cn6Av\nW2xhtq94mnmCcBkd1InTHUv5aBLkKddxqchQBhqhUlF5h8zqdQxPceJKUqne\nQJ/msTRvkZz4fYPUUEbfyrOe8+xTiTQzGyXmYq7zSFgcdDh35Xo6EBnPstLu\nDbIyg/deBAJB0xmV2ENbhSVzPSVUF07bYUUBaFtngLHrT7TwzWcNDCmCKQWa\n2NfGlkKVM/NvJ7N1XmEKX0ijx9cjQBqVzLLz6MrXl0DnKiayBzOaQ5wy6AjK\n9DJ0qoZliZvSiGDovlB+cez/H5Iqfd8tW5+MK7qw4SUhWhWM3mT9SkKXG0CI\nY9xsGXWLLpEbju8DkxSD8r89mcEblc+UeogmBHjul9Um37R3LQ8n/j3u3UPF\nWJ5rPvnawHbfjEICQloG6ISTXmcYTqInFN9jvLpD1ll/WHtqf6VrfH5elOOj\n6W9WKeD2IDsiOXe7WS4VTUfzHnxmYiUCRxgefy0AOmS/sHJDmFJi/7nE18Hb\naP+I\r\n=EMLE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7b79242-1603546472380_1603546538680_0.7783303870727447","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-aaab049-1603615990675":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-aaab049-1603615990675","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-aaab049-1603615990675","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2abea4f034442e58bb7b780b80a416d8ea932948","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-aaab049-1603615990675.tgz","fileCount":7,"integrity":"sha512-XvmdqC3weoMhPrwkS2mDKQcAKtnNA/FFt7s4uJ5fnCofAzzsL5XtSqXQzchRBf0nlhfeo6J/U+FgWa+7VTgNFw==","signatures":[{"sig":"MEUCIDi+VeVvKM+XF9JuzY0MHKD68CRWAUlcJ5mialBAliKGAiEAz+RZBpSgNjONzaIVLisagNUGqcVRLTGlUh790YG8OH8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflT0pCRA9TVsSAnZWagAAokgP/i7KV2Z28UyQ65S0mAdz\nHgt4S0of46o2OYaBbEQbHTBqOXIJY7sPrAO7y0OtSWr7baM8PTYLMWXOCgSb\nMF4ImyUvePGpdRRez9/rHbBW5X86YyUHn2PnmOrebzR2PiRKR9eWt5EGP2Re\nCOmLJlOvX82385YjQ/NCzN3YmW+l2Wk+QvqMEwLBQ416GZo3D6vSFPwYDDOm\nX3su29ll9Btc7g5RnNP86uLThUx/TWvJFQEbKFYYz5/1EmqUnbCqedx+uI+b\nBtm/e1Qo4RqDTlgtJ/1dXxBfbwA/Pi/Pvw5SGsDqoQ3wPRJmeU2J8Xk1cbPK\nFo3BrYzIGrYhZPVgbNy1PluwZ382RqGKEHbxRB0ieKqCKskXzrMXdzeRRAma\n2PrZ1ToiwhzhtzQaKeWGL7CSq0laCwvsG2iwzoL+mX2tQycMCXdLFKCSC4Mx\nk3MVlzdjf/gbgPRn9bT8l/R8hpgPZ2YP+0/krDvaVLUEhv5nozEktxC8kt6h\nOkIgq6JBA1kj217PGL566YJ3s7dRKJJt6btfV2WxwC8NX1RmjGG0/mE1NnYd\nWewReFE60p5LflraowdIUfthmf6jktcmvLslJ4g7k8ao9o2hW4bqAzDdy3p0\nNUROWe1abB0ekKgdi65a4vK2UWr330X+vVrzcqsKnYlmMRGewMgVKs5Q1jh4\nH60f\r\n=WBYX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-aaab049-1603615990675_1603616040579_0.25462030034487126","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-aaab049-1603615990774":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-aaab049-1603615990774","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-aaab049-1603615990774","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b51e029d838017d8a3c763727d1aa7301f4aa55e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-aaab049-1603615990774.tgz","fileCount":7,"integrity":"sha512-3uXDwx/hQe+ec/+Lv3R+FRuRlqTjDsB1pYDsGKne6yBLbe0NVYG3gyqP93dJUE1oqY/KqMdYXHFoWRpuSzE4rg==","signatures":[{"sig":"MEUCIDWiSW+VdMj2+j29zkKNrA1IZJH+MvbnHCxnAfMzAkjvAiEAgZXlB9ow30X2jq0ntvRhxkypv+rijvk8xf8psJ8LQWE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflT0uCRA9TVsSAnZWagAAfewP/2cc8cJR0RbWSGrz5Lyb\nETu0yirKFRgPQEufuyCAOJwhKCcpB8+ByqIPsU4Ez7vs1fIFNyP3pSAUIcwX\noGrXRRNnmzzuFCfiLyPCXMzAIDkZpxtZ5WTW36QINl7a4xtibonc2w6mIMEy\nvQVVSx8FUPoM/Ih4T5d72UAidHlKl3AG1zPOIqUsHF3OLBAXPuVX9/Sdsxh5\nssjosSgMm1AufQNQ5YftnS1AtGpdeRakRiO90P++YoiD7PZhqYxhrAIbVgCl\nkc6Due+0LRH6MHHqrGvh2qVWPBimM2h1dVFbxCHd15KgTes2VQS9VCSg44/b\nOSyY139XxlN/qFKg0/HJfRH9OImaVLpzBGso1/Dh8NUVRikoApQHMb+7cCgt\nU5nlMkLxzLuO6Yfh53NROloFiLHIf6J+e6iYeyo9k/uQt46X1o7F0OytB+Rc\ntXm3el+dYXEAW8s+YiSKaYQJ77PaJpF23Bxv+UHwtqY9+KBK4VU8IyGOwIYG\nYhGcOnelHJIisP8X+6rMBeLpA8AvdjmPDoTMiBbZAR7jtKfM/N1eSWOB23l1\nQFMMVHAInKrtunUy57DfHdESgt4pdA5aJB3NH5F5Xb08OctDdRNZaf61u+Xl\nbobhY03XBU5a0Bay7FtiXTh/AonhhXFwVeIK92pM749ZsskGv/HBESbRRhRW\nUK73\r\n=vjzu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.1","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-aaab049-1603615990774_1603616046331_0.01896623324670954","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-239c3e5-1603634516284":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-239c3e5-1603634516284","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-239c3e5-1603634516284","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cc4e976d312e46205ae9a33b072ce839e4fe49d2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-239c3e5-1603634516284.tgz","fileCount":7,"integrity":"sha512-j1Mj+dRCJf8OITqYvl9C2xqCyNbZhXizk+Da7LrZNLxV5Si3hLak8DkrALIc0PLfPk7Yo+uJUVk1qFxzt7U5Dg==","signatures":[{"sig":"MEUCIEiXiL/t5vRby2kuez0g23WI+yIhUkzmf0DRcPCvCa8mAiEA33X8Y3gSMlpo/Oa7cFPr+WqoIA63QYfJjh5hIDOOgCI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflYWFCRA9TVsSAnZWagAApt0P/0+yDnL/BKcpd29RnQeF\nwQoC9RWRg8cgLDnYqAfF/bjXBrYT6If1DCtPNZOImnYNyucDpuAs3VqMgiJb\nI5UyotbeN9JeF68MY8euWkcG32E94/wIfsnru0OBjVuAkILZLFTC9q9h4Gab\nW9c5h1b9E9cty1i1JFNIk6iBmEtmxihBMPS1wdY4BB+Io59jEuaGHAlLxatI\n3FwY+VFydUf79O2PAcBceQWVAhAPr0/LR8Wsnt/QFkqvi1SirSVPxxzEJqe8\nQo6GdNrz+QDsLOuaYZIRax89LlXzzdsqVIsMXRPtmTIRaqyHFynC1C8XbctF\n0vYPFuTuyb342XmluJIoC3Afzk8kUldg58Z9tAyX6J4iHGl5HsvtSDAqlZG1\nSBZxrhMueam263ua8D/Ufgv06WxJP9MwlZIFcLi3lfyVBWk5zHqax5Hz4Pc2\njts5wFRTWY4V+q64weLcnek+S/7gOudvQH06Uox4q3sjp6jWLkxYKCXDI7wU\nrxvImVrseSRW4WgaJyrZFdJceOWinstcU9uFNMFHW4B8II+Sno4YcICWlU+m\nUndKSL7TQO/6eafbBf3SQBZnHC7jjm4Mwe773bFi5CaH++CckJbg3fhqOgmZ\njhTL+dqlusPOKjaVlXMKI5qysXcrzM2mKdQuNbCl9A0iSIG/TWZPi621WJUo\nRVZf\r\n=X4mG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.2","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-239c3e5-1603634516284_1603634565280_0.3294138993882476","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-239c3e5-1603634521222":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-239c3e5-1603634521222","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-239c3e5-1603634521222","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1b2e58c6e332b2aab3588a2350db2be1c3ff8717","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-239c3e5-1603634521222.tgz","fileCount":7,"integrity":"sha512-N8NBfKc6+RK4dwxseDFwGmq2u6YvkeT282g1vgzQLKOS5CO4c/fPQR16VicU3nuB+qJLMlBrhD2kjllr8Afe6Q==","signatures":[{"sig":"MEMCIBzPdo1iqFYA/tuMsrqLWosCX9dHacMpsN0wAvTrW32lAh9fiIM/2nfcAgBp+Mz+Zpou407mdlGqR0LpZPYoaEaR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflYWPCRA9TVsSAnZWagAAVsIP/Ra9A2iqv2Hl28awHGCW\nzvinTYxup0yud/MUP5VWOR+THrDJ6NdzZhvBsH5/14QFCc6RNZ57Kc5lGYfV\ncGaYMwzcY77ahrJFkEt1UKd7Zjp7rqLZTC1rbyqEGyMhW1d6NRu93wrGUSlx\nS8yy7mMV82o784OP4TrtwFFHY6pUp0PMdcQBlaaZXy8wU7G1tQ4C6x5yR0Ve\nDs6pGJhygr9E0NnHefJqU6b9suxXYzT3I+hFI5e6+ryEWa0uM6+8nlenD46D\ngCcct1UaGyiLwZ6f5mtMi3+xva6UBzmd2O1Tw0799qm70GUANh3AM8+qPbx8\npeLIqjBIc36uX94CHdiLuoGXxKHcv2y/CtYdMaNeiD6+2n+VxaX7UhHv0tsH\nGJOXyPb0mf+fV/HvnAChNnuy38EiFUc3oLMNAPsDL63LJJ6c2oKdFMtMr5fK\n3j35A8R56RbvdzgjxoKRmzw4iVqfHF/SkCt2v+wHDHRUmYPC2+ovk6pQvhXH\n0ykPJDe0ou0kUaCbAK/hSaZUT1BOo/a3DL+5avOABCVvmXIbcMddwssDdI8r\n8p4zpq8TP2O9P5sIoDSUr9fb+Ec3LVFJXsrnyX40SlH68e5s9LtbXeJ9tLo6\nUuiZDh2IJCbnAfnUclcIwyMxhnVcVgpfMp4h+UisPGo2eInEZLtsLqmpJBEf\njpT7\r\n=KIUy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.2","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-239c3e5-1603634521222_1603634574857_0.956205446807288","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-80e2987-1603653124215":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-80e2987-1603653124215","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-80e2987-1603653124215","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f18571367ba215249612b5cf0bc8905792b4c1df","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-80e2987-1603653124215.tgz","fileCount":7,"integrity":"sha512-U7EMmBmIgrbSjdlrttY2qZfOrj397fQd6Cf35Pp2Dk74COyIMPyelOsgMltJukSj6Bp7SfBfqpPF+9MwaYUtoQ==","signatures":[{"sig":"MEUCIQD+XvnkzXQtmSEXT2Ahqouqq4pPmcW22Vbqjn44YqeLAwIgW0zVjkdKABkZq/lUi9REoJ1BHa+3xi6036c3yYBUHxA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflc48CRA9TVsSAnZWagAAJqIP/2Gf9HlNjIeBDVdqsd7m\nUanrtavgIZEdsM8XaCmOpbm3hlpvXzvJWyw5wqX5KeyC7XIZm3sT6hnGcua+\n9hJ+3aXZPUSeToqReq6A+Rd6XR+FOYtSxAxrWuflLMu6mZMcP0SoZ3J+wjfN\nyOKB4+3rCrJIDruqJ1WkWTXmmFY7ntEQqu0TayGSbPR8d+yo7bsRyFnsblM/\n7R7v1wH0U6uTOCWxh2VxKT5oBMGKpaKTfG3836Jjf0+ACqq6MaOuISwTaGdI\n6fYqOvMgFe0WKesphsRa5HX9NTL2OkMRUXa2G+3lonCMHSh+tNdBXvo/pmW5\nsB3DK84TAGQ9eFM/lA2iiBR5ErihZqRaC4ZMKj+xZC1TsO9GrWlJulqzd2uZ\nVB5yXvXfYbmxTjX/h8ZV6TYWaUQuSLXLQDeAEqdvh0IWDBSdX2ClBoFojAo2\nC/4HyGyqoqtKtvsv4XQXEIz9TMJYreSTjVf11ZI5L/D0FSN5gtFfGXsKZcqI\nZGjr2+G8ABHen9NHoXGFGTNQOui81nKRnx7KqnjzRwedzrf+7nDiIQuQp6QW\nKt6pvCtVLmvXia8yFqkLfbTB6k2OETcH8Sf16cKO9J1aHeLYnENHpNkZHCG8\njJ6AkOIOCV/SwF0NjXY+XgUJ/61vUvmIO27upoSFk2gXDdXNMz8brNptC1bk\nGx/R\r\n=16/D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.12.0","rollup":"^2.32.1","ts-jest":"^26.4.2","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-80e2987-1603653124215_1603653180054_0.9881051278394049","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-80e2987-1603653130583":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-80e2987-1603653130583","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-80e2987-1603653130583","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4f6f70e379cf60905d8a52310d51a48b2921df7d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-80e2987-1603653130583.tgz","fileCount":7,"integrity":"sha512-S46on94J8AqyggtrP5LcHcD6EIiLGxk2Jk2eF+69RXDpXMbNabKKT6v0fDd4LMf1DrNtOZaKoxA79VpHXYHalg==","signatures":[{"sig":"MEYCIQCpvfKOvOw/p2ASl0V/Y2jROm/pBMNq+2A5vjbcyk8bGwIhAOdXhmHM/F5nGpH8gt8yKb2len7qFaJwkBtEVucNdORE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflc5LCRA9TVsSAnZWagAAQT0P/2D1c964+2tiq7pJSS//\njgEejhaaUtEghz++xxB90NMWnb5ZGbW5+EUHBvB12zOgbA/nlf/nxgur0R3/\n7mci3DUXQCsi5K3lFnKtA10/j1KBFkJsttj8rpfc7h2eKQ4uPTg/oJlLmSdf\n7gij6OuL8EusJBbZsXxMHMNA4iHBdPRI+hbwrSAbHWm0eEXQZg0RHFAwQ0f5\n6xynvcFZK/uAo7+YK6tD6RA9H4v1AuBFydTUZdn5MlwjoXLPa7a9I1I9BRq9\nUqVcQIa+9kIpuIJkzbTDSDS5xWnawbTM0WUOOJAJvLgA190zZ4xuH9KAT+4A\nA/BbzRm5Hw7wbnaacnya07KfyXvg+yxDvdvYgisLDlf6Imdkqd3VDu+9sJkF\nrq+moAdCbi6Aw3VJbqqT6pV6VzTrfRoCqeW2/C9vkU5ik16sYFTVZcRoiChg\nNKyCmVrlO84CYdCkazIv6qsZdbh81hZ964NlNEuJoSe27kwpZvSMynHDTylb\nEdkB0Lu2iLmYaHDLPnEz36qLkK8RlClsJ5dciJi05WG1/m5p1T/npRmgWup1\n0NPeqqiZmTHUTPTf2UqXNZ8kBa9Tfh5JHmgYfiicwP0U5ueD2+CGwITH/iLI\n6yDsbeQcNSreWiKui474kquXZgbEsqjiFePSxPlxOjDGM+MTGRrDQr24R7H4\nESX5\r\n=F6zA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.0","tslib":"^2.0.3","eslint":"^7.12.0","rollup":"^2.32.1","ts-jest":"^26.4.2","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-80e2987-1603653130583_1603653195508_0.33826747235858967","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fcbb76c-1603666226712":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fcbb76c-1603666226712","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fcbb76c-1603666226712","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce681cfb463455e3f38721d980b7903fe59dfa7a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fcbb76c-1603666226712.tgz","fileCount":7,"integrity":"sha512-X65HUOpHnT8Z85uKxGPdWEWWZUdJ0rXf+dkJBUMoMCZFXBS7wZ8otariBIZwa+TsZmMJZJSLb3QZjrNV2b4Y3g==","signatures":[{"sig":"MEYCIQCC2Il+kx5izEWVByDkZIkDYkFKAE4ELOLNrSjXc+eiwwIhAIXoiiRuiiNrS/rs5yOPEvdL0H0pxR1Tdv3sqdss9kPQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflgFjCRA9TVsSAnZWagAAI4kQAIooF3Ybe6h0aXYsg4TS\nqdCdhaPJG75U9ic9sMlAbi17tiuDBvS85S53tRHUjrfpII5iEH54IjOSyu3d\n1d3HTJZvi/cd94jnS+tzM3Hbb2sry8o2HL2S4PJm0I5/fpr6HC6flY1FnjwT\nBHNUJR+x8gooTax6KJmxNk85Zow7tV8Crhde8f5BMCyNDxzPc9XBVUhXswn9\nTJTGvkuv8W2Cd/wa1RyvOnPZzoZik5FXW/pI0I4f4E/VaeI3+DTADUID5lTz\nIgZwx/VM9xgLFK2OgM9/wcnwgY1vbkX0k264O7NfdT94f0D8d8Q91Lue1K7L\noP5owyiijOEH/MdnbvQGeg8RlRTKu54lOX5YPaWNM2p5cuK0JGsRf/iQDlax\ngb23MjD89uAMBHl0MnjUhN4NAfdrQRQ6bmoU2e76McKsRZUkUUVvT1nyJx1E\n2pw9m3uFsHiY1cHdwa7qRIFl9KM+tPJI0XF71yNLLLwLOzutcyxQsPon9p17\n15nhHB2Gwm2Fqde8vvH13/Nt9TtBHCX55wJCcACvHoM0V/b2HcApZzrAFT19\nqcADsNENs5Awf+PzWJd5smeZFvkTM1v7+Csfn0rnCEcGHPuXlf9c9OstSJVz\nqyYclRQ72e2iSQabxJqZPSnh0ReZqdGz0rStq6RnOcqqvP6uCH2Kp3rDRj+g\n+A9y\r\n=8Z0q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.2","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fcbb76c-1603666226712_1603666274390_0.04522918330963499","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fb2522b-1603826833807":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fb2522b-1603826833807","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fb2522b-1603826833807","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"726ab4ba13476ae3a4ad30f51a4912667b29be47","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fb2522b-1603826833807.tgz","fileCount":7,"integrity":"sha512-KRRXYnmIRUIU8ggCm1AtF3fdfy/VlZAPeKkflEMUw/iaR2STK/3rBWY+UgfmyH7artIC7xoGRW9wNR75f8DoWg==","signatures":[{"sig":"MEUCICaHVvuHmzbvNVugpVcwhW4HJKI2P1uBEMYQFbUvK3IfAiEAkwIXG4kg+dsh2SJ5YljOR+hVAg2s5eRW97eIoK+Kl1w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmHTCCRA9TVsSAnZWagAAdwAP/20yyYnKHMxM01I384vy\nVkQDs3U5mmjoazr7RSPu4AYBkgjqNhK8jOXcz59SK59qHVbC8NpK3RqgdyYV\nMaQ+VRx0e+QDgWTRgdYHrmxX0HZEBQ8II8lQmNaQgMudkIVZVLSaDV+hwJ0K\nDh47sy7uwBNM+OJYgWD/D8qlXdXCINCN+xJ4sYSqGCQ0SMd1aBGwlmvjEUVd\nB0AKueHbuKkStrGPQ+FAfSTln47+0hY/vLbJcfXXr49XbfNPU3Ft25gQUNAz\nwKyPgt5KLn3GOxtmPnKDaaH0oo3o5MPLjpRw8H3+EQ6gzDyunmclg/2d1Sla\n6Yyy3gwxihn7Ut0aTCBpLZ9xPHbgI0rgQ6Nc0sJVIn3Q7FSwLE7gQ/w22baX\nkeGIaaXvuyO9ap+lzuOvhVGA84+kS9yFbgSH49qLRndZk9KEX7Kq0yhA2DvY\ni0i/bNiSODoq7q0AGA0YrYQv7nS0EA0cYA8mpQlyRFf6EvLxa096eBPOO3qf\nMvbe98QSalM2Q2bU0z6ZYb0WHrf4SfveLlmN3c/Ae1fxJz+iioH/uPNjlW5F\nO+x1cN796xhnxkdIM7JjM9VohuKZQy6a6aC8jV/aRXaVoCF6G/04QtERfoyi\n3FlsJz8IRGydOobOw90HVEdQdfiMjepNJPkOWKBaaZiBIlP0qiVL9WLH8FBB\nM87S\r\n=9YwK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fb2522b-1603826833807_1603826881945_0.19823325781155932","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-fb2522b-1603826835054":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-fb2522b-1603826835054","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-fb2522b-1603826835054","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8f274935eb2504f8d8930c1ad5ce73303c5be4ef","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-fb2522b-1603826835054.tgz","fileCount":7,"integrity":"sha512-fm6UFE9HkR2+96Ol2aFCFU61ZQH5dhn1YmDRiD4qfPJh5tm/3pDrSVSL06gyxoJfwLnwsZ5grwJZ+VtRNsEI1Q==","signatures":[{"sig":"MEUCICbr0z05gfCXz50mxWfqkkMCm07T/h78jQIpzujDoWNzAiEA1Rd2k6nFLvKlvX7nxZYgknSUEw8uKRXGntOTKC9bDy0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmHTUCRA9TVsSAnZWagAAef0P/jUBlElVBLmNXFrIh2WC\nVumLDDndzeaMmsU5nZM7mC4nBxHgfjXUIPjlPttajjxyIcJjkd3uFSKbheNr\nbX+A5Bb6wAqmNAiuKVVHwye0+empbJADKwnCI8I90wwbgbnXZrUVs2nBR4OY\nkxzeR32PfJ7zw3RgZAy/SiziqkxFACDVECnXNtkw9UHXhxOec/IAke66UlIz\n79SFbEccCerJXppupStuM2j7jXSI/mGHRzCFcez697FexjW1hx7CD9yJjV9h\nzN33Ovn3lFEz6+R02czCIzyZr+6orawc6G+ourp2R3g88C9FHLrEEtkFNe8c\nRo39zi56x87RaQVWK/qhPcOskgcqCURG7mP1yz4cdwXjQa99Ngyv+J5ooeLo\nFRvzLOmQDLM2ugF2tKPAuY64CjR1Nf3D91hURl0B+4pqPbceiEFFGePftU0O\nh2rhRq5HGwnr+vz1/wnPOmEaJ/NxSO8cPbRpnv94PK/l2I055dTMEBwIYmFi\ndp8ctbyfvQvcbC3pypCZTVEyRr0tftYb6TaNFMbazyQUD9gAw2UgOGDWMRDp\ng5M0SfOjJ8w2tW9U3/M8KETjH/rbDHEyv16ocfeORDE6DSQ1RWlqqX5M0DJL\nBuzgw5eIacUVuxgiRcd4DQtkQ4As8uIdyxYdEMlyoh+5QSVYTZTk1Ss1PIS2\nIRtE\r\n=EsnZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.3","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-fb2522b-1603826835054_1603826899688_0.8079783377473939","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1c50815-1603839105229":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1c50815-1603839105229","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1c50815-1603839105229","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ac27eb97f4910d7b3179d54c6a4a79cad0106152","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1c50815-1603839105229.tgz","fileCount":7,"integrity":"sha512-f8Bra2eU4kyFEvZpyYwkHpTcI2BOmh0hYmcLg5YnJpQe6dsVlG2cxUs5/61A8QEptTVwlq0VWkZWWgH5/yEgQA==","signatures":[{"sig":"MEUCIQDJxqHsigUMo0U5UGH5gm0h5jd4VnPe8AC6rIY6xRRmiwIgTPGTbIQYspiJxfnS2SKon7ibGB/Jgk73AqQC9tUiS70=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmKSzCRA9TVsSAnZWagAAxbMP/j04L/47ayZmKH0Za4dY\nZ8Zrw5Zhrmw4b9vvMB8K/fz/vYuA5cqQU5gQM8uTl/sGI0OP9yFlO4hBH0DE\nDciUrOd954VPop36UmEE8mUXw1pSzx85Kws6Zo+KHZwrT0qqEs8B+NZgDlsK\nLG8KVAOEJ1I2hFuZvehQ/2rLGgkoTOPT+ORUeRroI03QU/iQxiLpBXqhnJrM\nTPuyYeOMWwkkZ7T2rsFdl4qYW9AQYCQuKPnC7hnhOmwh/nUidR10NcbjTFok\nRvhXAeea4iT+q8zPOyURKx66GQsBwYJFVR7NFgktyU/0yTHuiM3ZAVEPlPpV\n6DxiNmoQCRh6zPbgWIsTAaipXCfgkIZXKXuQ0v8okf8PyvyA2JdfrfHnRRqy\n3Mgtcan7SARQhecuQw5WoRe8Vi4Q6nmX/Uc1Xf0oCiUnPxqs5ZicTqoixW7f\nkboJTeBYcD2RUuuVURmnw2G95X2fYQ31Tb5cyU2CtCV6jzwRIDmbuFJgJEK5\n/2buMlc6F+22ytP7Si3pPcl1pRGMG5BQVeCBuIdZLlWJXqyW1lLI3ExMFvmG\nRyHBGNLcki4NwqngBNs2J6i6+E7vV1a51T1PJkOsdnxzX3Si1YC5oNNwQKYl\nJbFX6pQYwLmDAe7m4/7gPE6QacuhGtJYm+B2kUBI/MNM1TcbmQBrktaIDdXP\nYEm7\r\n=lZ+W\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1c50815-1603839105229_1603839154638_0.5062855927537595","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1c50815-1603839106313":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1c50815-1603839106313","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1c50815-1603839106313","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f23de94602fba5863ebb2fe768f2ec96d620a1ce","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1c50815-1603839106313.tgz","fileCount":7,"integrity":"sha512-IjkDMkdGG5YH0hwQzRhREYGk8EJtCm5P3D50+GAvlhlNVweQk7mcXQGurv74k9QJ9uNZLaXX1BQKktC5UuILEA==","signatures":[{"sig":"MEQCIDYdkfbTLu7aQMxt6MjsrEd8x9lkbOPePfzn0lD/WT6lAiB/IhuEvLcKguXNFYqnCQaKDk5zDZSN0gBROSRlvx40+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmKTHCRA9TVsSAnZWagAAoXQP/Rs1mn/shcj6dXTMA7et\nb+YF7++Si7gVPj3MqHkvlLHJBP4lC/SCCljpETxpszpOoN5CIWUqnWFpsZ/Y\ni8urzRaK2rmL58wNEVWJ6pIKjkyeap28cjJg73fCQZUEzO7oXxZ/qpicpi6j\nz/LBJtA4R3BsX4Bv0+QapIFyUXZHJMxxam4cb0+tutnp5PItIChNXuJ5GKzh\nNwe7j2LpFeJj0GAeCQRPKJ/6bJpkEMUxh8Hc+0lZaP0N0lvO0sIhZh/oM/1Y\nJcZa+EhuuTTmm3xeWWCtiHiwe+ejHE6ORTYDlsi0g9iLhXUXqo/ferxOMyQh\ntHccJfHuuE58byL2SXlXhGRve7BgKqS5YtKIBubDdJcXA4tz8LxNWn8pFI1G\nH2yjw6M7nMSJOdtHrq6w/7LPpK9OxM1vTe2CqrhJAeKhCxJQ4pNPqvJMlfE+\nQ24r/k47Ol/+TecVTpPZ9aylRU3oNcsn/Bvp6kDh19OIztPpQ9e1VpUkWJ7F\ne8gylPhWULHHS5s5TbwEuuxurWArnC7GNlOuVP7OAnMfu1WGl6sdhRnVeCe3\nVAoG65GqmraKNei8bzC17i5DxBPiSlNO34CuoNFbWJ0sfajQofYlJjf3lxGO\nCwF66KuQGS197QHuegkVu3LFnG4q47uPSrIiRfbySUbqrB06pZ1i+JScHA8J\nILQc\r\n=tMai\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1c50815-1603839106313_1603839175505_0.9951968144934102","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f559cf4-1603845393759":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f559cf4-1603845393759","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f559cf4-1603845393759","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8e8b6f79f21045810e5e816a9bdbce57cb08fad6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f559cf4-1603845393759.tgz","fileCount":7,"integrity":"sha512-glhetssazdRqSsefAqpM/osadDAzbZkijgbtW4x0rP5jucyZXwKbP25aTSeL4jlDRQdsSkX0W+nGeMgzuwbxAg==","signatures":[{"sig":"MEUCIQD2vEQtTvk5jecBBq5holJHLr6qdRiduve9GiuG5W6jmwIgY//IWzzw+1KSPRHGz9jr6HlpzIy4QgTUHxoKostoPbU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmL1DCRA9TVsSAnZWagAAILQP/RwoF7mgPaaRXdkr5INP\nOnNpI3IIGn1ILyoEzk9WsSiGTX5zgqCcrCoZD8BT/w3e/pCVaYijFY2M0XLb\nyMGvB1uicFGsinUgRXVluAAAiry1YcTFnJh8nkwIHKwurdFHtN/0YDCbkAeD\nJ88I5a98zsJWQgVg6AHgcL0vTPgOEEa1UMbNbI002WPz1c31UgrmvhQAjK7J\nIS9oDzk0V+juGSVacYwfhXKHZDK4RibticuESoFou41w9hrKsjDrH4qw32CP\nGVE3hMrgHIS7ZCFnDCgJKOn0EFl8IYdO1oyNLsBkG/IY2Ig6MOLBUXV/KYjZ\nAk4vbCaAxaz7rOWrURVVpLxO/IUvpzQM5TXIOK3GBWHVhYr1/p6nlCa7HXqg\nuEq+iv6Da47nANQwih1QrwODlUct5kKYKwR7aDXFBR1M/d5I6s7qENg5X3gU\nVM9vlA/a7EtIhD6JscVPGCmliDig5akuUGiQqcgB0D+a+zeDcdmBCZnshjRA\n+DGJsBCWHvk1StoxZ1SlZGxOQxC1DaftluWWcvyh4s/gvIYkLW3cCt50zUgw\ng2eMXuSr8VmR7YLKiWcWspZGKjG8C95QA43Xf6O4hTXCXwyK/T6BVT95zb9j\nPyD7RN7QdawNkoaDGthVYUU0/NTHVBtNi3QAPr393NVJJyQiB7ChyrukYhcU\nZcGL\r\n=DCBg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f559cf4-1603845393759_1603845442912_0.1291532640712072","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f559cf4-1603845395668":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f559cf4-1603845395668","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f559cf4-1603845395668","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0c7dfb623d98a3e32eb6b4598639a2475d35f3dd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f559cf4-1603845395668.tgz","fileCount":7,"integrity":"sha512-EZLDam1wFuDf6U+vAfOu0oC5zmibWq3gU0O6v7u6SQivrwFpTUjL6JBJmVnxr9SQLVcwAO2ER2PSl8lYfwmb2g==","signatures":[{"sig":"MEYCIQDT/yG9Zu51V0a3mU7l65Ia9tIuhwSPXeUMFI0jFt1FeAIhAN5Oigwd3vZK33rtYhi/Uc1wLIPIHaJqEp3QpGLKdTG7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmL1YCRA9TVsSAnZWagAAPlcP/3cnDxqS0hmyLPZM99tx\njj0fzXJpo0ZU0YzouuFvqHq2i8o97jjw6gLlGgYnJGm99cqpE6by5OJiBlcG\n01fQ0R4xp2eb35ws8pHax5zh18IKu0mk3Hvly8h9xrJSZZcHFabXvBEHRSFX\n6jMUkZtDd/HcJWMI8mOhzxwIN1jDn4zqzWP5GgHULE1wVI70OfUHOqE81Pn/\nxEkpLnpOx3U4GOfSGpy8eqtWbKF0cAV4qiVuCEukuWr1KMI7QvESNur0bk4K\nxw+k10rsYpd/XNvAGZegChFXNZyuVCah6Us/aqJ+iQjeQPooZblcm+cVJ1Ly\n1RU8h8CQgJXCde7MJpTfAYr8ZiZccrmCY2K7Pi4x2JYWWRXXlu1FmkfLQ9oH\ntCMaF7PisukY+HEEpIo3I0vLZ56lEqbwgoIi8CxpQYDf3sZrGbCsuMils2Xt\nv0GCwO+3yZBRF8+WrH0DBXawE+xXi+eRcjZnzcQzxdyjhY6LGT3Nk0IiJxni\nG7Cjb68/pzyqMFquLbXwLli1jklAn4TDHXrtBlgozJylKrsrV4jFVA2QJnIt\nB8kmpSAyJ0SLQUFdlYTgSOJ++pESytOMRr9kM12WfsgGO+fxFnFpVA6OHDtM\nF/xzF5oQODHBNwlBGrpbciWLMIIZeu3qRyEZOY7mBjDk3mkqCVIgKbonudXW\nKz3U\r\n=6SVs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f559cf4-1603845395668_1603845464153_0.20860485829604847","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ea5e0da-1603850067955":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ea5e0da-1603850067955","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ea5e0da-1603850067955","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"32d253dfa989703c9bad97fa21d59914187f2030","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ea5e0da-1603850067955.tgz","fileCount":7,"integrity":"sha512-yjLXV6eCN28pT/fB0bq90y4eWnqrNR/9jdvde2+4stZKJeoOzm9nHuT/pu4oWS4BlOeDqEgigEyKmrQTQAtnwg==","signatures":[{"sig":"MEYCIQCHTqMN7jaGRv00t6gDAz3684o8D3u4aTMUxM7lVAaSDgIhAPXN0HdqThAITdMCvs8xfoRGsVdB/PPMFgEla2boCfRI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmM+DCRA9TVsSAnZWagAAPxYP/jHJq4vydEJnFbFc62Bp\nCD0G8PfcB3qsXeoV7Njf8bhYUn5r0ZxdpYzkp0Pk5Y+Tuvkz/6pu/Px3/Dx9\nJlbEI4UoETyIPHi9Y9dKWZeJ4bXgz/SnUVkmjD1y/rHs54HrS3mRwA7ChphZ\nx9C5ljYHNRy1wr3vyRPVRxqvlCo4uZVO1qngRc8Ewyzv27QpptZ2lT0IUifG\nOfwSwt03QJgQR4ZTukb+LfiouDZLTQBws6/OftQbT3qe29d4BnYG2c98yo0+\nxq8vTDwJv9XCEQ+EO2PNPXyF7u9Oz2JRs2XMM4XzkYr+SNLWmcuWCZpxwvMk\nX1HdPq8QBnAR3H1am0f7ZUIiqdRcPPfGvlz9/q9TC8YIz3Zg2wznqTyljrop\n2EIstOUBbcRo/JEx/Vpjbh/HJmK4sARlgqtCFYQxKhn0kFvk36HeZjY9DoMY\nrCxonvRTMov0Qz/bWFJoYv5LiHemDukProZc6am+n6/CeNFtAwnndxEUNtx+\ng6Rbpx6DXbLmEW9iAJYQjbMtjh/Q+H186ldFHdDFZ8a6hJ0pQhII1fPWxSXs\n4vuGa5oqccJRfC0bAfNItI+LXDHkl2H6MZwN71y/q/KzMMMx5L5InoyuxQ3P\nYhcIaBi0/aOhZp0sopiF7rXPpAfGhm9uHhab7D0rrsqwfLkiuT3QQAlBZufy\n5TZx\r\n=sJdL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ea5e0da-1603850067955_1603850115013_0.3699729922404973","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-ea5e0da-1603850066538":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-ea5e0da-1603850066538","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-ea5e0da-1603850066538","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a63369fbb11cae4119a9256ac2132beb2652a206","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-ea5e0da-1603850066538.tgz","fileCount":7,"integrity":"sha512-/BL50xrtaPCdKuuI0nS3gVP9t6e06KPCqewc+gxUmQkGoCwQJsfpv1STmL7K6Vkb+Yb8Z/TIYYSWT7TOeTs7HQ==","signatures":[{"sig":"MEUCIGQq9IXFFu8xWRjyTeen7kedLvf8X5RJ0QJCI8eJDoymAiEA5xhAH+TBbNfJ5S0jiV/294VCkgZfvQgIw4wDGvytX7c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmM+MCRA9TVsSAnZWagAAVhMP/2dlZXdFFLoSnOUP4PQY\nowVsKowKd4DkerQQQU4vwPUuSTBcy12eFMJgb+4THHXgslHiN9K6gj/Pf30s\nmQ4wQzCJb7DxVzr4ltsEA6gtTe8ZQvFlWJ3f8VHPbp9awVjKNFJbUw24K/JX\nV6mGOgAiRwjjg81YYWQ4jCQWygnIa8vhpGXlpA3rD0D7y46wTJ1E5x12Z2h7\nMtmbd6eE9if2bNqyESm2n3E682ICtNkBVFRgWz/VEHbJVFl2PJ0XMzbXodTc\nlG4nOZ2V90wOh2aMsGpeLhA12vPFXLOFYW2JjhBemisI02/On+s77cR0HZkE\n/ffhOO8A6mVMMIhaULQjY1iAhIGNNWRdVzpuazIP/wc3DtqXZ2cXDg42n67v\nSV2BsBnvSEh1/GT29vlSbdTyi9P5oQHYYqp8bwE181eriolXDy+s3JtkqSjU\n6JfqtELVLMRSYTztXsapsZcQOvAdRKxl+9Ptzc0pdbIsJIQQbfwsEs0jyNd7\nScSmU2L6gqKiflP1WJBadoKL2PHjQRm+5oAb+UYLz5SyBp5EYlnRofp+bG+R\n1bIp9C1hLhJwaISoOk3tEnpsbsIXaHVsAbJIvcUP/PUzMcfaoC9K6ih5b56M\n7MQgcabWzSzy/ZM4GdV6SB6+Yn8cUCHl1OdIUcvEx/NbTgW3Yw5jmlCmhIVH\nWJW5\r\n=Qk4u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^15.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-ea5e0da-1603850066538_1603850123809_0.1408421284271717","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5a8be5b-1603908642665":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5a8be5b-1603908642665","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5a8be5b-1603908642665","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cebb6bc217a76d0154cca2f86630b541bae9921a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5a8be5b-1603908642665.tgz","fileCount":7,"integrity":"sha512-tOqoMtegO1lSiXwGXzUjVWePI8Oecu0jLLMzBSrL/M/I0s3UYrDt07BEfsEiIp14R26K1yer3kLGuApD5JcSRw==","signatures":[{"sig":"MEYCIQCQsby6C2ItMI0QdztYuTYNY1m+0bmIjqCwrMEqtKmDGQIhAPqJ5XUs2knimsHYIdBWffbkDsYCKXuNUU347OGDxiry","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmbRZCRA9TVsSAnZWagAA/ZsP/3K2lXgohPIPjI4+15nO\nWThv2XCX303lK9arccMONeEtmPcb6pVMBdCFrEFx4CcVTYIP2mzOh2mwzeSe\nhBkh4MYO9shk+Uow1Z1GQUnHEddFFoy6GoMr0c4BZcuYWU+IsO4VR1i8YEal\niF0iWExZ5pb6Ndc8EIwJaXK7sg19h7GPvNkiXFVwECuQzky1EfVlcSTZi4cI\n3Rknz8BbytqC1yPxsyJXIWRb4my7yTEV5qs/bafVt3SekVMFQrEo0iR+ArEu\n/BoF67X1YEbDxbPQXV/LTbxzk7UHQT7pzK1PaZco760JuyfL8K/wjDl03O4B\nIxAQItdCknWkgSXzIlBYji7voGemaQVj3vVjX7ijJLWivYkkcV2J+vCeyNHg\nE4K2oi8sVC+z1plPA1tuw96AwLWVsOTANceSabakroXd9hViL4tl0BSRfUOn\nVJLdsKylAL7zsg2lMM0GlQASl8fQV/gOYJ8o3zjTURu0gvSxoiP/W/VoF+Tx\nObKGSDtBJ+eG8MtUv46iuZvfFf1UJ8/ndudwa3LyZxTXsmIJrVMyOl+M4mH1\nEgyn1Yu3RpYkLakH6vwhWNdmoEt/TfT0CsFa8+ojYY9AaoXqL4ZK6lOJpqXa\n6KgcIkacP7UnK/36teecEZTW+HQsutaVJzWfw2H4VfcNKkoycQuFJGRdgPAv\nOC/b\r\n=y6z/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5a8be5b-1603908642665_1603908697324_0.14942825852699682","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-bd589fe-1603955408835":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-bd589fe-1603955408835","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-bd589fe-1603955408835","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"638be12c4d1d19fda54607bbdb6fc1f378a1cd11","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-bd589fe-1603955408835.tgz","fileCount":7,"integrity":"sha512-N5e5tWfWCUGhsd41jbPMuWQxX4Bb2F6kfdHVwGudIc7PR6GvGfEgY7lyGR2xJobqA6ZmnYLrMsYeyAdf6KOm/w==","signatures":[{"sig":"MEQCIFii6WvKsuojoq+oUdzJioQ6Rr8JRNtu87gwONA/+UMPAiBTdo3n+WYukZiqSrDIkJoHgLkRJHT3lgdLNDsB2Pd+ew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmmsLCRA9TVsSAnZWagAAl7wP/3QkXXE7VBW+L9kJTc6q\nc6BtxbqheQq4JihmyznHS6Qjs/v1S1RW6+ZIsnHxiBVeZdCZGqqJOk1PYy/V\nwEQ4I7qzj8i/ipWFZmpJHFK5Af6bd4VY8Bb/MEXbdJLGSabRc/oJt3klcvm9\nnALoCS7MWFTXdzjyCqPEovalpGqFzxe2UBpB3qB91WSNkABI/EjD6tVUHu5F\niZiFhOpjcrK9Jms9A/NcA1EtItHp4AokzzFh0e3qspNmWXyIKZrDt5FQWi6R\nVDraWSVL4NkxhTV6JbOekvVcYwY4yg2cg1//EEvXBiAHoxcPd+KxoF2XUGyt\nz9BbhH/kyMnuapQVXPDJhy3eWc1xkmmaHUTHXNHLWq0VXYKJMPWqXafzAJWt\nkzx+Wyo6+u8yldRIotByzNVFaqpBKHuNFvGjGuHXNXK74Y/5aVPsRIiMcMYZ\nQOcxerl7I7oVvCBcaLPHFcMsS3/r4LNijnN1k5IHoqLjQv6Qr/zd1/APihyC\nCpIB0CLew/ZabcsN4woLOJ4WhCB3kDzH3i1xy9bZvDxiNOfnI8wLu7AVF88Z\nQWgzY0/JGh3PpJ/cwydAus1nMW5iLRgsTQbuCiCe4EAAgGY/hwtffgrNryKF\ndRM5aqgoErGWt0PGU4RCBAc3yfHEH6/qCceYvIUxBUqpGYCcDdhavNbueLxm\ni9gr\r\n=y7PF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-bd589fe-1603955408835_1603955467258_0.40468101336464013","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-f555d5a-1604107425250":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-f555d5a-1604107425250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-f555d5a-1604107425250","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"608c37d738a911b7e90caf9c802513f19cc5bb11","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-f555d5a-1604107425250.tgz","fileCount":7,"integrity":"sha512-+V/drX/2Tf7Iu3Rh/x5aK/8+Npa25apKQE2H4qDll2ER2CQhnahKW8xpL4Krlo2egnZuMhSsl1m+YHfEmGGNJQ==","signatures":[{"sig":"MEQCIH/DZvJLHonFp1Xa1i3W1YKbbLowQO6u7xk7BnUNaYX7AiB6UBP2q/swGYtqn9vQQ0eiBDWw084UzTzlzs7bJoOMFA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnLzZCRA9TVsSAnZWagAAfQYP/inF4e85YIthaMuN8A5g\n2dagF6P9kCMtXpfhJpC0y1INTITQzNmtOEdVRevoV4B3nLN7UloHXVfHbT2b\n0VmmEEVSuExdX1SF13lPOI2m2uHSs67eOv2pGgud82rmD7ga1GItZFyAicpX\n2qj3JMFCW3jiSl1uE+IUqnWw9HAaHHaq62PXoQbH8I1aUujSCJYZ8QbU904w\nQd8upKSHWB1/oDQpFMDjI5z18Upx8Up2Hp6h40Nagt/p60EzQArOSc1XNNlK\ns453jdhdkA2S9jkIZk0bcKExHMg4J9zO2hbMkZlJ74lxsB0TgiG6rWCA4uE7\n62Z2bhOlDJ5q2jzuKfB8zCC6xfvcVqUCke+k43AuMOmlZfk4ZUTe2Vk76KvF\nFIaf/Yh4mw+xYkhvhRNZi7yncbP9RYm92iyVeWglYRQBjz1G6U6vw/Raj8hf\nTpUpshVuIPAOhgffcS58Hv91qe7n8jJ05kMvkx1GXY9m91wlUcWk34dCkmpL\n04KcvLYdyAb2NxTa4c6GZouwIPt7DaV1zIcAUe0MnTD3X6AUjRlt9w+6mFiW\nhhQykDxriASwUwxw9ZbB4nScGFYFtT6P9tvR53DMLyf5u2Wb6nzBdnbAGjA/\nWDALKaX6FuRmHU6pUCnuekAAacZoglRrU7tIv98nYSHi+IWp0tK7E7DP6K0R\nP2TL\r\n=khbi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-f555d5a-1604107425250_1604107480761_0.9662754849637294","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-46370f1-1604107425119":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-46370f1-1604107425119","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-46370f1-1604107425119","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c4c560cb34332df9c9d31bee43ace936f3d9ae7d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-46370f1-1604107425119.tgz","fileCount":7,"integrity":"sha512-rk67gqZ26+HqfqvZcCN4LQEnR8Lz7+AhJLtKrg/j7nFst17KZhSWudehxFPmWgaUXLxWXaLAkjAZTc8GTp1GHQ==","signatures":[{"sig":"MEUCIB1rHsNCBBNzvIg/CYrAP5mhNlgH7WeYFvrcYZrdZJTmAiEAzEIirTHPPjJjow/eEl4gN28Voh15MRp+PhKHaby68pY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnLzpCRA9TVsSAnZWagAA0FwP/jz2rU1DNWIDoi/yPc+H\ns+SfZP8wMZyhxHeDaXSL7Ido9MGsvG7sjy/IppaLMnKOpgbcNjvSTlt61LmX\n33gdYj/wnHjzCnG0g8Xa4tA8EnI6ZfFJyqJ+9QfKVu8tK2ouKxItJZM7LgcW\n8vzTtQUozVbxfkd0VhM7u82fowOMyOOUlcsUziauMQZdroFB7NcFlMrN33c8\nLQPLg06TzxTnednORTxFKfDMDBfcf8WKOtpIcAsoptLXRt9kkXx6RbVC8kWI\nxpTfL8K5JkJMEEYllQaQH0V32OVlYa/qzKhWNogndwcQd2+694ta465qh1kU\nZMfuC7YkhBYXvcVZl0RmWE40BMI0FdCmwvyoTrmJ6q9nqNVpjpMF5wuh+j/I\ndLCog1Wxn8eWa3jHO2mELlMm2oOmm1/3A5S99H0UbDrR0ssCw83mApNWvhE/\nZuqoigIJ7hXmB7zpE63dKOD61I2J5HmkOyZ4NzMTf//pRIB2kiuEQDXoCSoS\nO/Z42Zvko1es+Xo8zrBbuHyl3eyYq2OtE6l3VA7R46cZ1KYTPee4g3BauFot\nFEEZA0MleQ4EN/XDKOmaQpZEcpt8S4yM/7MuNHVJtD7QhQTQK/04koHXehsE\nwjqaIJhU+lXeC4uNgDHMp2T4kTMpb/yzHNCjbuWW3JkPeBQMX7xbPOfceBL3\nPVZ3\r\n=WbTE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-46370f1-1604107425119_1604107496596_0.5974471209516108","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b940b20-1604128025754":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b940b20-1604128025754","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b940b20-1604128025754","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6c3525edf2da1f3449ad7697f87800d136cd02f4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b940b20-1604128025754.tgz","fileCount":7,"integrity":"sha512-Yn5DA7/siRJ2Y51QExGsCYO/sJmOxTyPaF6MlVrCIT2a8+dEJBkqc05+rCLGCUcjLnfP+zUKuu4M+GWIBxwccQ==","signatures":[{"sig":"MEYCIQCUjeECQeE8wRS9Qbn0V92365zEI2FO2zBmnM17bvD4SgIhALuKP34tOH4y9y+uVqxXWazonE1YLC3Vuw0mbLSxCsBV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnQ1VCRA9TVsSAnZWagAALj0P/jE4fY3xVUR3BxN6uREx\n9DjFyqycEqdIbQQQ2wsYbrKYqob1R+QcTvE03m25vyy5SQhKQ+s+DlIYVQ+T\njoI6Igst67AHjQhjMn4CNbenK1Lo0B7vic54VZNjRX0CptwtGKEHdCGceU3R\nXEwPRVOY4ByxI9KfJKxOB+ugmpyFvviqm/7Prw5gdIfJnBuTFSvFjksiAAnb\nrzwImuhJ7f/XYtv7x8+UPKaeOFSZYwaKgDbYOatdChqk08pAX3IDowZ6ruU0\nqmdnQM/VA/wl85nCtwHu+SOvqnjz6RA+NThJv9us6rrJv297N0x/tOpqGHRd\n+cj9wviKNlrpQ05zA4eGkssPtuwMbO34pJjDSFGUdhr6s3KZ29uaW8HJkedj\n2/WdrGbTeE8qXCcwlnMSetpV+6IsYnZjPm1RggwLXDkIKl31jdONF25PjOVV\nnIcwjdEQ6Rnmli3fZFb/9wfdf9D5CtG/CATSonOm5EeriNtW+5gRxMGbs5zA\nfg7L6iTn5cxK0iWQmcgF3nXVfuodrVO67eGHasTc+EDOXLPsK0C7HicZ11pV\nHrWelZkEXVcxRcmlYBaTsjSip4zb03LTBxet4rJo1z+pOEpPPklrcHCg7+XU\n6CR98eNecplotx4WdfkU/sLohePx8h4SlGz7R4fn1pLtMaXXeLR1MNIt1mJg\n886N\r\n=pFPY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b940b20-1604128025754_1604128084854_0.04848598846833041","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-73f3b6e-1604128189160":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-73f3b6e-1604128189160","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-73f3b6e-1604128189160","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"18d3d03c59bb768917f27c211a0ff2bd2dc7cb78","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-73f3b6e-1604128189160.tgz","fileCount":7,"integrity":"sha512-q0iJkvtQr8IBGEHZ+1fxfMfaXnMkebjBmYxp3wjOz+NOzZz5Dl+dkl709AWGAVNlTY7ekEYTvR+OTitdS1EmhQ==","signatures":[{"sig":"MEQCIEJ6m/XFdBNV0lM52kMLfY7BAneNrbUT+Kpu5URhz46/AiB7C0xu0hMcX1xuxE+p64r1mdy3FKPnbBuEfoPxOECy6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnQ33CRA9TVsSAnZWagAAB1wP/0jlENd+qGHnU6TjHG71\nEeWjR9TjCaxsO1goa7hfLeteoGrrE0nLb7MsIRdnrar/lKB8rFcWnH/jPjUQ\nkt9F0tbyq9gqaiK1R2dfxeVrJ1FeYhlCP6SI8piqlhAgz9Gs7IAYO33t6p9J\nE6A7K5jSyOr1mSCrPCWcC2iH4tMY/U8eeQxXFql1UYZEGWlc/d3cYI2iLxfx\n0oQMpqG7iwAmoKM9BZ8hoRYglhUnrMwoL8VES0siy2VyCm2jWVXpeX//P853\n5CSvS6uGZt1P7QKrNJXpx/rYeX9tH/NgMad1RhL0LKfm+qPKZQBk0JqONksq\n73tVReE2Nl8Gs0+HMsXmneUsxnYgtPtAkyYfMk1GWQ4rJm8ymE9YFnRUsOne\nAz5H8+7kRWtwRYpy+ZQvIyj/zKsm9alBObiIpwiCSufy8940DC0UaxrE4tSh\nBdO5o/NcEtKm6wqZ8Da/DduFhwEEQAjEj5IAS5gIqwkngSSvN2V6hcMFvUHo\nx3lDN2OCbXJGmesB8XI5EFQhAadYlc6jZMPYf0UwtuU1vf5da1qRVUlE+111\nCt9V9TlR0+H08Cmcw6tNxVfloyLN0tczOH3x8MJUTVhGXnH65LaansnOhnOY\nPBgYm+P7GTJE9XTRYHyoU4dRPwoQtdbNJeHc79Z8PNFH6rvyb/NmscN/3D7K\nonFb\r\n=2lYb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.32.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-73f3b6e-1604128189160_1604128246980_0.15859530999355442","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9b83162-1604213894680":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9b83162-1604213894680","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9b83162-1604213894680","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"33ec9d7c91f4e1c3fcd6ec559225f166b8532304","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9b83162-1604213894680.tgz","fileCount":7,"integrity":"sha512-O8gaBzkrEkhyRP0t6sJ5zgxeCVKkwcplZWlaATZX7tYPGeeEanTWya/ss7wvkNqbx6HsTJaCMbC8GKiW0nY7/A==","signatures":[{"sig":"MEQCIF+MYNpxb9t6WZwm2u6PAPpYiFeJJLwFPubs1lTHKajfAiAC/Vaz+VvPtkDmQd83BhOrspeZPpBFgj66vC34GaPs5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnly3CRA9TVsSAnZWagAAEHIP/jovZ1lUYdNyGcqMle/K\nQxKcklpfaWQlkEN0rks8okSOCxEDkgsu3SJoTXOcyAVjyfS+juvJma0NHFud\nwYLrZXNXukEkv1E4/1DQuQpkHR5r5cmev455Ia4hlHk2RxjGaHccRNhVWgcK\nyFWVcuCnsUeBXDaHkkjY8AfEFWtuCFDFy/vW48IYYJw6pfuBrLkC0ThfOA0S\ncWRSgyhFkAlyuDdAam6mxohSnEXN9B+Dm6XekPu/W3W1I9V70ZDtNSA3D/Na\nQV87bzs29+19ScWxIHe8QWUqWNTIdMb3OUBsy4LF9SLzFT/Ys9PPtVjGWEZW\nQkakYScG25Ckpw6rHFFhV58NxQIcTPSBHSmU9sllqmX8Ut1ifBmiLVChYEXk\nX+IW0qn/u1jRKoXYa11Cn4KW6cF7KMkqt8Fs4j9fpvM2zLht4gsXaMrHbSl4\naQV+BSYNCF7mRBs0gH3WL3iqQx8na1+SDe9rdTWlbHOUOsGWnABqXKXDTT8I\nMNdQB7vo/ChipIuIjYsojzYjK1nBheSS2C2YYWP067rrQMIxWBOfRodatkNI\n3iaJ++i1IMwt35Wso1avGN4ugezSLxhbPIJeJl0llnhv/nmElX/dCkTTe1Jq\n/hg29ZxBhPFIiR4YJmASBCLKX8tg49/p+wHKEmuLcjOiEoyK6pTlmVf9zFCj\nQmVU\r\n=OH9B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.0","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9b83162-1604213894680_1604213943032_0.10756967358118819","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-9b83162-1604213897064":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-9b83162-1604213897064","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-9b83162-1604213897064","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c6fa01cdbbc01b65c21830f0a3834718c5801951","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-9b83162-1604213897064.tgz","fileCount":7,"integrity":"sha512-Qd94i+2+pjqvy3isq1ImUaiLy+wMTnbPeVUV9I6TH8t82xWuuVLPh253R9CdDc1d3LZMAaMMoRhdo5ixyAwE/g==","signatures":[{"sig":"MEQCIC9g3R4QAyRrFSG7eduG7G60B17NHNZnS8AXUAO55LD9AiBOvkERnS02VnZTLMAH8enYxKWMSDUdMVcZ8t6BAumDlw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnlzJCRA9TVsSAnZWagAA0QwP/iPv1TUQy98dRv7VKkXq\nT8vkc2iBVKkRs0Botjqs4FfSo9BKiwSHgFCqmohnMmLDDlh+Av5zNmecuGhb\nVisl2kIV8xJsBKUnN9lc87ccloteUp7mYzZZYXzgzLLGAwBlVxfI+m8pq9Z1\nkmUDb6v5XHqsvTHoUwiM+yyyfIgRrAsFbb+Cb0RNjjafMh17ky257RtVp2z3\nMi63rIPL6Ns6OOxD/yMpj20+sQ3qr+kHhdhE/c5eOcB6tle8NE+ABWsIH7RB\nW/uKEVwqCD5XmU/skL4bw8hXq1Cg2lL50M2yU2JtlNS9BVufAH3eySGW1MZF\nGbG0Hh3tnwMVP6DPav3LugbISOMQ78utq5ORqpTELoVeh7lpHiy4nU1uKZum\nNkzaYosT37PLRgVaGrG4zE53dePmxghGZZsrpKx3YOwQOAgPuF7jK1Tv0d2F\n1IefKdJ+BBf2G5U4hKVwwKQ13/kjLFGtUuHcKDL14XBXlSVPoQBSmczspcR1\nNZyLTntk4dOS7Z0jqsP5xth7axIHsRxAFSE7q8HKCVsjcuR6yJUxnMMbVb3d\nILtOQ6lw0zT2Yiuo6SXtX7A5oeMZ4mN5oEvS/96AHQV+v+wdMNVPFjcGSD/C\nDuznybT1JPHKX1eQNTpa6+B8HgGuEp4TFDexWl8OlyNAd/JG36lv4LQmJX3B\nJ3C4\r\n=WRAa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.0","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-9b83162-1604213897064_1604213961066_0.009045087380765704","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-6f4bb5f-1604256854854":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-6f4bb5f-1604256854854","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-6f4bb5f-1604256854854","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6bfeaaba529bea52d0173a9edf92e49827f91003","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-6f4bb5f-1604256854854.tgz","fileCount":7,"integrity":"sha512-RD2VzQ6sdhqy6DHHh0taFXCj2+tiKpyLOfqy5awAEOfTtJraywRaFjDfE0bswkrEulpM/TJTBdz0U1CZn7YCng==","signatures":[{"sig":"MEYCIQC7A+19JqbTY+FeBVOKEA2igqzGMcgg1tD3t/zvrjjtaAIhANrhdlaamSr6ZV5wvezcSaquKUo4O7oXyqj2Wjt94ERq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnwSOCRA9TVsSAnZWagAAlvAP/12okzmOA2DfpIgAwz3n\nNo1fykC6L9ujPZRTN/OpWaJh0z10iGx65XAjzL/c2nA9EJmMIzDoaCINSM8o\nSgzMRCcaL8scB8REDR1U8X063uqIg1fmkovU7HzNPimYblajCJb3NLH/rEBu\nB7ORcc/Wh3mGGs2tI3ftj2McnY6YLDsA2iLwopGIVP8WciXi/xSd2Df9TmDJ\nk6/nyd/9Ldgaq4tXPZcVTq/XNLIypGPwHO6l2LmfTp+e7+wbVU+pt+b+bhHc\nuSLQB4WX+4CaQtsxX8q5bzI81NDiShlnYWQIQwfGPmT1clNJVdDb4axwnpwR\n34gNXWVnbVUEQdI+2yNiLxouO219u1usz9GTgS7EJx3hoDUNXB3AL/oriE6Q\n0HEh/zMt7tzhQiaeTsJDlheS2MV+/wO2MPsC6Tjj/cW9R4VV1l6Q/Od65Du9\nn8nfPH0LRWgcr6Suong0YPh/12yyt+B4OyOR3WT8sjse+0eVrwsh5S3XKg+b\n2HybdBC/dOUp6XkymujNf9wjsT8/gVmNRO2aR0GcYXAvuoSSgkyoKl9yriDr\n9sAnEVwz17RCVvqCmDXvQaNdO4po///Og3RVrkvUviv5ML/GbWD3MaVJtHKL\nB4+6tfNfoZgJuyKM3xQpriqP2Qxoxo/FNn8OvpK/HZQK3jhS04Q5QMyaVi5h\nKEZa\r\n=c4MK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.0","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-6f4bb5f-1604256854854_1604256909285_0.16754599263866465","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d69cdc0-1604309872417":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d69cdc0-1604309872417","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d69cdc0-1604309872417","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a6df028e8ce8e6f36bee9b065d0697c27ecc66e8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d69cdc0-1604309872417.tgz","fileCount":7,"integrity":"sha512-aQyHKesHXo0ANKzkebyvUTNJjVqHaSk6rKNk/ZQfVc5G+ZOltX6Usq14CNOkY9MyqE+PLZMZdA/pMhU05oODzg==","signatures":[{"sig":"MEYCIQDqSa3R7zgj1/m8IHYVYiSaNV8m+EdG00fhnrlnZvYPKwIhAMnXgdZjInQ2P8WE8EsZVoAwfZrjIpXcX6YoGYTdQsqP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9OxCRA9TVsSAnZWagAAXrUP/0NHydtcwB7W9+6tHJb/\n57OnMWAh8bly6MXeTu1Bza4evpUDkMorT2AraxDO8vzcXSwR3GRRHUDcc2jy\nNm/2ilGGBjGc1mxhXHsN2vcNxW8/FS493eoQNuDZy0hrGr1V6kR26rm4eFUe\nIkWHOiGNRXnbPldD5YXmkIIFoia5m84sA7o8R6qpWwd2uch5yUbFsCctCmSk\n4wNwQ+I2cuLp+DZOH9LnRYSUPbpboEsNqHuzVCtNfygtWHXv6J/GVACXV7ml\n1OsxROHUVqjPoqSp4gS8deWplcANdrEW5tRt3uaSJfdRA+wjoEfSp8wisZrU\nPdMKtNUEjETw27Jb1wVKIYeyV3PARFeNOehkg6dub9kxqfdKE5HH1I1Pk4nC\nZA9FqAqOmZ/E3snqiZHoxqHd0wYAMHMLK9BC2BIEbAbpudK81YII40sQn2p1\nTHDHxhoKFSogQYycC/DhRIkjGOOCT/tT8q94+O0ZqCwXOunqs6VZ3MjyNjjW\nj5ilPkmE1YBwmcRzi+l6V2ufiNdxH846P/4SStxbA42KNaJhJDCAo59JqyuJ\ntwAmHBiqYoygFdLmfKo984HoEwpc839lhrBiXV2ITuU26Z9Kqlyqr09AcuOh\n1LxsSGhNiKKZVxI62k50MiJ+cvG3hjcVcehJ5wpUeVkLyR0qh2sG1hehn48J\nEp0z\r\n=y+NA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d69cdc0-1604309872417_1604309936689_0.09424281858928896","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d69cdc0-1604309878676":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d69cdc0-1604309878676","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d69cdc0-1604309878676","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"51f6112ed3a6ef40d208e0e18cdbd56ae864b0d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d69cdc0-1604309878676.tgz","fileCount":7,"integrity":"sha512-8VWqtRmtRROwlm/mrhycQRPlNoSyldrnyiYGL5q1czMSZOsxZ5JMb8Q5QPre7slt+jU6OOralU595t5bP8lDFA==","signatures":[{"sig":"MEYCIQCUpW9YGS1sxA2CV0gsvsvHiMnFnnY47BVgMVegm6EcmgIhALSpnERSo35+s7aIoymKzFA5Db4E1m/s41+/dpbpXibS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9PACRA9TVsSAnZWagAA3pkP/1XIVnaXhMmANDJU9bri\n55PK68lSvaRXIY/8bSNJS8zmLyOjQ1hCPIrXNmaCYWbXBaSusXHTXYv4i2cn\nQWNr3q3iK55xN0S8KPS+/8IX0mU+ZRw65TazQhnOglVISHkwKQ6zfBGm5mYd\nqzJ7ewiI4BdZolOOBjn12/VpHU6TjsfTZarGK/9MdBsDM80um9LGmunm/Fn3\nHSaGkN8RML3IODTySBUcaTUA5HNRq9MqhU3/rEE5Y2E4FnrEad/9waChohAI\ntuLMRf+oD7Y/QMS09VzOlYBt/YYVVki+HQj2uD0KdqiFx8rIf2vPGiMZaLm+\nXvg3Y1wmyw8XQ9+9EaGWTsy6DYQjqeovlCh8TKZdLP5TjOOvhVBqBdmugedk\nok6syZwgppXOFtsEHp7GG4WW6CCQ2Y3xzqkrCMneJu90kqM1l76UwsDCnjbm\nsBN0aCoMEsSKxDwsJK43DRh4rV12A5JoPnuE4zw/9KqvXUueVHmanpmq7xSM\njwinsP2rEWgkA2luvjxrB8CqT2+cS7EoXjIXt5vmE+bozlscUN4ZJb++i+p+\n+vfGMnDAkex7W3AR9Iz0zlDcxP4HZD5xIui73Q6sICXdF4CYQpNf7JSilq0d\nJyp3VaZKgXIAE4FWMiOM4zTaU6LMboJTSyfArb0Vqsf6C5TinX/P9hzgGD8x\na0uQ\r\n=+Uv7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d69cdc0-1604309878676_1604309951907_0.7906630902552638","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b7a693b-1604310605242":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b7a693b-1604310605242","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b7a693b-1604310605242","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1e4d0746032f9dd2cf4879a8541f13e0f4dd7675","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b7a693b-1604310605242.tgz","fileCount":7,"integrity":"sha512-aRv0zhrNafXa7kQ43sx1wD5jCNBTHfq6c63up+RL9ctjjvrg4sbQhSKoansJiDxHzjuMrw72xjOvTKBPmUVgEg==","signatures":[{"sig":"MEUCIQCMbZiIZgEjK+5eQ2U910cELa10Lxtzk6c44GsTexAc3AIgQ+MJ+V5Wb7giUTca7O6ggfZw0D1f4jSvMnDyuog2ryI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9Z+CRA9TVsSAnZWagAAvjkP/39zk0yU8YeH965qmlDL\nE3x0Y/hjJS8LS6ooznN6oQfC3iXFfr0QhRCJOIxgouYWbK8oE9R12q5jmPZj\nXlpfaADjCILWW+dIJPMUzVHjGgKurFF15Zkdn44YML9GFq4tWTxSjSllVt2E\nn5pK4O3oHW6BURHUp1GlL3HJDXTYRoqB58DF8sU6/OJRuVVxcjB0th04/JMT\nJ3DH2haE59v91QdNXzUq7MK5pRqS78sMl/XO8MBNvfFPbakYgsYwre6p6jvi\nlLiGUu4E/QUpCC2xFoaF6zfnXxG/LVoHfT+G/HIv5fWxmAotfsl74Ptz5hIW\n1Pm77YEQqFy4LfpRmEmRDJaBRPb4YI8wHK6SWwVOdWaqdFwbTXG5aG+KgV5g\nFRWEd5R7Ac6k77pnCXIVjbQBgr+zzEPvVt/INeP7mIm7DASohiOQwmS0QmSp\nlDoFaoFlsWn1sM9LzGaRRBmfOmc9EaLY5ng18i7sBKARZ67+/IDxEl5bqftO\n0l3N/IIa+7wM2zbS+U6CHb4Jmzo534KDOAx9rDWL6TFeQ+TXa81IVA+yDwqV\nrgOZf7jVCd/hCCElTqup7vGRJl/qjAgDR6j9hBSRYmO5Uzv8jpHf1DZCwxpx\nRURreGBvQOKnkkOJpKwrtRZl/vdtWcVkZCbX1+JR3eEZAkttr7j67NglYHaT\nawdW\r\n=TdxD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b7a693b-1604310605242_1604310653693_0.595208833780865","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-b7a693b-1604310606351":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-b7a693b-1604310606351","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-b7a693b-1604310606351","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"412bdeccf63b4422dd64c8170c85904997d485e9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-b7a693b-1604310606351.tgz","fileCount":7,"integrity":"sha512-lqHgynl0o1m91kNEqHtVJYd30J9hVTZfNW0+9TpsYx+nP/pHMtklQ0b6xB0ToAqFzny3+JH9toWLFbjAAtkRyA==","signatures":[{"sig":"MEYCIQCtlUs24Mf26tzws/XUlsYxApgjJivMMy2mz97UJZGmuwIhAOSqNz4ND6QWXWi8tXKeQ6+1Ugxg4iSqic2p/CsPHfgN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9aKCRA9TVsSAnZWagAApGQQAIkNB8VF15djOFl4XMdA\nROWyE4cnlIblg61uZRBarmhp19CMZxe/v4olwO8mo+uJNEjyi42Gvnjbqmrv\nK4rAgCyO8829DQja+zfJMmrUeD0pFUGQZdKDqMMAJaqNOjHoWyqOJI94qe/2\nwdXzllsVsp1Zvcj/+Kbeh+0nedtmIPsEIZuliffKl2T3hK6UUF4RuPxA8ual\np28F9Qpao67dLOEe1k84z/YAwtLpj0Zna7zSsnGOy8hvXPu8rkiKla9zKBMi\nZqJ0MEJj/Lk9btNpwV3a60J7DrYrXctu+Yk1f1NjixGbTLLmYUSuO3gb6os2\njYBnQmAjp9H0LQ5JWn0AABK13wchj9gAl2BTSEebOJU4FTTDVnNmj3gpSynC\nJaIkJBNqdp5m7mQYR89axHLGeZc45R236sYUMHmbU01RMAUgQXPmRW02O4gz\nWNM4JQ/ZaoMwX7Ad3EGFYXqAC8XGV0SHn1u2D1ETwJ+239EbudbBwVyHkHuH\nMZD6lEZz9oxuEmzbmXojilZov2xwL71YZZEia9EtbC1WablwRLxQ3zbhZGDI\nGC4ijo3LV5OIFagTjvguonwG4z45WuAobKHAYupHr9IG2fwOo0xtZqv3BNiL\n7Lc+qTMoDekXAIKzO7BlJiqpshCN/WbtXC3usXDhdLc3HZAG8NPiPhtw1d4P\n8z5e\r\n=Gppf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-b7a693b-1604310606351_1604310665980_0.7088417363604347","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-02f98dd-1604310761792":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-02f98dd-1604310761792","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-02f98dd-1604310761792","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e2c8eaa8f36c9283d92477f08984175482488c26","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-02f98dd-1604310761792.tgz","fileCount":7,"integrity":"sha512-/t9tWowyrPJh00DSvE6R74pAlb4KK8bZIRfw+N9k8M6G2TVdbKl6IUzWDuK6C9uFx9ntUQDMM8dxVKizqCcYbw==","signatures":[{"sig":"MEYCIQDKAUVzg93NFGyxYT2j4r4xVu0oQfjwBtCXMlrqnvgYpgIhAKE46GwoRwWJY5nnWvbISmM9RsRrOKl7J1tVg71+fylx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9coCRA9TVsSAnZWagAAJwgP/jgWLo2gVoe2dozbxzV0\n8CnMNi/2PQlKmGKpB6zBgqHc1Gsy6ehfwgRDQXwaofIupmrRfm0HZdwV5ibZ\ng4XMsInHEAW0CiKy9JEESYQZnwKDgzyMbKykLJaK5D0J8IJm4WhUhEC6e+Sr\ncckcR1yNMGljCkACi/x/rLk9D6qQtsLta9WLN7xlW2NJQsScCqHF7ItIWjgX\nbYVI3v57sLmCefF+hWY/TiozBv2OP7BtfM44kQTHiZAi47hv5r3K8KwaCbgB\nyNcANyJq1SJiAt9FofsuZPMj1BJVFhFo5vpFTISxgwLn70wruDkfSq2VivSe\nvgtL80aT6TAM87QEo30z0Tx/g07B8dRr9N5edJo6xeUMrv2bGaalwOq5IIRL\n0eDtqxXhbNzhMDUZQuu9wrjwJpQBMtjQwaiwvVWPpSzcM7MYEUSe7Mf5ns/v\n/KtDoziPFWVSxzFvlEbh7rCLqUqVyN+ekKymETglEcwHktnU7pNRqJEQPmr5\nLCU8bUUqEWuKIS6jmzUZRPcJxWpgHJ3qUjnSuXS3kjZd/tqt4faU3AAdCvct\n7WrfVXFQ1CwJ/Lu9bXqIYyeWRPcRtz+YHtbuwi8JbIJpgm4KJwWXt8qK3Ihv\n56QAI6/kz6wNK9boxuElndYTXKucPLYcc8upACcomguAcgYe3nwX/TJWeb9g\nKz2J\r\n=2Tes\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-02f98dd-1604310761792_1604310824383_0.003822199377478963","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-02f98dd-1604310763912":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-02f98dd-1604310763912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-02f98dd-1604310763912","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3a6191f756142979d179ddf4812c1f892b89520f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-02f98dd-1604310763912.tgz","fileCount":7,"integrity":"sha512-1vUD7dU5IsihFQgasZbQ6RYNS8N0q57DrxF6ZCe1vDeDMke6HXYCdbLRz2+piZNICrg2zeesZQIO4HjToA+6qQ==","signatures":[{"sig":"MEQCIA+L0QOuJAXGLcFbz+aWnY7sd+qZcR/sFBZE/mIfX3LOAiAyxMo1vXtpW/+Li5Av3CJkP81i6ITG0FwwTaXi5A5KoA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9c4CRA9TVsSAnZWagAAvGYP/3At+Z59rI6rfIgqOCSp\nqHrp/2f01+fiBiqwUFuqIOQ2tdRHOllsWm9HUewzU6a6mbYWJ037vksYEdfW\nQbGF7RzenYk4cMwlErOJGHcH48KH1msiSjACtXfw8v7YoR7noa2D0Bx14pQP\nbckXFvKyGI30rxysO8N8w6Gxd3cdYwkKJFJ+jMarjOtTn8p+dauTT5TyzS5S\nmRSGqRQPvLcw3Xnp8Smx8tg9oVZRzVBW24us06r9rLiko1Wi/oGyZB1NVjin\nx1JM5eKkr0yC72sQTj/D/YFAMxO1auJ4G95U8X354EQPp8/Zfi7nLTd8CVme\nCy3qP9oOf7YeeE7TN6AZsWPIswtXrWXq3eb63HdPr//Z1IXmW3FRJf8VaJrz\njpu8EkjDJPywNv/LghI23noAMlbaZ+cZkpv0aBwemDhx7zvx5OvPpEL9+gn2\nhy0c7/o8Dn517mDDMkohaLoPdT05ImeNEmn+mA7Siwtvb/hdDA5Qe7/R9Y9p\nhIksE1n88PlKg2viHk24eY92fFxL8KUfMkN+pee5FWFOGFQfFFR93WRP8yxY\nsbJh8XZqFzro6VyvyKU8KZTi6GcOrLoYoCnifSqTI52dJlpRrfajZHyNOk6a\n5oYdvnqekRSS7X415jhmnBRq2JY9kDvCCGKZq/Qb7YeCWrtJhhGfYF5NueHC\nLg09\r\n=+y7+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-02f98dd-1604310763912_1604310839509_0.9087474090526284","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-689e2f0-1604310799590":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-689e2f0-1604310799590","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-689e2f0-1604310799590","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0dd00f7e197fde8f6861aef24a8bd68fb684cd1a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-689e2f0-1604310799590.tgz","fileCount":7,"integrity":"sha512-RsilVge8+gAJZk0IoIVLH2D+916cq5wF/4eKMWg+SlKdfSVH2+0GgFp8PJRW0HLDLoQnlnY2R5qHswk8D/7OGw==","signatures":[{"sig":"MEUCIQCLPHMGXsppsqQDWqMTFF8dmz4NLcghvqqvEwOEsLbjXwIgZ3URjFk0kyMPckKzYOGku1wICGM+Ac5wn4WGmf6oZFU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9dECRA9TVsSAnZWagAAJVYQAIn7GCta5HLm2ygU6Kka\njPrzh90xBjvqS72eELZ+Sifo9U4E5CU9BxVIXUJWVTAfUep1tIl/yrl8xmMf\nUj5ieSsKIaKUBvvA9LyNhFCaUwciG9ygCk0zyWoq7wTs0Ehf2vP6hyINkEv4\nf72URk0C3+XR5XVldpYwsiVMZ5XhiledBmEXEYQpripJ8COEjyK9iH2WamXt\nNsIwDn0YAslQ+1qMo8dHAzBRQkp7J46kdi1JpZTC2ffRs+8bEGELSw9Piae+\nd6D39rrm+UiQrEYO6IL6DW1N+HpPS9ylJfbygsBKxCgfRtkByZ5gAznDQLrZ\nl/O+5QMNf9V2qXLEu62r/ymjDL4wra46MQOKB/SauMNUEXyjqvuAXHA9que2\nWafuMfwkq+I77PIzLV4zd56fYMth6ahFQEJrS9Q5mTSUS+u0Hbu2U+ewFRoQ\nEc97JDQJyYgrHXhbXWU3nSvSaZ3yXs8ilPLycOzFGX9ms656exBzjozlNbO6\n8HrRI0DuLXMacFuUwhyiFZSmTeOz0OTN2w3YZTY3UK0LHFhHGqYdK4TVC7RG\nbEcjAjlhohytR1RiI09yKueE1QTbNPO5QhLoYObbZFPMzWsjOz+KINssbDEq\nPwuv59EmENfQPNLsU3tqLMFUccgEIwglKDSPJi3GNh2jnPHvl35pSRsJqPbh\n3BUH\r\n=2VJY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-689e2f0-1604310799590_1604310851896_0.08237531729473524","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-42c64ce-1604313682126":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-42c64ce-1604313682126","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-42c64ce-1604313682126","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5e2974496feadce1df2f4e8588d98a806c396eb1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-42c64ce-1604313682126.tgz","fileCount":7,"integrity":"sha512-wdpnfLP3OdMP5fMGk9vyYmo0tDaCE34s5PgNGukFH4fvBBL2rfy+t77Rh/uVCfsbGe31lQsz3sW8bh4Nwghruw==","signatures":[{"sig":"MEYCIQCZuGEF/MDrOCw1pcAhOspjghHcwitUYK35at1nH6b5vwIhAIHOkmeEz0Q48xuNJygXQyS5OB6W1cIWufi71cZiOVlT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+J/CRA9TVsSAnZWagAAlycQAIvQ8qisKUWp5qcm2cA2\nSzEzGNzdaRvp+0ks+vSBAQLlFtSRcfC900b/bgL44mcOV6KhZ6L5dZBcj9de\nTXFDeOVbJyeXkXQVDh8CzEdI7ARB/7ZSY2PrXehWMLvmYW4sZbEjEGkuA6gy\nZOi16useNjwPwnGBvLXKCyBcKeA7HgbtGMjj9UmKBEMB6zQcrcb8jVrDN+HB\nA0rz1V34saAAm8+SJ8R8DHGdqCkwhP85tCojT+C1Ngl2wVV/ygEGhtl9vtK/\n45DUeRebbqsUDI8OoTxXpSsMEPEwpoNO2oOdJVTvVnU+IZomu2vKZTVycSrc\n3kb1I0CQkmagRJbZYv43KnWDtCoQch99e/u0LAl4CkJqGJMnuwmhlGO2TsfO\nR/AOWBVJ+j/xT/SDBSaE+ABFFROslM47jOZRIpCWdswMAh3Jcj21F+P6rdX3\ntlfTD/ppcrrmKzVmaquxobZMWFZKD8tdPZ/MCFVyF2nuQXp3iJFXJeL0SdKg\n1lIi1fjk+2weDEny1LFcT7y3nyTylvzZVfAEVLVvP5RNTxss9aNdkXImtX7C\nw1QJc21X+QjQB4Mk2v4li+3K+SWER5ScOBY91pKeQtYwXhebUZYkzevqQjRk\nuycrcgwgnU96Tr1Xhk4Nda2xJVWskcEqcSiVwZuTuGHYbHBs+vk+eHyIj38j\nPDtW\r\n=rxE+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-42c64ce-1604313682126_1604313726832_0.4611048291505737","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-981f8b3-1604313888096":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-981f8b3-1604313888096","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-981f8b3-1604313888096","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e30c13d26d2d9028bd7bdbd82c38e54d7d3b3c40","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-981f8b3-1604313888096.tgz","fileCount":7,"integrity":"sha512-iMNh6SF8z4IgndkIda5GwhRkQX6pXr46CmopAH/Bq+9mKafy2xRCDoi9+hgLob7tmeYxF8zQ3Hu5uJBq9z8vbQ==","signatures":[{"sig":"MEQCIERlqVH8ArwclxQMfB9itWvKBL4BNmISOxlcRY7C6o2OAiAHcyXidBo3xln7TtDzu/Zi9tAStp1f2D4g72Z0p59vtQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+NSCRA9TVsSAnZWagAA2h4P/0GXcItUf99o05V3XO+O\nuvbEIhCM1uyAum5jUs3c2BAFP/s4xsMkQQLEC6FZnQJUCTIbmOQjhPdY+/NK\nbmxUOiWRHfd5+pnh24DVGI+a22ONnhZ79x1fq/IgeoAImRegK15OKZwhaQi+\nplX+/qhewZz+NgvzsRni4oJdmxpryfZtY6QnoDi7Yu1EbDQdclACve0NNSML\n+FSLQId9DlyRaaDfXwscaMV02FbYU+xVMXllCOk+Mw6dq3QDjtMtAKnMjSPG\ntlsedh6iVfIfmT04yHCqWOtadqS1utc5G4ILhVA/3Tax1azpz6s4YnRfc6eI\naxSj61Wb+h/H8wCrM/ssfJ7ud++Ys2wcX3soR5nXB/Uw8K77QDu1w0YmHtwf\n7j6RQ8gu4tTSHGSpgnTT7Zi9s0hWQw1a1xeEfkpLMmlbuDzFYO/z3iVbc3xc\nAAzETlyCN/b+bm29vj2PiPnIvrnHntmSDHF0Bi/zLCO6UJyUPACY5AFiU7Dm\nZEFcM2qY+WfN1a+ytYBwbWZhbP07ineqr/DIw/X/e46h19jQSyc5ETJZiy5H\nkECvUNX0gtvqVLEs3x5+kWweChAzv2kNpueM04+mT4r0GH1L3pV2InOKMwrc\n8DCzqUgrBqJZjkIHnnm4uMGRhPK1WNuFDZE2yaLCZvXyq19jxtlxHQWA4HpX\n+LZU\r\n=PMTG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-981f8b3-1604313888096_1604313938169_0.5533005426622504","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c238ba0-1604314075192":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c238ba0-1604314075192","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c238ba0-1604314075192","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c2324b4618f4e4fdec1e753c38fcee9725680ca9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c238ba0-1604314075192.tgz","fileCount":7,"integrity":"sha512-ooMRf7w1EV9pm4j9aDDtU6CgSvwVI89eFmS7y66qzTIsVPnN6qIQfcVoTIS0bjT9tvX2y0l8D9eNhvPB8J7b1w==","signatures":[{"sig":"MEYCIQCGb8//m+5BbMTt4J5KObdQy7ZSeWD11BwYau/msOhn2AIhAN1tTnAhPS740cEnhfwS7cbJOQB85WoicoOC4Kyuvd7k","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+QPCRA9TVsSAnZWagAA1U8P/ArfXGPmEwHT2BadNPf2\nq1K43cUAkaeOKuDjzChQoS0CSYT4pM2IEFTxq6sQSJHqZShpSGXA0yJyDN3Y\nK1spALoxu8vJ9cAZmT5JbOcXcRCNkQptSO1S4sOUIBcx9XUQjcU92bmQ8fM7\nu07B+S23U2npU6UbEOP0pnZUtinDD2YAfX9Zjqh+K2uGLYs5nl0Olqa1gbS0\n0Q8g+AbUq//h0tu/YoX4EAkaLPb6kTMuUqmgEAm8qNvYcIXyRCInlrrP8hAU\n1lognA873CWOWuwxtx5gttwZiJBzQExkKpLbVpzkqWzrG9j+YxZDtjzbmdvF\nSfKbJBnfgTqNUxXiLWmbMNR1rzn+Z/vOuAf38EZar+hiCVagg3g9YvHAIwYG\npzEkuJWkQNKHFe4MuP/j3NuBgSyDM1Q4dEkho/s92WHfngxVNGcnaEzKqolf\nsFTOlO+WZTsIif6Wd535fPl7JZzURmQqrZCQ4HWCcGwaFd+3ue0c1hB7NWid\nZYp+kUv/EKcMk3J5j4xzgFtAZf+/AwuPJTR2XXYTFmMFNqyfrA0sKFUANUeS\nRcM7DbpTTYIHIIgiQj6VU+YIQAaoBBTGjwg/IQHaQ35MuGlYut9U+n5EsizF\nshE9/oH2v0ruHdmtpUpfHfkmec/hzmWOILapoAB93L3AFeTRlXyqR5DbfTnK\n0ff+\r\n=sdJZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.11.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c238ba0-1604314075192_1604314126955_0.6586619666074054","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-7a18749-1604317639806":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-7a18749-1604317639806","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-7a18749-1604317639806","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c42c1347131261b0ece6d905ef4b518786f7f183","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-7a18749-1604317639806.tgz","fileCount":7,"integrity":"sha512-mCgJ7Km3eGTUJ8lWzqoqGITi5FMBtxF2YfEe3581u2epW/mcCql4/V5nm8WDjYv42hHHabBfvMDRvQRcE3LVQQ==","signatures":[{"sig":"MEYCIQDLW270GF7rYw3ZHaAzLZ4cDSRaYeiTTrkyTgrL7xGSnwIhAMbgsfzKuf1MaGESLXBcKjRmgjYXETaWMdf6KWXxBoBP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn/H6CRA9TVsSAnZWagAA6fYP/Rx/NnttA4rZudrnhw+T\n6WEaWx/6gr5PJICFaGLfh0eGjA5X5xez/6HsdTF1FKMI2ANdsr/kuAVFcADF\nX7+bFjRXAO8GryRUdefOl2ISUXz6aj1JV+cSLS8RUeMD9HA9hVaXe3+tLrrX\nohABXr7YNStbiL+Se9+UVBAl69yrpCEpPVWY/BBQYLH9x0FATR5mXTp6Y6rU\nVCcdKXXLFlPR4QFtAezmKieSD7yITgw1GrtvXcaRPNObY2CXJ7fx0FKO6VaV\ncq7L5+ouxURETwik36OtkVdhlYV43HBUgcGfAdRWldZNY9zWEePt3XalNlOQ\n/eua1KbGDuptiZ8isE1wlyAyxsue/cuXQbwsX5YBsQ+66D1HyYjOf09LG3hJ\ngOvlVp1zqTa6M8g6N4Vw3c4zoRxL+hRYvtDfaNMR15u2ANL1ZI7khdqVkiPH\nck3cmjmJVNmW7DQPn94uhvv16m+f48y2J3oiVEiS8QncUP6IjfQAZwt4G1fl\nrVJ7RcWVdXq7xl4BAA120DpbA0FRR08RlKfFr4HH5B8mHzLheGzE09t1qNYt\nutnCQY5eN4VVFr+e8niEzazXbP/wTqSwsqyHhPxgbeVIUJOTctfx0MAd+Jqu\n6Lqe4t/kSoepc0WysM2ACRzKdSCt3crN4KPtRyKVjj7aeecqpaoZi/xUouQo\nI6T2\r\n=Ir9S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-7a18749-1604317639806_1604317690517_0.26498449626073795","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-858fa64-1604321035138":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-858fa64-1604321035138","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-858fa64-1604321035138","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b16d7f6e585dc5af188872969b23a0bfc5355f73","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-858fa64-1604321035138.tgz","fileCount":7,"integrity":"sha512-sBuxuTBVGDBSv0YXdooucSJRSML5PckE+sXQcdhBN0t2l/GaDrlACO7dVZkJLpWNFg9SlgtO1hqajlomVjSzrQ==","signatures":[{"sig":"MEQCIFwyjaqetMhJE8YbmHJnceMn7m7sIQGlQMvEcf0J5v+qAiAZ9shUM+2BzNJe9KDMVTm+0iHouo35aJeytaNJ804RMg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn/9CCRA9TVsSAnZWagAAxGUP/jgnBgN1ttWBEwjSLhEo\nR3QZnuRzhkWZ/J8D7wOKkRkidiZMTSQj55/0/euEVqhZgNRFcgZUYJ1IqWLa\nuthiACmVr79AMBabAK35fNeFl+7uodZbdI8nb1e4S/HACgSnegoMsGxHSPrG\nZyuEC7g/bB3ujpw3bK1gYhxLV8VIZs66yhp/UkoDAlbcfQqkN2oIzmtleP7D\npVSEVj2Q/43wMLojRA4gzyr7TZ9fbvo4YvRWWtXrfwf0x0+yJPmRx03iwLFy\nq2sZ9iPm8cIr2uVryZZKeyjwbQCdYLPTkMIFK+pzeB5hDBKHCecpS7SGt6Jz\nijGXE+fjsoRd6sWMzcGpaxDBGZB/rTPFbfZDbabMbHzcTbgpywXvNbbI6MH2\n+bMpYa5bN3ePEPAX7hbrAFgn0GNNQM2bXaTNqzxWjo8YSq3Jmv2IlCsdhHCA\nfLkvXJJI6IIt8wynVfMeB7IDPdSFsyPpgGb+2EThAgK1+clu0Qn+PkGYXgJW\nVS9hSkM2cg6AOvGAzC/amGoJz1hTMkRcqqi5SZ+oH05pNBpJaHbh3UvsluO2\nBowdUWfVQE+OrJFrPo7bJFTOiYu2ucdmifPNqP1iRqO2KvLcQfpOc8VPLc35\nX2Ixcve/aw2ujbBU8oQDTwfyBLwy5/NZ9kQPHfEUZ1P37TpkQdjCHEQUATTw\nyefQ\r\n=ahGX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-858fa64-1604321035138_1604321090313_0.35065172010646206","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5250c51-1604322560399":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5250c51-1604322560399","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5250c51-1604322560399","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2cedbe0057eda5df5938241d282402d90152d396","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5250c51-1604322560399.tgz","fileCount":7,"integrity":"sha512-VuqdqMVVAqByAKK92VYqPhxHEI1Cqlc3/miO2Yh0/fqXtZmr2Zllw0l9nE4CmPyHrSs01bss1ChBcHkZ9gT0dw==","signatures":[{"sig":"MEQCIHKZolXCGhuINkg0AYuRRoeyzhZWzNnyiOi6PPu2+7E9AiBB8zmUbeV+kTjtkwCdzmHNgu6ZgX7bFr6Qw6dXB10iHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoAUyCRA9TVsSAnZWagAAxkMP/2h62aRzLufGxzAXT1Sw\n4XaM/Z6SrKmmFpXF7a1gOXLUEscl12zhSkDS02kodXhUHmPzlwZi+pUSYcT5\nbo6xgZO+FEVpY48SPbMa5YNBD1QkkxPfEP2MVMtJiydpyuXHaG4meELiy69M\nJ29c8bIlfwpI3K2D6xDwTVIK9ShiHQYdGxL9csAmlOcnMPQO3aGWI9/yBfWA\njw2UWELODEL6h81SOqiIgn5SERkb7DP7aZMsTWbCp/qsj6Bc6fb8c3WySrqn\nF50MAiEfYXH1DcF8CcjlzZmSQ6cINCU6F6ye6fNmSNJrmfiQTW+14b1amRD7\nevib/vgqIVKOMsp4D4VyiC8UothTa/z9sYT8LqA1Q+HwuxG88gkZsYkI+sKI\nbi9LcR5ImfxOWoLNalW9n+CHn7jVh6I4apLKn355Ysw04bYXFe+wX5dZwhTO\n7/MV39Z721prDcOyG4tMPfCx7Ykt6jonWgUmcf9LN0J0DQEpFIwbbnQauVDp\n5iE0U0KFrW+9wSzCs+/J0RSXfXQBnmWk+bok9sYu1dzOol7c74i9lzLWBoNR\nOnhCB/1mqFnkn1GGTsxiS7Z42tVX8exkZNM81nEXduK+u8kJSbvB75n3m7Mx\nU+c7IuQ98W0qV3RWbQdfq/JCZoMNqp+Fkl28VvS6PgRGhqXnqxlyDv3x12Um\nAciS\r\n=vZjw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.2","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5250c51-1604322560399_1604322610142_0.5864238743084615","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-5250c51-1604322562496":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-5250c51-1604322562496","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-5250c51-1604322562496","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f108408d07e9f008bf1f25080c8a3b5ad65cba0d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-5250c51-1604322562496.tgz","fileCount":7,"integrity":"sha512-CdYiEPXaSJSvxSkKHcFs4HfS66RRcCA92Hn8R45+oPNZylGurkXG87u8VEDIEwehgT5HmGhl78Uk68TfLcgrog==","signatures":[{"sig":"MEUCIQDeMCng+q6tH03VyMBgthN9VPnwlYkXr2pJQnI2Me49gQIgZbpXJ+zqP9gr4BJrioGhQeISRk+QWToRNhIGe2Qt0wU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoAVHCRA9TVsSAnZWagAAWKEQAIrQKds6RGx9TSl4pfRG\nHruC1ZPwuBvihF+j+AZR8qwzEWLgOsaYn9SL1dm9mfeyzKpf79QAZVHIm9j9\nWuyw+fcBFQJ5YcsWA6dD1ij0k0rrxEdUEyRoQL/zsyC2O0VnfNl7YpE3FUJV\nJXsIq9uQgG6GvZ84Hl43gPKHNyGpaXG7rqASGPkyCa6KJW6BSdSq/FeG8vOl\nkAoq4ea+iF2DhcpSs8ddRP7cjMVxxhxlUsVJfryxTJRQz9rbrl2TNrWNEt+W\nabcCglYQqWC1RUSXoiI9cieMUR0pHv15V+n0BUPtAyaPr+14agPVKdbU8gUx\nS6uV1hfbz5ITzN6lpyKR6IDB7WzLwthmuz3jHlnjRxHsKyu+Izo+QEnCSTI1\nOcPZaxKLD72rMsnZsvtCwX6bivjKTeas/f3BEtejsYs3wyeKGKkPmPsuF7Bh\nJGWBMHiDBv7gy09VcxHr+/GbwNd7dBU98qTTX0awPrmly9JZUhrrYBlgcgEu\nTj5A0OXVWbVizAY4NNxE5kQG7UuiA1GI5t81t5oJAdMX1rtSeSuAZ+P0wtus\nvygeXDLk6QReN7s8kMfLpBCqJKXILr3MI/Kp+8CWqBIuRySDkBo9m8r5k3Re\nmq9e0D8azi4RWRJi+O34u13tSfblAm++1TMGTkhx7mngE29oT0zEJoSqILwH\nyD0i\r\n=3vH6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.2","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-5250c51-1604322562496_1604322630708_0.6279163066855988","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a1c04d2-1604480736704":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a1c04d2-1604480736704","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a1c04d2-1604480736704","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4028c4d59508d24832ea4730dbcd53bd2d6e974a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a1c04d2-1604480736704.tgz","fileCount":7,"integrity":"sha512-tJZ0QvfrRXkqb8j7oXXMByGILdVUFqmo1vnt2irpEWvT6i6/vKu//a+FdCGdObw4Gv8LhQF24B6a9i8qCL9giw==","signatures":[{"sig":"MEQCIASDwkzWEw2F8yc0Nl7pclb7+PWPio66WUCkEmHpXdIIAiBRl1b1HPzo/uiujplAVkINxcFV4Vh/c4cQMxXJ1UO+rA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfom8SCRA9TVsSAnZWagAAUOQP/2ON3A2/w75O9OrHsZCw\nkqQVtkokRp6wB9YYUNmzPv870K9n+yLEvyiNgFns8rHIANM93FFQ1aK8l/6s\nnxkmTijv+9CuRCVpG/gAWTEGKq6M4mFM/q1KvWUfZdsDbEpJEM1mfBBuE0+2\nTC7NCBagazZ5DxtRlWaQBPNtfqY1fbKZA5VsueIzQXEwOVMnNvnEDcOuE6rX\n/wH36pdNAAIoDzsFbmvm9zrO4GfBUI70qLrMVB0IvHpbV00zR9qGpt0vXJDp\nfwZ4Gi0TN4G5CM2YbXiI0788I7BPBVDP0IstRDlfeWJD4y+EK+LA1EC1QpXV\nTe/qfyLYIIvot6G6uEJ4Q7A64yFGT0tkWaYHFEuxgwUX+SZ+j+FVB7MbTeS5\n1cAdB53KflGp9Jn7FZbftQ4I0T5M6Ct2tF2k7LLH6lzrTVMjZvgjGXjJOkum\nYVIKxPJrE9QUZTWDApVGttRRvDIIoeA1QIsQdedsiCJZvMwNGSp2P+COlCCg\nL9b6wTWAS90OpkKu9c7vfDnB+N70obKe6otyJi9jaqGgxkWb3U02txOLml6w\nar7LhrW4JZ5GBCvECQL4wJZxd4XRhCqJnBAh/zD+yS97+2eiG5Us4pKt8T2X\n0ww6QrlKKYbQ5x9XAcrdGZs2ttNrF7uDDeeI3pGrpsv2PtflAw9/wDdmcKBr\ntgcn\r\n=OCa1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a1c04d2-1604480736704_1604480786312_0.26643255624355633","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-a1c04d2-1604480739664":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-a1c04d2-1604480739664","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-a1c04d2-1604480739664","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f79275248c3260f8e28f7c5b3c278091679a9b75","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-a1c04d2-1604480739664.tgz","fileCount":7,"integrity":"sha512-F4ti74DYiP3cqeOjYX8QoU6K+Gwgh5erOmK6Z1xidSyceM8WB5AsGWclgqeLiF4O8gymw+fqSgzbA1jQx9TF2Q==","signatures":[{"sig":"MEQCIEj4EBZGHXXcofrF9k5rLvT/3dZo+W3QMJw+6EL1+gbmAiB6FwRP5s6v+5r57OAx+ffO9SYLpxf9jrDQl4l/c5FkQA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfom8mCRA9TVsSAnZWagAANgMP/jzvG7+UW/vTl9licgZG\n9PBr8/1b7/RdSYArMbztFa/biZrbq1EAiil+d0W/5LSHOi8CH0qDXWJFdCry\n0vdqB1BsnclwO/trFzLIurbdQibcQvMVcCoRIMiPqiWWAaDL9y+QVWEH/Bs+\n/qUQ73rFlZdq6LdsWG/4dcC2C/wD/Ytf8hDy7CY+goutwqP0O21is46de4Lm\n2NgmmYzua457/MEZzFAqIuKBT29tet2fiLozXrAcruStWZfmaBfRvEGEs5bU\n2z70d1dBGG74lzluOZ2PwqnbY/6N8aks9vm/dlrUZKde6vGz+iDhBUHkf8U3\nrnQvC511ByDwgBg08AXQxniS63Lhvt2fj3Dq70/2zszE47wZbjFACZnSSAXd\nqx8+Z4FuWPYE6636DHMN1drqWUDS3KKWFKaeXjWlT4Lepjzg7cRkbBQ3x7Pu\nNNgPgyU+ep7iUdHXiX7ky7skIFlBTAmL92f5s5oxvLVrIJcXwH1xCrzuKauW\nP0TW1enZEJd9HnxDjkBXBXS8ijqZT0DRjX26ZKlHfDZV+65kRX2aVU6NYttX\nmYpE9wpPk5+zQ8Mvn8ZZvg/ypabOWBiZc7vKeRoODA5C4i4DE9E5g/VXOB0x\n0UNtRAQHuhYipgMlTnElwm2U2jZpKhKaGVddIL5YQFrdDPCunvxknHGpdVAG\nbjp3\r\n=ehSG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.12.1","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-a1c04d2-1604480739664_1604480805754_0.59518589042593","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c0823cf-1604714980569":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c0823cf-1604714980569","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c0823cf-1604714980569","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0925f36c595eaf8f321a38d4f456aab72fc34792","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c0823cf-1604714980569.tgz","fileCount":7,"integrity":"sha512-mg+TXU6xP1Kqy758XDAi0BrW+L56szAR4TrDYF5V7yGVAh9TQANsIKD2FsygWBmJvTFFjQZPaiYtTtQY555ZDg==","signatures":[{"sig":"MEYCIQCHUwb++3f6i4SKTSwu0zYuKtdJsu3A41hEMX7QqO13KgIhAP6Etek8ps5Qf4lGbnyiGA/pz6quzI4fpFQ3HhtrN/y5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpgIfCRA9TVsSAnZWagAAViMQAJl5dq0RpH2qeQvM8X5p\nTUArYAz4gkMe9a7c3QxuPoWLZ1OVdCWQq3VPyrPmbW9IQKVtbdbf4cdVVA4n\nO7azT/UFDqQRZbrnML9bt8TfEC3BIp4BybuQeqVtR82f/Gm+rUsY16rO5abj\nLKGaJLROaPv4Wtq2jbcCi6uK3gNBi4zb6OsZONxmxnk6e1yvlKwc2Pf/vG+A\ns/0co9fo7URgNciV5txkGUH9yqYsotpPXYpgJkoEoLEZ64wIsu3Y0bVQEOpV\nVHfk9T41hTb4YBcsUxBFOoLydPJzP8RsJqZY2pEiNTrgVz8VOJOtTW4nXOQm\nukEA655LbH03Gg5maZqxOhD1LKb5C9rVcU+UAqwVMQV1a4a1XiURNXIrJVtj\n4+rB5z1z7yO0fCcjLPOEH+cNNFtYOnVM/1y0242X1G+TjfQumvvUr5zi2peM\nEQ4xtBgsbtEGRDWAGYIzG4NIm+Tm8PD96IDzFsVH2RZr4q+5eTi/5Dv9VnSb\nv1oSjXxMvG6sS1YQEvcg+8+Od2IEsjv/QlIGckMRrDaZ+BkrH0hsBXibyJkv\nIg3oGVYVU8iEc1WRBuxhyBBlGSkS/vd3UUegOFpCoLzXoRAsYZpBpy0v6MdR\nxuN6KMTkLRjERcpkzMgIpqi56cuxckLJxwkhRAVxaYF5VEWLUOytcEAHB7Pt\nwbsx\r\n=8nhM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c0823cf-1604714980569_1604715039180_0.016527554456065463","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c0823cf-1604714981529":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c0823cf-1604714981529","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c0823cf-1604714981529","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"90719571ec196aa2a41edafc0a6561124276bedb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c0823cf-1604714981529.tgz","fileCount":7,"integrity":"sha512-DlK0F0g6ed1Rg+SxDThxpDwLUD1gkzZwYkNWtBPKSBzf+GK2eEu35gHeuaWX9ZaI4hXMA6wMAn4UyTIscKkPCw==","signatures":[{"sig":"MEUCIQCEgRapehzaXJCkSz8x6/i3E/tzTHvyIZDDhUD4yggSrwIgKUnT3GOVEmNvK9qxNOfs7siO9VMc/FMTfQj0fC8aLf8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpgIxCRA9TVsSAnZWagAA8wgP/0EZlkLP+yXJLeFn1oa4\nDCgMiKykSM4ERh0VPazDCRBIDATYuo0FhtDXayNL8OpkhqL84xBQS963bn+n\nQyHoN8UDxoKfp7rauzDxbUnUntqSFUpLrkJcHSzpy+9/62wnsWhcgCElPI31\n5+H33h3D+tdHG4x0nv+IbZxaVTKZr/aOIr1z84Lxl/gr6DR5Yl29x4/QhLT/\nKB8jnKrea1yD5Az7SQ1hcPlsd7zjDRFAuu6S6yVqCH03Sv8ABp0PhIUPzO9k\neRDcaHlw4bEwUKpsueXpHpi1Cfe/jloFruKq34/Y/LPg5M0gOCxFr6lSOYx0\nZL5Pxyf1eBU8WHhMPLm2SYu0NSGxfPk7Pb81uQUCuKatxKtmfIe3wi2z7OyV\niMK32SG9RIEKieF+8uebcZ2+ay6lOtkrPSuK3w5tXn5kQPQDFXruqX8or7sB\nEUIBKcIQsbWoteb1/9eO5K0YCs13MovNF2dHpPvKp3vXoigPybCa5YFqXmbQ\n2qGeskWBNcqCdJtl3DScgBSN0qB1IH2xSjrZXtxei7KzuFx9On7OUcuOnVc6\nlMMuvJBo4tFAHc9Wmon+qzMWXe+bOPhV2yh0pVuuzm4H7c7W7a0fwnnKo+GV\nhDr8ZWPeTQx1PUszx33OW8zx3Dpa6cx+xJGrsFblpnat1OkspfyAV8NXx2Mj\nvF5l\r\n=IsvN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c0823cf-1604714981529_1604715056674_0.46705168545904785","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-d6d4fe7-1604731086994":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-d6d4fe7-1604731086994","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-d6d4fe7-1604731086994","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2c853902116aafa9f71193e5ec409013dddaa9d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-d6d4fe7-1604731086994.tgz","fileCount":7,"integrity":"sha512-Xr6g5oeELmuqMn+LSnl5Mv49cJSotlwR3vobVxDNUD+l8Ad7Gcfruu0KMsc9hmDCPpEWo5CZ8icJvAas1kWpsg==","signatures":[{"sig":"MEUCIQCPgaqPWU/RJ/lk9YSxMZwG7rjyLeDFa2q/0z6MENvzkAIgCbqbkLB90LajuIwJO7dIrN2PHa0MSEJ91D622yYRCeU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpkEECRA9TVsSAnZWagAAEZ0P/jGuXarMAKyt25uyInSk\nGLzTlToUvfWC4djEKno0LIb0uVlmPRii15kQgbU6Xj/jdk0QKOTRyocsoXBS\nHIaM0cet9IyewDljFhrOfYoO7UMTMzyIMRuqm7BJM1SD/1Ybc4w7RlhUmEyP\nVwg0M3ek4cAES6bmKe75WbUYOqt2cCin2NHqDisf0b+nLSOKbgBKZLig3mjB\nL5uN4M6Nfnpnz64daH5Cvr+UhpWRrqKdVM0VkKR9BSTc3ZBdrowBbbbZd/S6\noyZiTK4d9SZXrAzKEuyzatR8xmUfHlTVFKK7CRdFPWnEEejppUivF5ue0oGj\nxAUS6Na4oPmmHwy1TgYywWo0bcfaR3m2FvDVtd0UNAj/UjAhx9w4JfOGVdzZ\na4sCXs0BXEeMRp1Hkkn9RZqGkEf1/8Zc84JSQzZaUd9Yzi4dFwtAW2vIVEFv\nckImHtv39fvuJEv5LmC/OJZuuAFQNXmdBpLsr2dsz5pqLUZRgE9gAeaV80Q2\n0690+FyYA1nEKftmrKW0m7E7dorpzPNi+R6PgJXKYCHSkyea9j3w7Gpg36/g\nqB5ht1vTaaJ3nE8SyvD0n7/RaZC2yLmEuiTFQO6qc1DfcTKD9WJwFfymDnLp\nzl3cwvhctbjytBccgGX1UPasXIljVfCv4LCD+YqBnlXvXqynMEg3PBl3A/Jb\nGT3p\r\n=IuX1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-d6d4fe7-1604731086994_1604731139879_0.7447113406028008","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-1a49b13-1604731276512":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-1a49b13-1604731276512","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-1a49b13-1604731276512","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"53ec8c61a5affce411746e0f4262aa5899897c7b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-1a49b13-1604731276512.tgz","fileCount":7,"integrity":"sha512-H4ViL9mExQsLG+0xbc/n6Qmq5BDfEtTjrz/EfOoC/n7aPvORjJ7y8uxmS0vKJ4Hrbnbi5VlcQtbm+wht+LT3qg==","signatures":[{"sig":"MEQCIH/yATRvqOTAlR0R21NlOzI9oRHfEkk1TLw42l6pDUlJAiBVklogiZviyKbfNyvgEHMMut7HCYoYhAv1vmVk1NJnkA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":23785,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpkG4CRA9TVsSAnZWagAAETQP/jxhH0lmhEQkkNoAj16k\nZ9AW3/5DA0qpebjNf7omyNcUiGdISqBCLkKt0BJ/lSpdP/yU0NnlPAi6SJBq\nItjylNcBeFhXfTvRUVqe2/o3v1BbxwFaAsXXNhb+UoPtiWqM4+3R54hBrSW7\nZx5ivyaBLO9p/31qA0oRAmPTqcmpOLRAW9ceJYDwj+8Qwm245aF1z2glgrCS\nwoQGQBC7c04hYlpj7yXFBW+UrvFXWubfyEZ1Stp0vCSm5956kOqNeHXNf9sq\nGt6oHez8uK2lcYr/CSEA65z6aDWSfhoZ8mqtuYEGqgEGv7AQkDIci6F3LjWw\nZmvuvqC7szGIHPy2PlTvkHGIfVBb+US7LhDBlzcFJUGIUzTL9dsqdmafGc9U\n1iEvh16HzlOsRbT7M4q4CxGDyaP62gjtPmGprDuVwEpMNU9VOz8yHfBTWc/N\n7BT8WZxFsxEM1FowAOQx6AbDxIL6JU2DJlQ9jkg73yIaia2FOWu94iiQArkN\nKA+a0tavr8SikhDCCLBxUfFnmQ0vRRS6Yic9AlBxx9tX72ERa41c89laEZpp\nKQkyuwOHWdKbhGiUj1iQTzu0ZM46Iiz0xY8ztUAem7kuHpTSmyy3RFH+joI8\nt/x8w46IMr/XDRjFiEacvY1NjKWVFCkH0dgAodn6BWlGLeYDxME64XxNX7oA\nItPa\r\n=cM2w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n\n## `Store.project` - store(s) projection\n\nUse `Store.project` to create a new view from one or more stores.\n\n```\nStore.project<A, ..., ProjectionState>(\n  stores: readonly [Store<A>, ...],\n  readProjection: (a: A, ...) => ProjectionState,\n  applyProjection: (newState: ProjectionState) => void,\n): () => Store<ProjectionState>;\n```\n\n**Params**\n\n- `stores: Store[]` - Array of one or more stores.\n\n- `readProjection: (a: A, ...) => ProjectionState` - Function that return the\n  projection from stores states. Used when reading from the store.\n\n- `applyProjection: (projection: ProjectionState) => void` - Function used when\n  writing to the store the new state. Usally used to update initial stores with\n  part of the new projection state.\n\n**Returns**\n\n`() => Store<ProjectionState>` - Effect to call to receive the projection Store\n\n```typescript\nStore.project(\n  // pass all stores you want to use for your projection\n  stores: [storeA, storeB, ...],\n\n  // readProjection: how to read the projection from the states of the initial stores ? \n  (stateA, stateB, ...) => <projection>, // return the projection from the states\n\n  // applyProjection: how to apply a projection change to the states of the initial stores ? \n  (newProjection) => {\n    storeA.apply(() => ...)();\n    storeB.apply(() => ...)();\n    ...\n  },\n)();\n```\n\nNote that `applyProjection` could do nothing. In this case, your projection\nstore can only be used to read and not to write.\n\n### Single store projection\n\n```typescript\nconst storeCelsius = Store.create(() => 20)();\n    \nconst storeFahrenheit = Store.project(\n  // we use the storeCelsius as source\n  stores: [storeCelsius],\n  // readProjection: fahrenheit is celsius + 32\n  (celsius) => celsius + 32,\n  // applyProjection: we update celsius state from a fahrenheit number\n  (fahrenheit) => {\n    storeCelsius.apply(() => fahrenheit - 32)();\n  },\n)();\n```\n\nBecause `storeFahrenheit` is just a projection of `storeCelsius` when we update\nany of the stores, the other will be updated too.\n\n```typescript\nstoreFahrenheit.apply(() => 32))(); // 32°F / 0°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 0°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 32°F\n\nstoreCelsius.apply(() => 20))(); // 52°F / 20°C\n\nconsole.log('temp. in Celsius', storeCelsius.read()); // 20°C\nconsole.log('temp. in Fahrenheit', storeFahrenheit.read()) // 52°F\n```\n\n### Multiple store projection\n\n```typescript\nconst temperatureStore = Store.create(() => 20)();\nconst windStore = Store.create(() => ({\n  kts: 10,\n  direction: 'NE'\n}))();\n\nconst weatherStore = Store.project(\n  // we use both temperatureStore and windStore as source\n  stores: [temperatureStore, windStore],\n  // readProjection: pretty simple, simply bundle the two state in an object\n  (temperature, wind) => ({ temperature, wind }),\n  // applyProjection: we extract both new states from the object and update the corresponding stores\n  ({ temperature, wind }) => {\n    temperatureStore.apply(() => temperature)();\n    windStore.apply(() => wind)();\n  },\n);\n\nconsole.log('weather', weatherStore.read());\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-1a49b13-1604731276512_1604731320359_0.15022614288512282","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c1f8c87-1604843153245":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c1f8c87-1604843153245","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c1f8c87-1604843153245","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ac683f4242493e96c70104d959236edf74d59491","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c1f8c87-1604843153245.tgz","fileCount":7,"integrity":"sha512-czM2zk8QE1iAHCiCBcBtrUhHak6RKV8Mij6pvKHrdrj58o0wNiDlDlYHUTOQqU+R+m7laNXlHqSEbxXbx0jL0A==","signatures":[{"sig":"MEQCICLBQsD90rnwA5dTCXQDTPVNpDfkIcMHlJHmBOrJtI4gAiBPtIr0gMzO5YfSZ7QIB+Oq5wUFhELGQqnzqX/IAL5oUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16657,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/a9CRA9TVsSAnZWagAAv3QP/idplTUNG6Oq1ppndSAR\nRsrte2DbX0BQmkgcXFdNmORxwCQvPautsqUQtHta0f6HhpspUwdsH4kAs/M9\n81a+V4HcY0fAr5OMUVFe9/J4R2B24vPxxHTjn8CHyx1fWPwaJGq/KqkHkebI\nv6zHN9sD7VefGAiA/+5VQh7FU6fKE1NxVson9IV3Wq8zPX+hWtJXZ00v3N3+\n+qroLs7c2aBEuMUhuYT/Hi8AbdXKurNHMFH6rf+ccU8NI6o18WJ5SA5dC5d8\nB0+IRxZKzsKqCjbRCaR17+SEeP0utfUET39jsY24/YckYYWJPiVEDJcau9Wh\nq5nFIW9HVkWzb5ZQZvZJZsx0JZvRHma86MD/Tn/FkCY3t1FSbC4/fETiuQkm\nvp1kKHSzXwix8KeSORKhtoaMWFrkFJtanbE45FCXFBCC6POGZtBd5g3lp/0y\nrMCYhRTu1WmYpzSqni/BAmlE+HjH268r1+XZZFh6NtfmwEvdLyalHh1NzSVT\nbxPRAIsn63JwJnvTIoFbhYHNDgaiVy95G4/BfsCrfpMa1WnIH4+1o3UDTUUL\nfUiR6lwtwW7gmFG7MDBn5GrfHsHtkDEWLlZhG+2FcJAwVlwrLUl1WicNWiIn\nTJk9q3VFRnmEEpuz9TXUXLI0kzuGF/ba2J9mCGV+DQzI8fBZS8H5mA8Xw/AB\n1/wn\r\n=uNMS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c1f8c87-1604843153245_1604843197258_0.08029587065245547","host":"s3://npm-registry-packages"}},"0.1.1-beta.1-canary-c1f8c87-1604843150437":{"name":"@iadvize-oss/store","version":"0.1.1-beta.1-canary-c1f8c87-1604843150437","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.1-canary-c1f8c87-1604843150437","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"23a78521d6191f18c99e65888100abd65d947cb6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.1-canary-c1f8c87-1604843150437.tgz","fileCount":7,"integrity":"sha512-otahPRWFS1ITPKzfXIwMqI+JXEHRupMS4dBScN2YDpe35OSr1WdZ09DGkg4pIDIPjK6sBBarRQGZCg4OsuATRA==","signatures":[{"sig":"MEYCIQCazILUA6Pk7BpzzhhG+4UVT1oPVM6Jm0MTZ/ZxPVCXfQIhAPYVFGvNW6qSR/OjNgwd1IYibhO8Fu9rLuPmenUCRNJF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16657,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/bPCRA9TVsSAnZWagAAP+YP/R0cxWLbO+QuKssy8rwx\nzI6n9mhp7wqr8A91pajcMi/QjF7JrNmPtLv+zF4BUqey0F2h+0O0gppLY8fk\nsiZxbaQY2rtavNisFDB/OyJmJbNtm1j3yiTFkDU1/iauF0Pzq1ALPAGk5IFF\n3Y8nLAXypnGc5jsYcZYXKigS4xLLVKMkz0Tt3emos9m86/cDOmYZbm0zDn2g\nSiKIliPKdDjvFyMyLowlvSTuzUdCfxn4kA3HO5tbEhPqdHjhXiN9uGHy3mi+\nXNYEP2wK2d95kHgrtOcE8/uYJEdGJJ6DBgz+VG3KbwbUwY+V/VZTdpTsH0xd\nHUNF0QoZBz2pa/DbFKUN2cc4Fsq5luC7EV5ijqiBO0qzXkGDVIBTmYg/H/+l\nEa/hOQVFWKR10pdGb3nx7Tc84/4uoRkd2pAEVK1SASP0NOfqWvib+qo7fNSA\nnqEMHQsSb3i3Dm3v3BpQ8CB5HaC5KsylU1fx6LNk7G8OWAKz3WTlsMoUwTgK\nWU0j/Ev4UmzuVNM4ABVZC763IpiBEJD8NcDRKzPXypNeFotXjhGIOVwKDE6g\nVstySCKxtL41vL7lZvZvgUM0JtT9bY6bXsQaVZZKY+xlIeLeZ3IYD01v9nFc\nL9TCSOjOKswald8qqSkAQuRvY9K4G0hk5ZsmoHr9z6FenPiUb+S1pkq0I+5t\nDh7R\r\n=zJCA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.1-canary-c1f8c87-1604843150437_1604843215479_0.3931966027182763","host":"s3://npm-registry-packages"}},"0.1.1-beta.2":{"name":"@iadvize-oss/store","version":"0.1.1-beta.2","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.2","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"89ab3f2c0cd676b1e2b123ba467c2ce523e8cd2c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.2.tgz","fileCount":7,"integrity":"sha512-mnuA7BUDdmatEVFmOHGJKlrtUEj0BEG4z+Ingy+s4FlDiKuxkVNPMHYn9P0vu3ivBJ4leObLPYRMrT1gNopxtw==","signatures":[{"sig":"MEYCIQCGdaun9K6mMqNvsPxrlFAm3hhfK1cmy1dlgL4wmTkHHQIhALdDrhd6pqRwaekz3kdqr8Ph1Guevwtx9oBTOYzHiUdu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16628,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/dpCRA9TVsSAnZWagAARmsP/2EgaiQKHy4cDcef1moP\nUmdsTCBPNqXdglzr9zSSLYC2+Ko6AR68gValOI8w4p8GWGNxgJZg6/1y9VJO\n3tC5aGhTa7+vhGgd+mmCMDnBLS7krH77Cbkv7Cnn3rym4FwVJmFJIwrqdLkw\nTX/CVwpT2wKjIN1wVafi1ZgnxmTMNMUqenTqkRLb4DknEoSA0LqKQQrTjteO\nSj4iG4e8B9clp9iPb5a4u9yJtf1ASkJax6l2wRmmIgkp5gEM0xocPI4mLf+R\nHGbyVmmhvQKfKE6/zuj5CRvpEffZEkEbB8gOGe1KDVkV3bLpf1zE8Lbz4y8+\ncRT3PPGZ7+C2JjfCftMLlLDBdEiqYFteqUOU9z7+H67rrgg9bzAqigB0odoo\neN5bDtaMHSKviesSOC/f5n8UPgbZbRgV//fJedxdJl+742vZ59twYdw/qcki\npi4kWYkaYaKId5E6Bz5DZwnFpjatsZiFS6plM8VcEPNBEL46HTzk8d4GCljX\nApMVbGQF9p7IigUJrdQN8mhjqa2dw/uYwh5YJf52tt2h1F/Uyf7ECJxigbkf\nS6l6fl4fMLnkb+pAnufPBqu+lAz1mq0K8ed16T9xU7vw/cIak/HOEib8Oq4J\nSQ2FGJN7O8fdU5CMiFjorUgyuNsLo0ixseJzMQULNL+H5e+cFst/PqyHG2GF\nOZ34\r\n=sqTT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.2_1604843368834_0.16528128598175296","host":"s3://npm-registry-packages"}},"0.1.1-beta.2-canary-0f6426d-1604843475214":{"name":"@iadvize-oss/store","version":"0.1.1-beta.2-canary-0f6426d-1604843475214","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.2-canary-0f6426d-1604843475214","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0a6266e2faf627014fb02930c4c5fe3200228ef7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.2-canary-0f6426d-1604843475214.tgz","fileCount":7,"integrity":"sha512-H5dr1ybpae1JBZYmX2SSS54lfU1zBQA7fVV2oEAGBPbARVwt4sD+dFKfUp0I2QyyBrTwQjn75vrcsWTWTWG0bQ==","signatures":[{"sig":"MEQCIAkXqlUHlNfjuH9IMWWRJtDW62T+i0JJ+g2E/+ID2uKlAiBN5oz8+UaFExEXUtxB0dNUlM0Yu+sFHFvK7oj8ckVyDQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/f+CRA9TVsSAnZWagAA32kP/juhizh+5Sslmknlzfpe\nb/g1pRJtUNsjzvR4rIIZfT8zTlKHfBXSmgW9dtIPHHhkTJqILudugjxA8c+L\nfXZ7FLbmR+TnN6Eaqdp2lIbdtkiD90K7VGhvqJiyGtcU0vvgf2wPOCZjDYdb\nPcHtQfK3GnAwlxl9eLqPjAnI0Gs3ne9tmmZEgGQQ2lgoE0Z4yp0lRAX4hvZj\n91HoWECecEcqR6xzfs7ukmKRm1Io1/FyFgQB/Y05RBfPngJrb68GZvAecfqI\nmptyGz13fyEpQRQmR+mVELXzsIpN/CaigWtt3Zgh2KhYsdYBgxuJp4u3zpqX\n2G8C+67D+W9hUz+ZJ0HTbLx6taRxh9XFjio7Gcm/thewhu9BD0Xygq02NRLZ\nwiG32P64OJ+y7u26PdZqBKPsxCM8IBKNrzLYT9P3xQuiNSsgcZl4wliegBw0\ngOclpz5DPYPFXYeA9RWm1pY0jZv1vDEKR7tPGosbflJqaRMOrydXf1SfuXvY\nLululBhqntP5v1oTS4+LOKUHLZFUzZOi4QcNZP2sePgLbBIFi0gTINOJaBgz\n69qLGAsJYPdaI+hHCHGAr8kROwrDTCBrfOvC+kYu02+x1VwjXEz1HS3+3drb\nKMIqkYqT+aX5kGZ1bwt3krE1V/U1+viPBQ2bggVBRySctpk/FOXzb8c+50fq\nkyob\r\n=f8mr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.2-canary-0f6426d-1604843475214_1604843518119_0.6823088547069762","host":"s3://npm-registry-packages"}},"0.1.1-beta.2-canary-6e6139b-1604843474038":{"name":"@iadvize-oss/store","version":"0.1.1-beta.2-canary-6e6139b-1604843474038","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.2-canary-6e6139b-1604843474038","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"18de3f319421b213d5d964139d17f07e252aa45a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.2-canary-6e6139b-1604843474038.tgz","fileCount":7,"integrity":"sha512-loisUmTacsUPVLENIw1al3pXo++S74oeIxgLJPrQqWeJ/FSZjmBc/17H3dJ1+4Hj0bOTj5IIy0Dy2BAv0chXHA==","signatures":[{"sig":"MEUCIE9FdBTxhmR3MiXeP1ZrF6MYrtMwCWVy4VEx3IAAJ7o+AiEAkZDTWZuJay7dSsB16R/iAmBJd2iL/dARotIVJSF7og4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/gOCRA9TVsSAnZWagAArNsQAIX3htEWKK8Bv+HJVoSP\nxF7bC8p9LgU/GDtd7oidHVxohXjCkJTbr41uo1VAfKcch7L/2boTHRsQn27l\n9Z/7uLPt1gJ3JB8eWTEHHE38YB7l8372yuax68kmuVq8A6xb/JdXrjc+gm10\nIZY0HTBlei7gEEmEIM/VilBZ1Ycc7vHF3oE/4fO584UP7RFiUHmU+aQNcnCX\nL8DaOM5Mh8QohNgQmpV4oPV+SUN89b5nm4kDDbxcXWhUnz0QBkXmuTwTXUbP\n8B44+69XsbhTKEEbhuVqvvb/QZp9APLCQaJYo0pV+R7TmfUetH50ojDon9QF\nfkkob3B5gG5qLdKsiC64awzX/uLQ13fUI2WkQpSszHnORKHT6VVr8FWRe0vB\nKBerctY++YqEnnl6zf50gk10eMtF6ZeO4LNxxnyddS3C8UcT7IJhXsHN5kjN\nvWVmQ2qeOOgY+ab2xdYVNkqJ+N4iNLCSCTYAjMGvBNLnpc+W62UVrTfO0DXw\n7pH99PhMDXds2WURgmUPcywMbdhkdlgyO3ynTuwywNz9YkI0ukCQyff1FAS8\nNoGtjOUiniwZfbyY8iBXrJHHlrVHBlOOPvVmSr53CGMebXo0BGsVfyNnQwSn\n6TpT8yRwlAlUzuBn8axuokKWKA8W1xjj58epvRrCRvGmJ6EmQXN72X+44SK9\nYTqu\r\n=8xMW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.2-canary-6e6139b-1604843474038_1604843533867_0.35345999131029804","host":"s3://npm-registry-packages"}},"0.1.1-beta.2-canary-9f897d5-1604844864243":{"name":"@iadvize-oss/store","version":"0.1.1-beta.2-canary-9f897d5-1604844864243","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@0.1.1-beta.2-canary-9f897d5-1604844864243","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9118da813632749d5fe73e57f58af3952f9f9a1a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-0.1.1-beta.2-canary-9f897d5-1604844864243.tgz","fileCount":7,"integrity":"sha512-8sunPe10zzX5czDn+o+LJ1+Crfo/Gx8d6wzhRLTK12FzQTIrNkFTrZPhtfZ2i/7/dEhfwMTqVBWEiHZaNUigHA==","signatures":[{"sig":"MEUCIQDiSP1DlFMyWKtNQyLff42ZbzerFjFf5Aj4hbklB3ewRAIgWo1Vl3Ui+aqd1srFhgLUtPbB/NfZ10Tiv/SGOicpyhA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/1+CRA9TVsSAnZWagAAbmEP/i0oytEkI9MyP5qOoj5X\nldCz+MnjWLFJKQyt+PtytwHidDCsML21KnCTS5wKTZKieAiiAJ5ETVRhnJze\nztgJdhhV0ACrMtWp3wctP32MjYTgvB9GzEw0n4RHOy0qD/08MGXJ0uuwHrz/\nm0WXYRnUPinIchKxI4qgd7/IjrWTiIhYSeaH98gTvdVi3DqcgMPEQmcHgGyd\n40IoNBhZgbD2iyIaWzHPW411s6FNrK/2ddn7mFXEYtjPReu/F/VCw5uPt4vu\nMIoVEWwi2y5TGm0J6j6eIxwo2hCE/vGDmYUeTq13k+CN5QtLMfybXxAElvnx\n5SeWpQG8ZtqmzcR9U/UbwtbbR0qSGjFdRbwhtrGHiBzhypNMmzD6PnI0Vp6y\n/wscJLbRMVQxATEHji3kZFnNpnfkyXVUsMHY6E1l8bOvAttITuFx2Ft2GcZc\nu2oHc6CLBAvWVMG4Hl5dzPRNN6DI+ASA7ZlqP8hj8bdzZsswhSWAs8Z221XY\nBogPEbwKZMfVgeklfR5e43RfcwXS2lAFJ1I1iW8tKxdAA5np7Mi9c0FtvY2v\n0lq1m7NDVwgMaOPNSkdoR9vkmJAv5jYczdsrqt7TIbIYLMYqm/VOZsfSKuM0\nzNkSh31uiaEp+fIIGmtxtVTm0cBisJOz2FsaU+sriperbcqY695zJ2wlFKrQ\n7cAr\r\n=a0Bn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_0.1.1-beta.2-canary-9f897d5-1604844864243_1604844926116_0.7242698889212336","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@iadvize-oss/store","version":"1.0.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ecd0cf515a682e08a32f83aa8b076020040241c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0.tgz","fileCount":7,"integrity":"sha512-ifr3eEc37dDeWuCaSsDoFi461dzFBUMHOlda4CouiY1BeMDRuGVTXBBLc3+8EkStOToZhBwLLMxm8lnBHmtwNA==","signatures":[{"sig":"MEUCIQCuvn4c9krHipjL+kZS5JyRt854OJQEsdRfZF0Vw6TbEwIgPtOhnckVMPZMP72wK6W0Mw8wUD7XAHGIs1qN47PrvlE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16641,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfp/9SCRA9TVsSAnZWagAAEHsP/1vOtDhLO9dc4gX3b9Ic\nUe3v9WbXcCqxOQ5T0UlGOVix9KuwRnTgQ4w4TVWXFvPkj1RsKiia5gqQ3A9g\nrYK76nCz828RSt5LWwbrmSfqIPbwqET3gt5WYhRD6Lzpa5pZmxZNwQGAMly5\n42AjrhXQqbLcVBkObCfdbF7jgGqABQrGTTsSpK5cW/kldumFmIXhTSIdTir5\nHd6KPfSONCCTMUpICwSDU7Mr1fOIsNG5eiQxkHyjzHMJlkkxU8hgiknIrkDT\nYrYqLS0XLBS1SkJrNVjv7pNyapU3gY/lu92YCQj2oWqkG0YgYCd4Re+85M7b\ntOpnSuMEfadAWbHGiAZHWqkPagPhQ8zd6C1kujv4B8OdztKeWozD/v6mk+OM\ne0lFcjID83NwArWr/TQYLaddKgQPQOcuk0fI9IHgXVFTjpijybJ1CMOKofsH\nl3qo1I/Ep6BwKstlw9e5ES09SYWQLQuOJE3zJ8JSl5t9wnh28D0BB6KdyIRf\nLhoN9sZZq/zW58BWATY3VdFPHpHP+Ov5N/HYrK2InY6r3E2hXfVDfN+MS6Yq\n0ITYej+lGEbCIh6j5Xz3u4EaXbhlC37yfpuHMvEOqqsVTAiUzFMZL+rMcvbk\n1aPDdfsm3YkYpzIbuGuGAtM3h5fNd3DZB5LpiHrerwe75aI633v+O3aoQ/0z\nlOxN\r\n=vrwP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.3","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0_1604845393590_0.7106263171122431","host":"s3://npm-registry-packages"}},"1.0.0-canary-3978b38-1604847784718":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3978b38-1604847784718","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3978b38-1604847784718","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d7e15b2b322a6970864a1b6ee915aa549ed71ef6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3978b38-1604847784718.tgz","fileCount":7,"integrity":"sha512-L9AxKgPEdjJmrjPLme+IgKOVYlr/v6MZn0Z6XoSFtPr7cV3R/+DhhRGs46C7OkzHdQ3djVDD5o/YLqjR73/Ucw==","signatures":[{"sig":"MEUCIQCtR1hEhMLD2IyQDT9MpB8ip68g8PJZwk4bbix34p1YtwIgAdbWHf0Oqrz0oXX82OwzzuKk1f6AMvW0a5UkZbcEKA8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfqAjdCRA9TVsSAnZWagAAKkgP/0tdjTzXIlr2x6daPUJp\nUT+pNunXB64NxmSBraguuejJlWa2dyqXjW7dS2lJQguqQezya938EXzMQbX3\nwxhXXQcJLT3FDpdyWTJkWOnfqWFhknVYHHFjRylVJmascL248SwTpcTUKInG\nr5kvImw4rX3D2Uw6UhbNrSJnm7uZwAQCIon4WI4u4leOciU1UBg5e35I9nMZ\nAbYXP0XxD6GlfpoBwMwpnajH/tJv/M6OHPOu5QZaoAXAtddE+GthsCbysT7o\nT/6Gc5h4Xgu7CqpWvz3TUQ0+OUShxtqNWjdp6z0H3tBg9FZ9eUHtuF8ZyDKm\nkr1wNG0JMPNq4Zxtp9Y0H3MZi1GUmmzWKiGefDaV8UFZimVn80i7wiV8zcsw\nrR9F+NEii9spxjCj9UylTo14zlDsuGm1Je5XN5tuBicdrPTzNx71rQ/uhlSF\nEepG9g87ozKUT3Mgb+dUlc6rBpudSXJ/mo1RTDQSzf87jTg0Uyg3oCY+UHBR\n0oNBxq/h3kNQP/XigwXbkS7ryryNihR17ee1q9nyr12qmH3UHM0DrQCRdu/g\nU3NETxgkGdvfZh8Ze2x18n/Jw98SWMN8Z/BneTsnnT9S1uKVnYvHy0v5Lonq\nIfkMQBWR0gIJNmR2oApLiNXjvO0rCEQR4zXTPGPMa6l1HYIAzR2l5NLVCdw3\n+np4\r\n=uq4A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3978b38-1604847784718_1604847837298_0.8509179711583925","host":"s3://npm-registry-packages"}},"1.0.0-canary-3978b38-1604847790524":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3978b38-1604847790524","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3978b38-1604847790524","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a8853f864fb49b439c49561098bc94bb8d3e6f64","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3978b38-1604847790524.tgz","fileCount":7,"integrity":"sha512-xGKKWbhmQtoxHr6FI2R23QyQxVlgMmIkyhXG7IRf7mk3yIdyzsuJfp87Jh9sgIgK40RRTjDjBc6Acn/MmSjNEQ==","signatures":[{"sig":"MEUCIHxXTMc2Zszd8YRmW1GLsquJLetxhpKmzxDtEkQEBNvoAiEA/0T/PtNzUGmBuMkEbIuvyarNzF9hDzvYCRUwrTyMQbM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfqAjqCRA9TVsSAnZWagAAfzMP+wV6W3ezNQeTxfnC4Rsl\nRVY/8XTPsqTOK/nrg5Kf+vKWlSykJ7lpC2br78oNQo7gTNQWKX6JlDrAMbV3\njkvziH8FDXmGK46aqOYYHLFtzOUfEbI2oyuJjO7h/BCXXwGPd93iqobYARdQ\nOb+bgwspaJapICZYbHUqh6WwFKC1qSQNzLGtXZU219MnWyILhfEdfpT2Ksgy\nlQl+XJvNSaoZLPlj8mIG+QbvzkARE2Hg0ZFqc+h5zvQmJ0hrmWArBtkHyohS\n/Iv1LZiRpY4tJTYU7kv728Vj3giSf7GO0BtAcC6sTrOYAPvbiaUy2U9vDHIO\nN4Fn7VXcg3F2YAT+ZsOLvK9vukSQ9kR3kOFbfrwEDN3I0oOqDImZTad5PPEg\nPXWRgHEZSvtmhWdwgnUFPTIWKq0qD4cLYIkQ3fdw8OKIEaES55olejKJrhHO\n/N5bO4MbQB7jThTH32kyzj853uYue1JZ6KXFxYXmCd2YiagYAQuFUTkmqNvT\nseJcCGHJa7AuFa2FvrH4Id2jSJSuAcKqPpCiFmp2dHjVwo/7sy/xnF9kmFU0\nuIVtIOdgBL6c9d0sroVqHfDp1sbctuf5vmFBrGq2GNH+gwFS0fIgNGSnQQTm\nsIEQsn2D1y6vLYuB6l/2N79IJxA4ttQ21aTaWeHuQnz0Gdu7hF8C9CaMmLOS\nmWKv\r\n=wjL+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3978b38-1604847790524_1604847850283_0.5172635827129337","host":"s3://npm-registry-packages"}},"1.0.0-canary-35a4b53-1605363609642":{"name":"@iadvize-oss/store","version":"1.0.0-canary-35a4b53-1605363609642","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-35a4b53-1605363609642","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9d20ad8c24ddf93f022aea8f804672d6e1be1057","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-35a4b53-1605363609642.tgz","fileCount":7,"integrity":"sha512-knVbk9Ohww9E78h6y3XmmeMfFFB0lFy1GeybDIAGg7TPQeNtaXJ4mMfsT21b4UKknZJxW0fYK4VPFJEqXU7CKg==","signatures":[{"sig":"MEQCICZQsfmSs8B8IQ+99z2HX+Fairuj8/Gm60nRv4jaQIYoAiAJooW+z0IzXgXSWzdszX5Q2u0h+7vQGJd9xdhSm6jUBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfr+fRCRA9TVsSAnZWagAAlEsP/0i1jpoEOQlTi7Xgchao\n+O+83q9kmMEuuMAmrobMRdOMgUE6nyvyPT6qK8HxUdHQ+7demszdY5Tl7bu5\nN0BNzj8jdgjGfvWMzHI5M4bAFeW42GY0GYzlVyJXcW2EocXR4JXXl3rqgDG2\nMU8IeUDMXVOTAS8cl4xHTj3fxp2vPYoyiTLA4L3Nj98pmZlRuqsyKW6doSKJ\n12yd/0G1CylFip4h70smN5cALickwWv7gkIE5Yy7gPAatdZfB6LPpxhLkFIi\ne5wEZnqv7giYYYdKBhGUwKh7+OBycehN2EN4AYnE+SG4dKS7QgrrzD/urerh\noEf2fLtlzd4cUalYe0zDIEsJzDaCbWNn3KfpnzboLvDWM5YKZj84Af4B86pC\n6oMXr5dQdkJwpbfkuuBdDCwzqdqrK34GAukkLP8dTjUEdQQ2qdcC2pU6r7Lf\nOPTFqKE13DT7B75HHAigV08NLP0jNlReE2GE5D5/6wP6un8wYEakLL424J/B\nCxTL/pj1btgD8XLwxuMnEJ0U+fQCzinwnT8nVHvYzLF3gqfxuPolM/cIZPra\na/KCBW5eaFhFjkohjNKUEl70cvW4BA0GT0jd2XY1s5zibthyyuyGtkB5m8/G\nGb+rljSY3+lBZT4J2UNAwbRX2fggQAkofJNK82c6o+eYNS+ozpEx/w6e8nOf\nymcF\r\n=KFoh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-35a4b53-1605363609642_1605363664483_0.09393488685500184","host":"s3://npm-registry-packages"}},"1.0.0-canary-35a4b53-1605363610538":{"name":"@iadvize-oss/store","version":"1.0.0-canary-35a4b53-1605363610538","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-35a4b53-1605363610538","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"74f8e5907176f5b2fc2099212a14542240ca6418","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-35a4b53-1605363610538.tgz","fileCount":7,"integrity":"sha512-GTpilQFkO3TVS1R1ZorZnx7z0oTt4SZqrmpAWCKXTBmI/MJdqTamSlC5LGd6hpJepUnJbXgwjd5XQ8N0F2ExRA==","signatures":[{"sig":"MEUCIQCu0Z7D9y2ov+cUwT3qrIWWPaHG5/zeUpmGzwWwhC3/xwIgDpi270k8LiWUNgztmrtRoVgAarWrtbeBmIyIC+z6xkY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfsCF1CRA9TVsSAnZWagAAvyEQAJZXR7ki809jVdIvRV+r\n3wuJd78NXBbQJNtMN+7v85QoY/LvoLRYFCdQLAAd3f8bSiA48G92J1mBKs7X\nFjKMRtZNKwkIBGJI3PVBR/iXN01m2+Z4QVhNNMjNszXXTnxUvaVE6FZLpvio\nGBTuZvwZpVQ+yo846yPIz5WrnCSChbgMCUfmIPJglE2N9KFa9cedawS47VWr\nbyDrbDi2Cm08CU2dbHnFl6Q/Ee8EFi1QeEuGmyPAppis1DJiPNwNzsJixUKm\nXTiW25bjhAX87yabBeY+yVDRWZBmuaSjrx4/Rqh2OYrWEU52VqRmxBmdTYIy\nH3DfeiSMQOKXTr7o7YLgZbHpzZDE6GuOEeRNvQsgFYv2hMWAJ4u8MArd/odW\nCPM3TWyVpUzj+fSGFMG5OhqpqZ1XVeHwNT5gNGNL7xOw9bvy0jkg8tLWD9PH\nwfKScKYmCkAMe/gkhD0V+747Vp9gqEmrVQJ4ov7vhDMJrusjzQO5iE3JTtKA\nzD31W3VQCu0mkyhtKfDsTFnrNID/n6TgYsLq6K9ym44+DFK0bSwHL7XsgM96\nEMVNo/aJURfqHXR4o6l/2/Vtday89OV7/3Kbcn1g2+FnH1ujmDgg8Y/wAaAJ\nD6J3MpgR4fvL1dhJmjnZ7Q8zwpufDgD0PCU2L/qR8rJVZ/tURGVJs8iOrfR8\nfuac\r\n=ahF7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-35a4b53-1605363610538_1605378420589_0.7336272593819213","host":"s3://npm-registry-packages"}},"1.0.0-canary-c0fec3f-1605482157044":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c0fec3f-1605482157044","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c0fec3f-1605482157044","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"185112b062738249d847c4fce45a95b47d725e6a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c0fec3f-1605482157044.tgz","fileCount":7,"integrity":"sha512-IoAZOAqVfjjnf3zRQb9LFUaczdvNwbzR55a6LMvG702gAcov6G7UhPPria9p9RLdrdBLmSSTpVLi8diW7bFieQ==","signatures":[{"sig":"MEUCIQDN59LAK/KrsIXCmEnsrVlO4oqe7hSOTOcPOpVx3bLKhgIgXOyLS7FpwzJOPTQ45XEbxnL731BtAo2fOMe+cuxA8dk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16670,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfsbbnCRA9TVsSAnZWagAAHXkP/AvmT8LFqR6KE0hjeZXw\naMnVSXH5O5VNchRXJf0e6BtviarBwseyZ6Qr6Luk/HNGo5mhCdtWMH72VsxY\nGUxPzr1riu+Ft3knfUabuJFd3C1rH7PZ2Sp7qbPErr6+9Yz2BRWA3WdV1XEC\n5LIcqAN4/cDCi6sYF9ljjglwapaknyoZV6WFC91rmCEoFGO7e7GMmjVfqE3z\n/wBMxvo4exhQmIfLBTkgFMFfuouR8upwYDoomexw3ZsvtXr2335CHtkzZ25L\n2/cVRNBF0Y/svc7CPZT8pGy8b27nzfs9ACWEHBO0q5reSMGDUrsjxEmBH2+6\noFIze5O8RQr995g/rZbr+c/qzMbj08R6lA0xo/L4JXVLaMsIBuivMcGDfZul\nt/Dg0pHrNihAIajj1lr7UdKNa2SxxJ0JAif9NWCKFb4G0oJM9j9dWSznmzhC\nV0DUvOA+fdStg0KP/IaujVnvDTEcXlC34s53ys89sDhdtm//JsMY+qtPTE6N\nmzxK5/rDCUEukQ0bqxI/TYdgkpbhWfBIMZjL95fsaiWDWcO8s0WmZuJNbfN/\nwXB3FTXTzrzMXb31fePtZVegbSLHgdmzTbBEC5ym8eH0ls6OXadC7y00NE0C\nIS8UyBdllIe9MhBp3efOmkiOHRLy0yeMKd2lpEZgXBN2mv3W1AUyupTt/BpJ\n8B4q\r\n=32ME\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c0fec3f-1605482157044_1605482215244_0.8301807582287066","host":"s3://npm-registry-packages"}},"1.0.0-canary-9aa4f57-1605687850707":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9aa4f57-1605687850707","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9aa4f57-1605687850707","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e36f1b5acf7c20c60430dc72358b2012ad6bd0a7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9aa4f57-1605687850707.tgz","fileCount":7,"integrity":"sha512-eIuuNHeH3ZaCy1qlzM1hgVV8JfrB3OCl/E6u3r/8cSIPgMd7k9IeWeSOGJQs2TE/pXfejNZJ4enzfh2yyfSDYA==","signatures":[{"sig":"MEYCIQDHobqMnLweMn6SOkW67L/Ece3QoiHun6VlhgM9MoMtBwIhAK9SpVBhFnY15TmeHh3ZjPJisPIRacv5FcWxy2CxZ5Kf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftNplCRA9TVsSAnZWagAA/2gP/jQs1AnpM4RbViDo0nIu\nLtnYc8vheEYxYLWXu5FzK4Dpoq5sB6quXjaTBeEsEUKUytQsT333Zvjz9k/u\nyf0qvtVZVJFVAKAHwCl9UqrNnTms6vYx/JXiGhdYvdGVc3FGitVVACQJpfkW\nqvR2zAIW9/Rtn/z/aBuXXOP0qo++EOuSOmLl1LEr8AlddKhspE9NMsOCrz8B\n/2z4LuCfcAkllcGfJpeaxpZX/092wGIk4pygu234WIJouVS08l9lJFDFi7Re\nPz1RvrfdMLm1NhORakswi+y0PQ9unksgkjSQ1mjheGi9SiTbiyNePDRUcEib\nnVqi4lb2K/D9mmEER+VdR9PFMgjNvBOEHXzecoAjlBeKKyxpQDqAZbyisqe8\nDf/zUjN+eBtkSyuUMCIZwqTMOqt/DiSd5Z7wXh5Wn+85du7rDOJ6pnXYhTrB\nXDDxHhTl2XdOuCcGJKgl6TkwUqPq/ZHhbNg7Vr+OxNP5Fad6nF6c3ZLfyvUP\n/yIhnQgFHwsvKDZswtkLiJpX89qRHbsa9hFhGPhQ5Cr8IuBWxp1FEBKyLxQv\nKhXjHRbDy1Anhmuubqbd71Ka42MBMpmAWXrczvDCEfCDR7rgS5snJeWu+gjm\nEh9Dfc2ZCGGL7OIgS0Ftf5CYaciTMHUyO9VdmklaHp5GAjyAfvG7bEv4Ztpl\nFLzK\r\n=Kxdq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.3","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9aa4f57-1605687850707_1605687908957_0.5147783011195637","host":"s3://npm-registry-packages"}},"1.0.0-canary-9aa4f57-1605687851778":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9aa4f57-1605687851778","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9aa4f57-1605687851778","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"759abc5d6daf8dee8742edf8eb359735a3a32145","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9aa4f57-1605687851778.tgz","fileCount":7,"integrity":"sha512-O2HEk6MZyNipc5xC3OBl7VQfdSdDAQ5fiQSFQ/hxM5eJV4foLyJOwUopt3iPjOWZmkcNi+nMGfqzyc2avrI+Dg==","signatures":[{"sig":"MEYCIQCTyDViOFr7Bxd6eC9/z04Cx3Suqz0tRcvVV3zlX94KQwIhAJaIFxlo+HUzwtjGadasbDjbYOcrEzvptFqoV9A0jDi7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftNprCRA9TVsSAnZWagAApFYQAKTQ5eIoDOpokN32scsG\nLF6TCGDD3gbKyGrlg4AUoJMdJ7MBfXJGjYjyyHjKjmJwPU0JZOAqotS2AKfz\nPUV5KoRhfFlEwnSS/9v/IaxdEBqgzDbFetqhQRiRqPh4gkHxjBwaVW5+M2SD\ndm0w2lvla2H4mu9iZVg+X9p7lrN8WsGxGPWbDI6nA6ap0TIC1CPFlpvakELv\niX1bir6iUNafrVXS7bODSqsW0jVY2EM8qsVCebkcfUxgrLk+wjDGQpUoM5yM\nOlpcdoprhmGbrMyareUZVuhI+bqegps7wqn32y+WNW5dV+loXDbN8K9Kavbv\nNYe3u1UVo8yjHni9E/ErJ6l50o4O75ykNq+vnxO/sn8uEV4c50xZEhUe7TZ5\nEZ4YavlW4tLerE/9M+9D2p4VVoW7dYw/XvgseEUKvoQ6hEBDkRKl7SpUBimE\nzgvmWn4XFfUCWwEGmh7PWZHThgnqrxuyYenZ3ALODzFSxife3VCFZ4MMFJWm\nT/sIkjVEEU74wzislHgI8Rk2zyvVahu1BB1mdRlHIzl3jEJyzw11Za/X+eAk\nItqvjqAWCIUdFiDhktxc4FTVSogGJ23ClEIzeyXkUIALJlfvRwn8m61WIeHz\nD45JItzD0IogUd3fKXI4y4LqLkKcsOZ/KGbPPNBpzTygyCpRZYG9vt6D2N9W\n1Rd6\r\n=5cfg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.13.0","rollup":"^2.33.3","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9aa4f57-1605687851778_1605687914954_0.4945163903334926","host":"s3://npm-registry-packages"}},"1.0.0-canary-06061cd-1605912872689":{"name":"@iadvize-oss/store","version":"1.0.0-canary-06061cd-1605912872689","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-06061cd-1605912872689","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"262e9301417b4d399510124fb156b945d3f8e80d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-06061cd-1605912872689.tgz","fileCount":7,"integrity":"sha512-chwmJh9EKrwQf/YoR/4NpfgADe1RX2EnZUDhdFBukV7hoQk7QXtV03i10/En2oFifrA3FPMMOJ17mlT27ya3Hw==","signatures":[{"sig":"MEUCIQDccj99RlfYmFOA3GmnGteQmgfTvoG494RVedCeJbQy5QIgZzd5sEx+GmeVLlM2JOZ17XoJsuwbuFO3JM6SwwZGc0Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuElaCRA9TVsSAnZWagAAz6QP/iB6uI4lVVT8ZPITrpFA\n2vDnijflMkWy+f6x/Uki8d8uXbFERfGO7A54o3WA9XglgilV4tUob/PniKUr\nfj7htdnJTzX+HMDg5jrmi2uYtCOWyfcPXSCJkdEY8M09TH5yofl1FSOx52WV\nI/xq7srE+qcLYXGHBA7NLSN0tvhDQOE1w20smAwMDqu+m/9KPJXIItHBaIRv\n6TzmgjWz69h6jZ8QycB6wto27i1TPQR9rNe5js3QfXCydR7dOj3xeBjEXb4V\nyUn7IJJm6eIU/od5XN/iDNnYivrmLcy0DmQEE9aKkZSCCQEKzkcUcag6ts09\nukpHp3cTxaaosA7W3KHz1UtKHcAovnUwK9B6JQH7oO1TN0bx4o4yHJzw6Dst\na51BGAi2GpQfAzouk5MInmpJ+utLEYS6xnuaogB5edy+ATPiTXS/kzqHlXUK\niIFy/AZ2I9bxFEYHlVZwGzv7u5CBoSRwy1Z0nU5yYdtWX9+wuh6JOan3hOcM\n84nCfgurDJY6naSSALEjJjj4RnuMe8ZiiZPXG+V/ZGhKtqZNUE5naBkIpPxl\nrMQ9QomBbD5fDj0r/mRzjcJe26LOiyvT/ndBmHGFh3CgYcCfcEtqszMSerme\nx8GE5/GYvqvdssdQWm/1xO4/1iYYUVN0phBJ8mt3pDUyvaJEhGPe+M9SIK6j\nCGOR\r\n=iBmV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.33.3","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-06061cd-1605912872689_1605912921684_0.7577630598591014","host":"s3://npm-registry-packages"}},"1.0.0-canary-6f8acd7-1606086831199":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6f8acd7-1606086831199","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6f8acd7-1606086831199","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8596aebd8605f97a5fcd6240e36994f95d59eebe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6f8acd7-1606086831199.tgz","fileCount":7,"integrity":"sha512-CpXuwk4rByLv57PbwTpGzP5acjrntlpy/deJrWkK8oVm3EH6355wUbY3SZNHbghtBOq3FccV8EMnmJmTXJ8a1g==","signatures":[{"sig":"MEUCIFqeU1RXDU5pbKBpF7sIWYI3QrBUe6l+c4uw+SIeEcFpAiEAse7lUNJYyjW6X2MVc9r9X0BD+H0k6lWWfonzCsNT4eI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuvDeCRA9TVsSAnZWagAA/14P/RvySUdGprsD9OOMXhYV\nVu55TMpYK+r7p4wQOWXZgG1HH+5l2b5b5fB/5PZKzehrP1wjNKKLX/CC3iQW\nBpfHS+MJgy/2AnJQZOVjemfUJCjmz/24lNhJ5XRCKYs9MNv52DVlCh0KB9yg\nfK0eCtLZgGHuGYsfCm85wu6YO12Ql3aP6mGbXeMmBO8WKoonFi/2LgA1atZy\ndM9xwEuWdfYcXB8ZDlRKxRh9Phbis2zMO7c1SLxozIwkXNiEoip3tEolQzmT\nZulBj4pz9cTMgaNNw8MDKZxWd0ZoeHBxueV53vv291S082wnMY7Et/qzEtVp\nc/hYOqHdZDNgbW5LGcB+fAuYuWTdfpXKZkXH7UEsvQWpXPlKiy1SrllBa6Pj\n4vTjh6gY3IPnsRHm2rH8Ophu9eY/As8Rd/NrcrwpMAnSPa9/0rp/02dmR3Dj\nvQtNGX8LstVnKQ370qk+92qAEnNAhw3oaojyWP6omTYgZtDk1dwcDXPU6ls6\nTgyiacWqYnESuzkbeHtE9ZoxovfbtRkjdFySuLV6T8SooJDj1pcoNnOv0hn8\nouoeTpvAHR4C2+DN8l/oK7qdMjRwL+/vQnihIof9IcRBqkbI5nKD9230FcLe\nn6hahWxWQCxhJsOhgI3Fg40YUe3dlozXy8ChQO+yS20hrjUkqJ7jxnRZXc8d\nsm1Y\r\n=R+Qg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.33.3","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6f8acd7-1606086831199_1606086877563_0.2155463060279268","host":"s3://npm-registry-packages"}},"1.0.0-canary-3149ee9-1606630354710":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3149ee9-1606630354710","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3149ee9-1606630354710","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f62a5b227ef3beb3add9cb518c11be230ab4da59","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3149ee9-1606630354710.tgz","fileCount":7,"integrity":"sha512-ZqQstyG1cZQh5+rr+w+K4PYbOWVnFWx3D66LPr2X4Md4zv9UzTZxiQ61Oig5W9APtJIWa1hJO3Zff0oHrTu7yg==","signatures":[{"sig":"MEUCIQCC9TBnLhZD+tiDLUlVPmdCbc2q5hV89XJLX1NdvXA9OwIgfK73ZgSGwj0Jvpgav3azRXjxtkAqtNLyJDn4BxSlk5s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfwzwFCRA9TVsSAnZWagAAvKgP/R6+FI8DtF0ioFRRpi7G\nLqFv+vL+xSgjpM2MJ2tJTNf8HFBos1L4fXpxMhUggNTKdBR4MCfjcXksitqr\nGBx0zaKZOoNA9eDGVcGHkBIVNF0nwv9wr7N6mPtI7YSzDETv/9q8dcRKoUaz\nMa3pM5EScHBFPj//JWzvJabIUHs3CpxxyLI/ReNwwuPW8zX+P4FJkRWCrulJ\nSurA1f7bocCnHM9Vp3e1HXVPIgXF2pUcmSC3lSqx1XffeKat0XNzfH/9/qZz\nBXHguJcXq9DY89HqYUXBMKLltXROKO4qyfzPMixVhw2roJIgdjpziCMhVa5L\nebqz1i4mKUm/k9P7YzgAwN5O8rm0EeBK/eBEJrNed8kuMz+2vPPwswZX1Jna\nt86HtqOK8113SR3JfWBQgG/6AE90jbgskwy0ppzVQHfJISKfr0Fq4C9gVQLz\nsJ84lTAcw1izyCsLvajHdjL+aKCvn2lx02Qq0T9jbQl3j2gamlrmFr7jnZwM\nHUvuaJg6t0iBi8tNStiGMg1YSifWA9zrGG6HJFpWvWnNUtsDmNXwBzB3IjJD\n1apd+9JMP4f5qzzDsOKscDbklvR4uEw/poRd1nbwsZf7oOhVdsfYMS95dXkr\nkP5FlC0anAQJbcPcpGQH+wve4qsWy+zk+9q4dEJWrhNDIV7zq0uUORm693Lb\nwLw+\r\n=6jHl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3149ee9-1606630354710_1606630404894_0.5452300713926064","host":"s3://npm-registry-packages"}},"1.0.0-canary-f400b25-1606691727983":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f400b25-1606691727983","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f400b25-1606691727983","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"91d45f4a5335d2b8edba4f79621014c90581d140","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f400b25-1606691727983.tgz","fileCount":7,"integrity":"sha512-9Ooonv4NoY1+FOZPcVIbuLxFENcHms9UuJXweV/xvSzJQzb4Z5q40YxVUVAyaINznWFuxfpclmksZkcvZA9ouA==","signatures":[{"sig":"MEQCIAZMaj//B9JtqQ0mBYZAIYbxaHLv1jYwHEbkdim+6qOoAiAo7rphvhXyRRvggPtIrXhVAX4fUVrtm25WXvHxHj9AXA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxCvHCRA9TVsSAnZWagAAKf0P/1T+908FulvfrwqGi7Y9\nv0ZYSFwDBT+9MvVNYII04bcPiBqS4n7WQ/lRT284LZurPHgNe2pKXfLVHqeK\nq+ULK8LgI55/W8wG88jeZnyD8lXUpmDw04/9fwNY9wkb2Pqc70bcwfRSTNE9\nWTwEngm3KNCDsQ9mu6fGV4/xDHMjwZx1AZW2ePMF59QLoqxHzflvv8iLOLWp\nDFtr6Qx2jIPC0A/yhHTcqSlt3HfAokKNMMEOX6FgIJ8N0X+lembp6m6yMr0z\nPOtwyqXaPtiMAfNk0SOWu0XP8QV41aF3alsXSbGEWu4o9Q6UMrE6LWds+6WJ\nb9hzu0iI1YiIylf1KXRnNJL5FeeevQtkBNlxWbMNV2/Fn7uv7vUrIUcL8e8y\ni5lTVGh2MnuBGaFLqokak/8Ydwvr7TjQY2Dx+Sk2u4GUWJws7E5kdtQMSOfV\nN+n6k9k45QdL1nBa3cHdMPGct/TQ4OrbYEDq+vk57cR4ZqfPLVV1f1hzi2Nv\nlAHdQ3Hj0HV4I7j+OzIQHNHYAz/GgJn+Jcsq1Pmv8aDwE2JrFjpS1v8oFNF/\n7uFEg5PbLl9gap6Oz8evRT/SRZaaeta97FGw6RSYUccDInnR9kXfL+YghPmk\nCUrMVUljnw3TddBgAR9eeP90HQS01Zez3nNTh1ftAibiRuFUabi/jQ8TC2l+\nxexX\r\n=B/Um\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f400b25-1606691727983_1606691782592_0.8463963196302358","host":"s3://npm-registry-packages"}},"1.0.0-canary-b3cc713-1606761918497":{"name":"@iadvize-oss/store","version":"1.0.0-canary-b3cc713-1606761918497","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-b3cc713-1606761918497","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"daf9329ac347f8c0326a9c3c66d0f9494b939ac8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-b3cc713-1606761918497.tgz","fileCount":7,"integrity":"sha512-QqntYE1biZmZrBfoxUudh45loIQaWSIMhE5V0X+WGqgPoUO42l7NfQIxxu1y4ByPrV2lkEt9i+xUCxrOQht47g==","signatures":[{"sig":"MEUCIQCTHTyMmz874EqQvD7MmcsIUUCM2Q/HM3wlRO3utuVupwIgN7VbcIkXG+JekEm6P5D+A2PxLvArrvTgoV6uriMZGjg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxT33CRA9TVsSAnZWagAAuIEP/17ImVH0Mt//mwS+1sKZ\n2INHn26KelUuSKn6l25ykZMF57g3Z/1xJGHOs2BLLPKyxbm3mtA25RuIEAO5\nUyccMln2os9dKC0em9ROMe8vpkHVU7yCUIQzt9cGmJucnhWgUhQlayihAw2h\nKuH+mJwgmHUKb0s0e/B9jcOw3W5P8MHVEB+dn56vOgA9bZp52SCvLgDq0tnD\nHelmLaHllekWKpOi8xzXOmUP5L8odYmX82dUhOsUZ4ISWenyckpGP4hnICmF\nDuwWZY7BPOD58iXWmio0NiFBiCZ13PRXCUqylh6IcGwa64+mk1/NZZM1dCUr\nD6IfVAwbD+TewaQDzTuouM77phO60gj95uyfpd0w1ToQBuby9ExKfHPkzaNW\nV5PyD9ltrMurjNrcYOmapT2jJ3hdd6Lky78yGVT4vagr3IQy/czOZeT4j5By\nWCuZ7ppXLV+AMqB/gqlGCxXFmmCYPKNuHstD9ld0a1puz5sboYKOz0P7jGwW\nVf+sD/9zWiFWcVAQ/s9I8vty64yhk9fyvOX5r5FnRP9wIhzRzEEcu6UAgGDw\n9a3C77uBo+MdwFGLt84NNQWk5vfw6CR49+XJcM6skuSQg/7iV112ncuJnhRw\nNnPa2WmPrHsiKrUH3dQIW7BAfJlNQzyBHbMiFKzj3mSjWzzUC7B4PrWN0G8+\nqpqS\r\n=DONd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-b3cc713-1606761918497_1606761974909_0.5013705976541605","host":"s3://npm-registry-packages"}},"1.0.0-canary-a386769-1606808729482":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a386769-1606808729482","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a386769-1606808729482","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"59ee3559faceb73f1a2e1dc7d594271e744461b1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a386769-1606808729482.tgz","fileCount":7,"integrity":"sha512-/cMf8ezWiEuTaX/KDfrQ2QZNmczSrcGk/G2dUG1SN9imZKO5/7dCHxnRCxdEReNgF95SEYpXVa7nOD+0iw9+Uw==","signatures":[{"sig":"MEQCIF5dqpKRshEjkh3PLo8qYH/2dIOITZFlzQKa4pejF0AeAiBW6qygCcc+X+Jegpf+UoabyPn2XN4wV9t8/utCmBorBw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxfTLCRA9TVsSAnZWagAABd8P/1vYZSlhI3oAtqyshqGn\ne88PvrWKWAWERHHNqSs9VHm3bHpB/y55f5yrpUDUmmLRytRbPLRDJtUlRZpQ\njuJIrY4IDwQegQEs7wh0GFVl/BzxNa8Q2wn1PXXUGch2+vcrB4C7vrXOlKRp\nP4hDarXJcd93+BSXTekBo53MHTJPinay+/lC7VQ6vXUnVGu4hiG7MD11zah1\nwQOxGiJlWrpTtlHYXHSauAe0yWN+NF3dG0qw+mAqT2ZQrMVZoc9GFT0zAz7r\nabvsEoIibrJGcnp6y5BJrkJi1vZxHf1jw2f1BcPBbbbwjOQMOe+6KrheAXnC\n9CAoLPkTcZ/nA33tPx+5f4uaaDYxVs4IVcbym/j7ffSyIAFbsNE5MWmWgSzF\nWERECQXtQeRrC4z1v0DpnKt/gyAsdEcUeatLi2e7aK175rEwnLLkTREc06Mw\ntCBSosciKJKO8+aarJ9qLxKZb/VcShyx1gZhcSmtUINRxYq5xdEfuhAPkh5y\n7UClzDqCBTXhuGJmdWFqwl76UZ3RxRx50iVaKZMnHOIsgJCtFovmLwodQJ+M\nFeQ3++W8UGn7786a8TD3b0pvv4fkNb/0zv9tiaAuJsqyyz1smUF+dQfz1jE6\nGaGnZuezuKatc9Cjk/RtwLMzbQ+Gr7yx4QMQC4M8QUqjAKDYT37+jaRGnN//\nHvox\r\n=1Vi7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a386769-1606808729482_1606808778772_0.21622288050505123","host":"s3://npm-registry-packages"}},"1.0.0-canary-9a000ac-1606808921917":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9a000ac-1606808921917","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9a000ac-1606808921917","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6e33e5dded5668decab643b55b2f2b8e39554a08","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9a000ac-1606808921917.tgz","fileCount":7,"integrity":"sha512-Dv/Wlu13ZA76dcoWSvPzAwnpgfYH9T0xgPEg/3qnv2CK/Ke0jkXC4BbyJCjWBdtuxS05xS2oA92A1Y8tYQpFvQ==","signatures":[{"sig":"MEYCIQDlXZkuZPYDnxlr0tMFqBEY7J3FdrUvuDfo6djEdY6i4gIhAJPmwfvr2XxztWq6A9+CgTTby29+NjmHekj6dqywH7Fw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxfWKCRA9TVsSAnZWagAAew0P/j0TN87djtcKhs4OqLD7\ndSJsBChMAkvU1KIR7xPp8HEtbzl/5XooSTuanGKEtmENlqTEi5QzgwnY4UY7\nC9ntqfDBZ9xQHWt8KVIcAzQYxLoBR6PVilc3LyEmKmvh0jQ14jQ0dLTb6Qfw\n9yQ74ydSX/VM0FQKfIL4PbjvFhDwVN7s7Zwq+6DxuKV9Bp5KP/fuo8/7GYaN\nxkGFo0jR7LbUFhUFRMX045KFIgqrZpIRUZ8Vfoxv8QgMcYyJi3i+pgSC0FAI\n+Y/1ax+9yH7dyZ8EwFxWDwkoYnJAY9c2T3qsXRHXhX1VhOCIFCt7Nks+0rfH\nrEkCHGwp5rtzDDTuiZ43IudUVjBEL6gSVkw383kLnFPkSz17V403aUpESWRY\nd6sOf7rEsrDX672LQurX5oTlY7P6MMWBCW/InYLidFqwT/bioZJoR2hXLbyB\nhSgVj2i6/42cB51d46+E5tyMWbX4wJOgC1nBuioOxXvOnQMufixrQz8IdHkG\n0O/JNefD7qr/2F2tNO6OLJF9QRb+NxpmrVIXhol8hN6VC1qPQ28e46UDj+VN\nNgGxwutMQU6MVgJ3ukccTCJBjSUXbPw+gNqCyjVk1Sprrfp25E3DNvBUpY79\nb+bIstOX7zZcjoUL2NCDMJtaX88HrD885MWecRy4VwM1JWYxWd89cxVKCOb9\ndDw2\r\n=dWpl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.15","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9a000ac-1606808921917_1606808969773_0.8645125668368854","host":"s3://npm-registry-packages"}},"1.0.0-canary-c4cfce4-1606854759294":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c4cfce4-1606854759294","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c4cfce4-1606854759294","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"772ae74f639e2c911f16def633234fbc0e751eed","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c4cfce4-1606854759294.tgz","fileCount":7,"integrity":"sha512-xX6z3ffT3/hV3WxwuVK5xCl2K6CS7oqJGIJWEnL97BOFp5Rh3R8p4V8knTL5NHiI19pMRNuRZRQVh6URWj0ReA==","signatures":[{"sig":"MEQCICpplYkgVopRziW7aWnx4dDeyM6FztYLJ/yBMj3L+roBAiAlid+tHZsx0wysYQGHfNNg8veE8CB+5dVCFk1AmKhILA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxqifCRA9TVsSAnZWagAAQLYQAIdKqbywF7zCTjd+NeZI\nKHDUNBZeDeyffQgZumyNN1MQteIy3lbZKyLvAkk0jy2cOgm5R5TyXD1WofPT\nMkJ2La7i41jXREC/di7qXEFEMxjzavx+HLNqfTXW4XcogOMeR89Nr45Vn5+V\nQbgYpZQj2TZevHFQUNM2NsHkF+OkbBUCG0aWnSXkVuMx524y6Rlp9EO6fZEA\nGmeKNmYiSQu20Zddrni2lOpICdcvxcYAnzFEqbf1X1GiHm89VpGK7Mrss7X5\nvSg72Tju0uEIc/FzkRAZwC/1hKPJuvo9NMfR4iFVRwTOkCUijyo+iCfIfFXK\nWhCY5ppkzmEMVYSZ3gEZQ+1rkZGl9ZcmC/6QJaTbScSW5JTgJ1qr+JKmMjNF\nmlcav2/RlO+gvZ6WV9xBo2MvgVyiMc3RNrZu33QEpW0NlHjKf8I3q1CK6M+l\nUlaU1kXXhHcDFDX7/x67lsCYRFbVd/n7PwWI9zbaIQp9upfqKCyqMIPCmG2y\niTljmyjY0CNHE4t4GkLtU/D/qgLIToWR2aqxW2KBO4y5qzlyLuPomB/ml8DH\nwAkn/Trekh8eKejYFot6M4k2MDkY66CvXBTlTyNXWALosoyZFG3T3mJqH5Uj\nU4qjvOCGtY/7Edp199vqpQgDFV5QCIhqnqJuo5/KrgUYZBRwKK8qGmkjXm+D\nCvgg\r\n=eCai\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c4cfce4-1606854759294_1606854815164_0.7815425281509327","host":"s3://npm-registry-packages"}},"1.0.0-canary-c4cfce4-1606854771115":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c4cfce4-1606854771115","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c4cfce4-1606854771115","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"268368f37b9c9977f1354ff6ded1a9be99b31e2a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c4cfce4-1606854771115.tgz","fileCount":7,"integrity":"sha512-hPv5EV3GPLTwq6wiauZmRoHlhogQlsmiuZSj7PkrmRLuII/2sJGCoYQt129xWnehNjnVu7fcSGhdHlpUeyad+g==","signatures":[{"sig":"MEQCIHeCk8o7ui6pFS1aB4TDpOCCBhTfzEs6ULzs7bbd1UVxAiBpvs/YqDW3E7TEJh6tVfm0hPSfiERWLR+t09eEWpT84A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxqirCRA9TVsSAnZWagAAh84P/1K3q3r+IYZQf6PXk7j/\nWNeR5KaGs0KQ4c/Rgw6Zt+QeBRm5yBnKQkSRxHPJDesl2yTvfU+kYW2vjhFx\niFDfaeoWLHEXrbEu1W7QeA/SCq/9F5nFplSU+DAuLfM9LWxLZK8vCpyhINYG\nQHJNqkvNQ24/4dZyiMTRUf1Ll70BdjGjrK/OSZ0Rv843npPLKgGV7GsjLDUM\nTaI4nyenPaM7EY/PAzxq8r6fO24G4Vlgsuzj60ZhwtK7NMs8k/Z0lCWVwRGV\nUdXaWQIFI50oKj6TKmW6/ColowssBnd55Hs3BFliFuoeEF1IzsBFBNrmv1XE\nRLOO6ld9GBeO9avC46aeNCGexsieqoWkKv0amylGdxNghfEbGkc4EarXSNlE\nZMdXK8oQM8p19/X7X2ecHUjcvTWBXTH8LfGFKWjUxwWXqrm7GQcrHdAuBzxr\nPNXPwoRpaltoeKxmTQrhzkqtz74xg2cEeJ5tBrj6WluBhF3QIo5X/3eE3GTR\nnU5yCgu0DKzJfaAEj+X4i7VAhvEG2MMTDYWvtULIi2YT2QXaPCzkoMLp8wBw\nhpJKk0g1U8/wdZsaPWSZdU8wTPrt5s5c3Lz29AqJ+fkE5UiMrpJwCwSxRRB3\nmQ0vLmouNhRFOTYyCOaWD3ZlJ5Y2Rf5fLCxyx29QbvwX1ifBSXdd9PsrvIyu\ny73D\r\n=Vjak\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c4cfce4-1606854771115_1606854826423_0.934385054378869","host":"s3://npm-registry-packages"}},"1.0.0-canary-89f8f42-1606984144532":{"name":"@iadvize-oss/store","version":"1.0.0-canary-89f8f42-1606984144532","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-89f8f42-1606984144532","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c232e05bcd3c9f584b8b0e0f483dd39bc74892dd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-89f8f42-1606984144532.tgz","fileCount":7,"integrity":"sha512-lKtrjp6QHFYo+tlCRnB9d15CJ4blR3z56lVsutBzuYeRwWRcqtU/NaY5QD+bJD2hawI/P+DxjhSkXLohJLSmMA==","signatures":[{"sig":"MEUCIHlXooL0Om7EZcYz1uRUD3eOaPdAoEyvr1qfFT0C9RuJAiEAmi+K2sN8tsLHMszp201cWVx/wXGXYBRQtEu+J3yYOuk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyKIFCRA9TVsSAnZWagAAzewQAJ/FaXxCos0GgrMi/Ge+\n5uCdlJdRZGec13vQ8hpczkNECbs3NwXT7olETYL/8f5l/rCd9/QupyOb3mq1\ngP+jMBKIbxlCv3PgNAAvdU3UtwWtS9yhvCg/o4UEvPQJfs9VX5bnaY2nwC6j\noxVtWCNzMlIq7j4a03rkUwezi+8BoYLzZq7THAQLDEC6OakCMArb6CwMNy5J\nUTPZeJ+/VFmvsxMdqBdZ0Q1dO+E+c6IqtPLc3kYNA2zrHh3XLRS1bh2VEZb5\nGhZYQL+Pob8b7HatorrdioPM4+d2zRCrN/y6IBoa17qkp6MU+y3kcnbMUxN+\ng/miTrPLZyT7bEwdorp983jPwSey+hV590cyU99diT7FByD3lPVNXPKVKQTD\nGctJtwe6oR++Bz+segfecDTk94LiqMznSMfgC13i3ghZZbuybBZCaHwtTdQH\nUi3kB2kGZu4a+vo1QwKqI9l6hg3ZFZi+hrq/Bs/dg1Pfm6H5mSbUlX2Qq8IX\nr2y79UsqGEbAXZW6FcaR2SvgpuEvjZk4RSalhPU1R3HXZS4ABW2VB0TRPeps\nj3HUhKd19V5+q9+qrownWrFcBZWTmuDnYKZW7c8qxaRgpTqG45F3zY036/K2\njcJajLbHV2uUnPMTWbjl2NqZVDuxyiszXHY7sTbyvPMwSU10fRv1ELH/oh1R\ndsRH\r\n=i47M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-89f8f42-1606984144532_1606984197188_0.57879756487619","host":"s3://npm-registry-packages"}},"1.0.0-canary-89f8f42-1606984144060":{"name":"@iadvize-oss/store","version":"1.0.0-canary-89f8f42-1606984144060","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-89f8f42-1606984144060","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f0372aa64a66d9a4b33e5c823353d3a51187f534","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-89f8f42-1606984144060.tgz","fileCount":7,"integrity":"sha512-N3a290Oz16/x0jPBeZ+migl+UtMsXL0LLo/U/e1950/7B9kSlPSU+ZKNYxxa0jbzU7nbHbSLCLtar9PjH2VUwg==","signatures":[{"sig":"MEQCICC9rSGtwI+6eWqA+F+AxmaCwG/XX0RFCI5HNwEb3WdjAiAi0yjyTBFTjF+LrKMu7ufSh5+Gv4Az9Rk972slimVnPg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyKILCRA9TVsSAnZWagAADtIP/33sgGd2uoQanmxHdJGI\nHRyORnOGLL1UixHwHdKT1cGOy8+gESnyzU4RfLs+Gu8uSsp2XbvKIwgbML9M\nhrsbCzYNs7Cp3BJOoutMTRTY91SIOjj2Sl4CAcQTpJ5GJaSvCemygSJmMXKR\nwcC2cGtj6tJND5jGotJM1bv55FfSpJ5OMvqDQxZtYp4y3P15xwJsH9aBxtXD\no7rqS7fmp0e3K5Z/1k4xdkS2cLFtlpg2aChs5+Ks/kKO+qVc+JPcT05ZQgAu\nQ30wKAcyOgpQFfMQWfiLNK03C/MN4t7mgWLp/8kTxQ9QW8ZwpW3Vl4OM7oKq\nlSUJ3vavFDcZOMAdes6JtJnhoEM3I4ibJpM2zmtZ7HdpGPwx72KPdh56g0qc\npM6LTOCJ9npjYbzg20t7hfrIpqMzZQSZ4Mw3debbUGmifoup/xuwYJzPFrgw\noPBCDmonLK5xcAVlbE3JtHJ0wSPUiUE+SAV6AUMCUIAWL2rRctoOPNTYfdWB\nmyqOu0mhPpvgErTdcH4E2Ei3jlEcU1A4mBQgBPBCunFub5hfPy7lnZMgsFbW\nP5CsIIAtIeYHTwAApKHqW0KAxdKLNUFFErdtBPVrQHl8P0CNDfjLL/LKZR67\nEOKu5Rk6n3OJiETvzbdseDSuxfXvakrOMhw6BUGIIWW4i3ZRR4IkG+qliXlx\n0Vvn\r\n=mspY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-89f8f42-1606984144060_1606984202732_0.3607258123308028","host":"s3://npm-registry-packages"}},"1.0.0-canary-9aa153c-1607102838054":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9aa153c-1607102838054","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9aa153c-1607102838054","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e222098e6fd6c8b7f31508c552a257b22c3446b7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9aa153c-1607102838054.tgz","fileCount":7,"integrity":"sha512-P7kwuscSVvW0GOu2qY/XQ5jyg8hj3gMAFdyNFLr96YbIs1djLmxd8Uv2nKKYc18iOD+fMbiydOmNm3rSMBmLOA==","signatures":[{"sig":"MEQCIDEGRwMIvqvXCQFHCujPdSQGCx0nPhIJraZGtk3iIqzNAiBm4T/mjwHT8ulvUVsjeHkhT6gpF4z2GLmCi6MYV86o0Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfynG0CRA9TVsSAnZWagAAf5wP/37+p+8fw14hOOA/r7M9\nY2+jQS1AIeX1hWfPEqcuZZ3zYEo04glECRn30LHWMIBYKfa5rFOViZGxmB9t\n2Iv9bMb7Ogeqdr3Hfs0vxByOlgSbaEY4SupEZ7LXerLxyyF1BMV8Dq6BlW46\n7ZnES/p/UJAZ9SL1bXkcMMOl9FkeyMPFhOczyTJmoSnYmXYw6DdOJ0tpLO/0\neDeV08ZXV6XGLSvbHMjCL07kij3q4iASPV/fy9Z9C4cHBTKruKJrpXIadxa/\nZcbhthmV1yDr4wScAhpTQclOhJMM7ER9jDN50MQqjrQS1rwSKVK0EZX03Iuh\nXTZ1voBuYsufd+F1Y/75Is9U3y0P8zWE23izeY97BizRt4sRyTPZrkU9LEz2\nGo8XzbPDUimE69E4edJtYe+p0i/9VEG68/5aPoikAm0CAwVXFAG6KKK9QO04\n7ZwemVgpz6N/+R+t9Sbbptb+0GdRPQetF/btCMBiLkvo38pcH5o+z9HDokv9\nQ/F7P/nf/9OmsQ0OGi8Lmn9KxanL2C/Ylq/Z6O0/fapyElmqUk2tAyPHg5XM\n1pQO4SU3Tp1gXWG4dv0949ZqP+0f8XzPDgU5PBqVll255GV2obYtfV01Pk8c\nBVlbgwJTXtKS36mMaSXtkDhsD6RmgyJ/ddVAkLTg1aJzbIBwmmLJVIl8SLO6\ngyyI\r\n=O7H3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9aa153c-1607102838054_1607102899715_0.3811295359960114","host":"s3://npm-registry-packages"}},"1.0.0-canary-9aa153c-1607102840391":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9aa153c-1607102840391","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9aa153c-1607102840391","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1ef9078a6ffd41990a5d123a91de96b87856d24c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9aa153c-1607102840391.tgz","fileCount":7,"integrity":"sha512-Cnz/ATsA16qhEg6z2bsb3ODvGIFJairbfgBQHPr/Wc8orKRq9wBnfMCeoMaz+s5XpSIsHnhtNxOoEPI4tv/4lA==","signatures":[{"sig":"MEUCIBMqwM9OW9zv4JTrvzzdRRI4UC1xBbt2nHV6+stYtmG8AiEA1BUEY/QbpjoL0wUDHOP80LphN2Ox1EuiS3NQDoMLpWA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfynG7CRA9TVsSAnZWagAAoUwQAIDMt8df1X6dWW29twOF\nGGUWaq5G4KATuTeO+hKXK5QQ3rsMCRzf/1eq/d5t9ZuQmArVj8jRF8Mpk5qi\nTsDQx1gtyAYVrAmN6kUSi2ZXBYgvXAScMc4cZHNTMp2MS0wvcs9If8bvCQaD\nzImlvbwBcYVZlJW2mzbefwWo4NeY/aCvVc/A44kRnk3hcH80UFR9vgTf6Zcm\nwNU5Jl63OlgQCgDHCfnUm4zLIYYg/PST6n0T0R2iulId7e6N9Ae+A/crOpqg\nmmlozXuMNcj6LQCiNA/SIf7hfMg+2BZaCEEo/nUMNe8w5HA4zMRVyosOXEpO\n/6Js7r0Nr/3nTyzH1SVuzRtVj5Pr1UFbylxZRFmx8zXHeHkuYsE3EB7+7/Ve\n9UAEtotPIyOxqOJfyJBLOgVkcfLmhqHolGVLYf4lsXk4eHd5pBT07o3+7Uas\nZl3j/Xpd+LTf2o1/WRsqWsxZKMAwOEL1yEGBfQ22ZVpQIDzDzJiCg9pNlpBC\nRBw58iDKNDIFd8auqMooRcNKQ3FC4WbcfexjTixA0qx6SJbAeqX4dIdhXefc\n7HqgVqbeaA4mmvoV8jBl1ssiMuPv5paRZ6h8WRpEtp+12fbuFmFLmxa5RDp1\nEDaIu4TJoJc9uBwS4Cvq46e098y7SJaG1U9xSYd0/CEzWEwdEBBVHFnS8to9\no1CO\r\n=KFuL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9aa153c-1607102840391_1607102907502_0.5269044070312829","host":"s3://npm-registry-packages"}},"1.0.0-canary-9aa153c-1607102869148":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9aa153c-1607102869148","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9aa153c-1607102869148","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8cf604d985b7ded12ebfa4bb0e7bff537e1e8dc5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9aa153c-1607102869148.tgz","fileCount":7,"integrity":"sha512-bUGhsRqjsTN8ugiKO48U2UAddTRnFWZyyO2Iz1UNHTKZ2dauLaeAxHzWdoehlB0JAIlp71j02pCZy+KakudVNw==","signatures":[{"sig":"MEUCIG52Ny7JaX3Ko+8lVIm0hzVTMLGB1ngK4bjKEiQAa4GIAiEAi5EFjjWhT4EIJW/jfaGY2BeaJj/N5reYbcz4ytVBSy4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfynH4CRA9TVsSAnZWagAA8cYP/146M2Sv/kHeSI9t3w29\n/YzThr8159S+37AorATKf6OjUnFa49zCF5cyC86wRQY+VF0fnMUlIEJqeaxz\nmmsY7JvBpLWVtwMZ1S2fCZtDf9KJcjBAgiWjFwhvWCTHZiYJvq6BdPDYiXkQ\ncbvAce67w1WAILco2b9blQajKBIa0HWI+wfofZdeNjlHgLvwa1tkbgtjc8MX\nVOl4DNSjIAMJ0uOiNYoOR1PICinyWZvYgFwIYw7qJCYoL4dsMfRW/35yzug8\njEToH3bTaUfnLsmy+j5SrM5wLdYLOWjF8EhIsO9kA7sFyTxgXO3+beHg7E7i\n2s95Zso3HYA+bcSxwXHuh2dd1HxA9lSmV2L2ieAlnYZ7njIhd9JfZE+zytkT\nh8tc5pPSbualwLOW2lweyWhKmuaHcJp4bAhKySldAoRAaHrdawy0ScKGCUaQ\n5txtV+spcJ50GfMgUW0ICvkI3mVntcX8DcXrEQxlVgEp6CSIFLLOuLQ47n6p\nqCFhXsXkeiEUY/KpYinwHCNZbM8iZrE3PddbnGCAbq8d+kCjk/elGIhis+0G\nH2/5PuoYYzfpv70oW8t2gZh85NbSpGx05qyY9S7m6+H5PxDxjxYXWgyzcM9J\nNIEPmYCg+NG+Vx8Pat7qEftPJv4uX+GqX3LLUc3Gs3vFJ1ll+0ot2svGzpv1\ncjow\r\n=5HUb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9aa153c-1607102869148_1607102967606_0.4876442447331142","host":"s3://npm-registry-packages"}},"1.0.0-canary-3f0a65a-1607112463965":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3f0a65a-1607112463965","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3f0a65a-1607112463965","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"572da66b0d74d7434dfbf4e4f19162d2e53c4888","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3f0a65a-1607112463965.tgz","fileCount":7,"integrity":"sha512-rXFd2TzzoJZ8ni8GIhCwpYE+ancfChQ3nQd69uATH0LOVLuVNLCOsuj91iq7FNnPMZ2xgUnvPQUI0H3rryXcxA==","signatures":[{"sig":"MEYCIQCnLgmmDCTB8sCTXlM0+Q0FkOoygyJo/FKY8oBpuVLWYQIhAOtuSU3DIJzh3M9S1t7aWVUD1MF0s741fVEUkWE0y23A","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfypc+CRA9TVsSAnZWagAAICMP+QCNNjO8XvkoQ3D291kf\nf46uwuXVFjtVGOm0tbKeBrc1zhVaMxzrHDWACx76Gu4M05Za1keuO7xw7LHM\n42y98Ryfn9/EzC1tgqzWETLuYTciCi28jUr9NquJnJys3dieM6mi80YWVzib\n3uienW8hHQsYLLe5uKYZCE/yxlZPUArRa7G47sQA+hg00wnux8LrLTKYUNC/\nQS+fcHztAJ7MxGsueed2cwM68LZuATmY4n0IpJRJsrHkTfUiLIj4bHczmyBe\n5y7PWy3QBVSlRru6WjD/qo7NUtT7RB2hrJGfHrMmd0yCKoVyhHaJnblsWzWl\n9qXmmLXUify09hvYEDoVf4JUvDlqHb8PJkHaPqIaBH4Pldfyxn65Tcddkcp0\nc7epU2q0KfBM1cMc47smswA6ZJcC9gULn0csFkM6vEKUBs6mHdDHz0sBy7QK\nFV65w9HzdqGiSrZ5v4biGZo3KG6OFLfvnGVXGU//OlaWxlbOnqpc4vdnMCA7\ntUHJJf51g3AL2bA4Dym8e7V2fZyb20j3Bzsy0a4poF+2Lc75RtReddq7urwm\nB21N5+DGpdYOFnR8RlLkwtW/N1o1bmzX2hq1F5vFdaj3M4Cz+aFOfeNzQV3x\n+3oHqyl22Gd2GX2gZ9HMyQZ5XTyR+tBGNVh+ptzQo+YSklnOnqFBBpr0CDEl\nK2EN\r\n=mB+Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.14.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3f0a65a-1607112463965_1607112508688_0.9167915360099586","host":"s3://npm-registry-packages"}},"1.0.0-canary-77484ad-1607156245287":{"name":"@iadvize-oss/store","version":"1.0.0-canary-77484ad-1607156245287","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-77484ad-1607156245287","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7385183d4b12e577d26e261d8603d8a5e9c0600d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-77484ad-1607156245287.tgz","fileCount":7,"integrity":"sha512-cVGEKY1xTx4Vr8ofSL1mF5MsIpxtZwDW5VXG2ioscQYQO7HQZyqK30vb5btNXPiHCGXeIwg9gxurVJ9EfLh9vw==","signatures":[{"sig":"MEUCIBQpp+L9FIvYr6jXSpq1zf+ryrNZbX+PUR1MRJ4vGCf+AiEA6ZEbZVrXsUSa8O/Bi7sjrQ50KdpdVdmN87WAo4kVl6k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfy0JBCRA9TVsSAnZWagAAWDkP/jTiXwTVc/iwcqESHaHH\nfmKfmLBy5OeKsqcRLmMUcBTFG6RfXWm3aTaB/cjy+37CXo12TJvhUoLh0X/q\n/xlDZo7/4gwI6K2Bt8nzt7tOYbslWJ+X+hDUGExloXyMdC+LLwrbVkAzIM1b\n03Qjkxist1L7HwizUOXCElorTQZCJ+09QD0mTAoQMdyv/iGDErw9gFWQL8ab\nnhOhOZOerVt/t1cPj+bjmBb6Y9tVou0vxhRjYq/lw5Y4cKnBUv2hZtMwTIXF\nr4zY1z4fbG3xeulg8MsvnJ8UcUlkT7BsD89KxYA7rQTB7WFwjqtCS+TPiPCJ\nKvPkfiV/1KOLj80K9qG/vo0Q/uSO9HVxtGOnPb+DgUK5F1CN4dZ/Omk0JTOP\nXefgcyp0SgwE9gROXhKnPJsATzKzBN3ahug+N9zTxGPQTqyTNHTUkb24psoK\n//C/aI+VSTLshuEIVdF4dg/LRSWC4+FO2DHWoSVJUHpoyzUo1Wpz6Zv9n1iH\n7R0L7ReVEGX2JhCI5UMYaUl0eIcA6ZbBMEOpJtk6DTbjPcS54/whIuk+0sf/\n1iIiGH0RkVvVO531s10Q37WsVAMcx79UZd3TUPxuseZOT7TWxP+KjrDc72qz\nDuW8ZPILXl8k3IHFQQuFJAnNJkfU/tiaQZoZLSN7631XMowov3HemYgG2W1w\n/aYW\r\n=2I68\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-77484ad-1607156245287_1607156289182_0.48944559346858685","host":"s3://npm-registry-packages"}},"1.0.0-canary-77484ad-1607156251673":{"name":"@iadvize-oss/store","version":"1.0.0-canary-77484ad-1607156251673","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-77484ad-1607156251673","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"333220639f2383beb815611a8896b2bfc348930d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-77484ad-1607156251673.tgz","fileCount":7,"integrity":"sha512-hQTFfDAucCOSBN0KqNZzFF9yjHcGIoScHjaeADP43GhUviwS1XaoANvrLGHVlEF7z1FYYbjZM8inRo0U7J4LPA==","signatures":[{"sig":"MEQCICzIerzx/KH3L04Tsy8l8pj4es3jhBEN7MChJ5ofg7H2AiBu3NwUODzzn1051wy6ui/0LDwIKM5v0L7hqs+Y9AYRYQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfy0JNCRA9TVsSAnZWagAAItYP/A//YCkOwqDjHZyYHylr\nPhZCWrWu3yJ2BSFVTM+YgiOQOu2pUnxFDRACyO1cpHGsAv+NxeO/2PsoJQyv\n1KyfzNx8xp/uSvxN5HFdG2Y+EGZ74hzOPJEyPsTpsj62YY0XJbiPop8cUzLo\n8Iv2KgQMYktRliUOONAjaLccG349KcT9pF2NaW3a/esHlbVGQuid3b0r+gYW\nBb6j89TGDTuDcRleFWehBCYs7h2kfG3Ry1biEHLRihxbkHCll0lg+2766iuW\nnGPCwmwP+POrnGUO9TuzhSyASm2D+JxoTMc+zREny8sbLa0mh1V/rdD9uZvN\nU5UB/vmLtL3Fdwe2C+yt3QIobcQ63vCRwhYSmfqXiqeEX8FOKjnPzu6tL9K9\naHBdMT/Bl58cK7APzvZIrg6xNS2NzyMIHNtTJafza4yhR0lSQDMPmQc2Nhp9\n0GRGidwiV/frk/FBgjTeCUXWR8OZUIHqnp8FnCGnZ3YnVRnM6OGJn1lU26hP\n5VuxidwACv/LddhpNTSRja22HX6BItTyk9w3W+h+MT4vEt+3E2125GuFDsBw\nbXrMlzg+rntxU2GPL/k7X2hqWcZJoRMekEUNdsCCG3MubP6hz9uoeYaoINFw\nX858Y9/4YexENBsQh98F1p3G6doj0M+9CP0HQA9fKjSuY+4/6SutAUxtRfvS\nwer5\r\n=ZDDp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-77484ad-1607156251673_1607156300759_0.5842577555999406","host":"s3://npm-registry-packages"}},"1.0.0-canary-8013d0a-1607234711158":{"name":"@iadvize-oss/store","version":"1.0.0-canary-8013d0a-1607234711158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-8013d0a-1607234711158","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"77ecbbc7a63c4cfca7a29377efb3eafb23206f0e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-8013d0a-1607234711158.tgz","fileCount":7,"integrity":"sha512-7rZpUBJr4kzw4Ri8ZDeJ8mIeoVd1UT/X5OrL2YgE1zj7ebCxmSobMh6kFpBl1xdDeI3Eo6cxoNwijQ0NG0mozA==","signatures":[{"sig":"MEYCIQDmxMy+4GEpXtIYubx4mtXl545ds2vNXzEq2YkavyLwDgIhAN3PV2s5mUCI2NiIHtb3yYYab9o1glMboM5zXRqdljn/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzHTLCRA9TVsSAnZWagAAwB4P/i6hCe5zumhuIGcGIryZ\ntHs5rsAspfZN8d4ou3jolG179e2liiiBWooaCEYALc6X+/BzQArW2Z01Rt15\nBZADpLfkdGUiLDFltmwUsNww3oPkBspe6SkpcHGQ441PRYJsJp5yZ9oCproD\n45Ry896CzIy/3hAmY+gJjcGDIq7U1YLF/yeGvKEuMyceTSNIgUV2ACGqf4LV\n2oA7iKQLHGrPevJmoIVyIsL2s73QLgOJzNfwRhFyd/g9ClhI/L+JfN26Kj5V\nMNzX4UjJnsB4kDbybXOgUmzFArA3oqpIchZz0DcMHRgjnNjfEN8YuO8YTFK9\neMg8BOIirLdySPEi6D03nZaMcPrTfsWU9Om+PDRGqaYu1JUhQiUAlXTlSS9D\nBFa7FeGTfn3okfB9LFh1vyK1uICg/PsJpGs8we27AAmG+hdzHp1TKgbxOOHB\njTzTeRR2fEvJoqItl/sams+9scp889kbmg7PUDmFi+UXBb98NCk0tThGfPKm\nDmvesBcLgr+FOD/rpF71jStQBEI7poCZ025TKJXGUhkyohRIk0hnT+XveXgg\nV6TsN1lSTQVnediiYKVdfq5p3KnRO9fMuSa1BnyKtSQI80wD7Och2zmm/XfD\nPWGP2q/k5y6LfeHV/sMI2W2c+HbkBk7vWEr4gS9hvt7O3PntRvxVOU6vPp6S\nUSEG\r\n=os+H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-8013d0a-1607234711158_1607234763145_0.36096331035736884","host":"s3://npm-registry-packages"}},"1.0.0-canary-8013d0a-1607234744329":{"name":"@iadvize-oss/store","version":"1.0.0-canary-8013d0a-1607234744329","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-8013d0a-1607234744329","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"779879ec5757003fe237531bf2d078801a255011","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-8013d0a-1607234744329.tgz","fileCount":7,"integrity":"sha512-WKnaceH2eCnk83fkwHKNsBFjqNgCf3fWOmkqAHVwPq2ubdav4kRIZdW3+gPxEu3uwPAxgWU28B95Z2VDfz2zIg==","signatures":[{"sig":"MEQCIGBVodx+lCwJQMTfTyP04HqQwVwP7OV7q42OIgiEosZ8AiA/urzPX04yx59m9hJ2pHCH/1MRAyaUzZQXqd98zdyzSw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzHTsCRA9TVsSAnZWagAAV9MP+wZFdgf1Wo3k5WSv+jsZ\nbhd0J+GcknCycTkl0lRf2/w3KnDs5fHT7LCP8hyo7Q01U35cJlsFGPKIPPkR\n8c/Gl79CuhhAPLumes8ghsLPR/Y0GGJd4XFMIAr4q8buzVYl3dNwBQHSyocP\nzhyLtp+vcDjbv5SVfQDJ6no6LU80VFEFhGUE4DsJKpQXpU4V4ZryvEIuAAAA\nhNCzS4jXwoVeiSVACpkQGow2yoytOKHaNb/ehsxk0KUP8m1LQ28a8VMO+KkR\n0rQrrDMRosMZEVYnKx1HgSshYEZLw5GnE0peoD6mS2Kk4fnBk9HOPrgdDn5w\nPABXxL0AOEhrhtUfYWsMmJZKq0BKflHeTExk5xL4v9FpbleJtG3DlRF3a9C0\nBP9s3zYgrpUElGcCJE7MuEPY0W1zbgMBoqs+R9doiIDXFbWPobG3xsxKIW9q\nounmuvymiI/RIJyOyzD4Hg8SatylRFsx776Pn68fKQTYnu70thz7a5dAzAy1\nRALb62+gfKVgQnyuJk5WnN7xpCToxaGfWV5oQn0+Te5sNQdYa0SOdBw9THcj\nKcKfbF6/XKFVa0fFtatP44TTEPJNqkjqto7iUiXEQ2X0V58kv2gfqKiojmGx\nNszWi5OBg2hgCcNgD0NX+oXTcN+jY/tURmgvNEYhcwfFY+fCAzg3iDC4CM65\nmqpK\r\n=mgxa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-8013d0a-1607234744329_1607234795774_0.2031011478105922","host":"s3://npm-registry-packages"}},"1.0.0-canary-fd620a1-1607242686255":{"name":"@iadvize-oss/store","version":"1.0.0-canary-fd620a1-1607242686255","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-fd620a1-1607242686255","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7acab5381de4e9c019604b4d75a59ac735fb63d2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-fd620a1-1607242686255.tgz","fileCount":7,"integrity":"sha512-L2AQp+JT7kyVHhhx2QO71QWM93QXlo90JoG0aHnsZehQ1wvCkCbB4VDwRg16CA/rp+QKjoMh+IhICeKcHOogcQ==","signatures":[{"sig":"MEUCIQDAS8KjYDwzM+BvTP9bF0cMY172RBLozi5lTn6Z4VQ9ngIgXwpdt+gjIyNyzp9xhSu17tA9sqzdEKwsmXd3a2H0Jxk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzJPxCRA9TVsSAnZWagAAslEP/i4cedGYL3kn+uv7izuA\nbMRr9AnJHThP9rPfSYf/GVRZLQdwMqGUp+MbEcCSAKOZY5hw4hlKdYV4Yho7\nQP9mNMnbrBkYMaojbhpEKot9ox6KcUwHECNNcjVbNBPV74iO9oe6uG2IUbso\nb/xR/h/6xa3I+cD3ir/GYvY7xdbdpNHeYWz3jXnPN5YRRAn4x/ht1hhEzYNR\nMJVQjSs4R+QZ9R62gknr6noM13SdH5UcfyxIG9RAqZtd/j25VFpE/fmMpEUV\n0smn/8CYvjo5WUVOsbi+l72/wge6M5OsAnz97w0XcN4lMdQjzTF7fq5EKomY\n0BeI0cxYow+3XrMUrLPclwEFiykDwEEpFZ1zPt3JbQzOn6+uaNvO1Ugq1Fxr\n7FEwPRsLynuYA91t5xMPIbp+kG3YtPeCpOuyvHJjtK5GdgrozMeCZjxsQjLx\nUJMBx9YD/QZnPaDCnesSShksTzMZ4lo5FLMYA/9xAasooqtxPwk+YpvSUEAf\n/5uJtjamYwxJNfx0FTXxOpzX5lOWZcxMozRum8CpSam2DRKoWJrgxnhHgODI\n9u1oZxG+fITOHPID8mJFNVHnoRdLkwVgGRUmM6D6lQxN5nIZkdl7/JzB127j\n3hLoWjpWSojNLtS9rBLkDmmXCVYTl2oc1+aIhqG94ph6vh6lBcb/S0m+bhxE\n1DWx\r\n=pE9D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.16","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-fd620a1-1607242686255_1607242736677_0.9616788061329593","host":"s3://npm-registry-packages"}},"1.0.0-canary-4b4ae82-1607405501575":{"name":"@iadvize-oss/store","version":"1.0.0-canary-4b4ae82-1607405501575","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-4b4ae82-1607405501575","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ecc8f039facd5bd05349f0c6c968e36ccd45bcf3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-4b4ae82-1607405501575.tgz","fileCount":7,"integrity":"sha512-XucfNrCvvvhdiTOWbPg3t0DsiX9vBFfvy1IHDr9Ea5Xt0F55HuqrWiuv50bWuCPWjUjX7R5IwgDPJkXO2g/3IQ==","signatures":[{"sig":"MEYCIQCg5ai4az2q2w9XDxicGneuiB4CrJVAhSXIdpiSjU1sXQIhAN7paeL/LeKgN89tsWtp1xY5UJwzhSwiLPF1yWmOAvEv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzw/sCRA9TVsSAnZWagAApuMP/0pYTnltV8eaJ/ZZp3/+\nvhzjrrxpQ5tTqE3Sg6tGLW8J/T9hcWlxSkrc1KreIVNEZFxQdgMv1poQilB3\nZVRfeE3KNv8r4D5G06yk6eodg/b6aEcXSwmK5KoFyjS2GXse3DqkWQ6RIkog\n5pHK7hWt2q21BzllvG5KnS1FiOfThgmateEgCDFR6Ln/jduD7oz8sQw0DjhO\njvyza/LqogOviKCqfo5evEWTdVQRcgbjjuCvORnXoc2X4657CiA1HPljMlk6\n3hiCB1bpVMYvmBa2bKU/5kCvlffqLvaApOvySixqTQ1pmfZVcZ4EHGU1x/IP\nc8NSVUgajh5fGD4q7MxUGxx4GlT0OkFwYZ/ogypo83TJ65HWL2OVOK1/5gLS\nAKnXC3MrE1/Ui6Eoqe+0r90lkQGPef4xs+V+rMdvwj40PgwrlhAmemcc7V7t\n4gfrcTUZH5rGhocgU5PaWwedsRyAHIojheqQK3IJYjKBPu0Do9TOoXHJmGUE\nshVFXd5lxVDZQt/6iyIOEVbl5y2uufSzXOqhkZYcrwF37m6/oRO78ah9Fuz0\ncDGCQFkHgFYUPbfk5+2ssjWqgTWa9omH5iZC/6WI7VgQDYQUhsCZ13qKu9Xi\n0wUtFIcb5QMMQ5Nq6EEGiJA3i20Hf5VgiycW4H+ZagM6ZLqDSNSM5kMaglIs\nrP8c\r\n=rBRJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.17","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-4b4ae82-1607405501575_1607405548084_0.7723492575927013","host":"s3://npm-registry-packages"}},"1.0.0-canary-bc4cfca-1607421291219":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bc4cfca-1607421291219","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bc4cfca-1607421291219","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c8278614c198abaceabbc00614273501513f9bd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bc4cfca-1607421291219.tgz","fileCount":7,"integrity":"sha512-Gk4NWprqaZwvZIPv9Y79RRi0D+gSRfsucQORhJ8FhsARO4R5bgsv/OWYrgJF5BMG72eqla71qGDuG8QYQj9DPg==","signatures":[{"sig":"MEYCIQDw/1Ypa6q6o6yu/a29V285stJn+67qlZCgVaIMxIWRIQIhAJyL2FLkg79Z70a9ZyZ9X6gJ96KHAcR9oRS18lo5mW1g","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz02pCRA9TVsSAnZWagAAonUQAJ/7mPxbBHZsxnYQT86x\nlFn17A8sd6kEh2RgmoO489yDx97kTQBIfhCwIToXPSRiuU7thVvcCtenXLx0\nYAALyoRlWOISsH4/XF40RJu3+nITYmVbIKfql7ogOeI61M1QM41rNPYIAac+\njQyfpIoBl6RK6LCYr1INYtu0XnpSFIl+kTLG5F+neCohBBTUM+J0KcCe0cn0\n8rN1zAZIN3NutsBrp6XxNgt3E+CXhnV0d7RYc0fWau1OebnRWT+w/+c1yIeH\nGKv+9r1+zJ1wBdf0W1LbgsU6pMds31VYAFXUOVVYKsfGsnt7xYCosi70hIyY\nd7ViSTzBEAfuz5NLkrdT86u7awFvgfUA88g910PJf8/87TXPfMwdbhC0SRMw\naC+l6l+rkLf0T+Ir/gk0d0DeieHFcl74EvU92a1MMVbY7xI79uD5LOIxqR3z\nspmi/0HeyGRFFUH+mYUKEOz9xLWsJibdHLT3sFiXDEib37mX5W0RQ62C325c\nx/KGp6OuRJiF+v/4bHc2tzja1b/lheEMrrzo9nStdBMXX9b76AM5hvDibO2w\nFtwkxPpWFrgtS78PRHn/rxqc/nKm5Tlz+0RUa2UnljMnH0OePbJ1m1hABmtA\nVpbKNh4M3XdsxS1LvWpAojdOsD8Sg3Heoni006sTa5ady03LUemT21XMczjx\nEX1L\r\n=iHCo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.17","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bc4cfca-1607421291219_1607421352949_0.8343656135823649","host":"s3://npm-registry-packages"}},"1.0.0-canary-496d087-1607461191397":{"name":"@iadvize-oss/store","version":"1.0.0-canary-496d087-1607461191397","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-496d087-1607461191397","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8a852449867d456ebd5a317442f793c10cfffb83","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-496d087-1607461191397.tgz","fileCount":7,"integrity":"sha512-zks0i1MiG/jM7pqj92ICM2WeOlkMYm126x5Ng355VQ+xa/2TQNH2yd6TnXv1oMySoxZbvS5LqFtrCr4s+Z1+Xw==","signatures":[{"sig":"MEYCIQDCkkT9fP1rzJMyUz1hT/RTUi2WbPK9VqyeNE1SHuvz4QIhAPT9GNL0AJwYv/MIY8yQmVVTSOk3D8w2/MH0TdvBf8jn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz+l1CRA9TVsSAnZWagAAkT8P/i3T27YhNqfcXLfqoesM\nWbGRxU72IU0bzSaKDzZCeV+FqWJZG6MRiR3qzjXsMpV9tqOp4oxR9rmcnOEb\n1/ogYfCMMxnHH3nxIZhP+Erdo7svrUOmr1cwx1mloFs0KOwX3cZuEEYz3SNk\nuQfPF9zO8yRNm63uoDpCJ+rUJ45avz2onaiMppW1JSuqr4bYh9qRLI0Df879\nhdHoghP3UTIRVCxIp4AaGsnmES0pODHnj3AvKUA71hCkiRj7z0fLaZQxEsWe\nG/BJdGaL1l0gB3ELWZE4X71iKE9NlGgz7VvctdOsnIc3tw6Ss4tnoTsAGylX\njQxcSUKovyix5SHRyuJy1pLxVFXd4xXy9cvves/zQ6DNGsC9IYT71WkAwZFj\n58dzYOiJm7PGKr+kzCwpMjL84y9bz9w7YWJW5M8mxjmcPSFj2Kqvkk1sm9Pi\n1lSh1UY/tud0DY4RNDSD6biEcTjbJxHgoiYn3dJyeYFr/25E0EvZRbrXiKQ1\nSpoK/DLt/xmlP6p0eOAis/svYT+Y5Sn58w+OPpOJdSwaH3SgewHikScGyOB9\nhhJAgSY1g0xenceu60RxOIgdwNvmWu10xhReNdvvSK0Fsu904dryy2lxVl7y\nUfWq+TONphkXfwPmBso7TUdfYIsgGUKkXwIeRyhOxu4ALsXjayIkPnHNle9I\nsVWf\r\n=t8U8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.18","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-496d087-1607461191397_1607461236970_0.33149172218264233","host":"s3://npm-registry-packages"}},"1.0.0-canary-496d087-1607461191330":{"name":"@iadvize-oss/store","version":"1.0.0-canary-496d087-1607461191330","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-496d087-1607461191330","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"da0527e32499ba9223c76a8e4fc9f74283dbfd10","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-496d087-1607461191330.tgz","fileCount":7,"integrity":"sha512-TJui8H2hoqI8CmioDRW2h5TEc773/kyiUOFo/SPc7S1uhpXain5oS75PQFYURJ2GtgJn8nPXNH3yRNZ6kZeRAg==","signatures":[{"sig":"MEQCIA4NYDoVy2rc/PzhCJghPvA8FABVTlR1Or1wJq5mTAxuAiAzcPjpFkVUGN3KrtcB2DlUAjz/Amr6KT+3DSipwuRKXQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz+mBCRA9TVsSAnZWagAAz+kP/3RcCi3xr8zcqf3q7IP4\nYrdJB3qJQOVuU6l4iHyYDNmdwZpWGK3nI21IPMWbL2eGl759WNQyj8x/AkOl\nEuS05nnvslspudjo33GbZoX2ykThGD1O6LuFMbtu6TbNGJwlF5YgALdz36pJ\ngGuts681TnjFYuhWtmte2Y+uf3OmvJnkJrqbIhGf5/04Gu6xrsNlmiUPRnVF\nTZjKA8cWAY7krnlpDtpe6PfqN0Tz87p3RPILzD5FiZ1eDkgYfhzsYa7uRKIF\nIXAlzpyAkDMi2JRX2T1Vmsjf/tFvJ5TRPFFi/Xtzr+r5B9njmTeTMj2a/B/k\nixXAlNvt5Gl66BRqTrHeNCzsA8YxqxFafBHI8ct0Hx9EgddgxIH9J+ybfq2M\nTBJYBmSUEVDel09pHkHLv5ec5iQAr+1JALMFf4H5WKF+zuQnc6lTTP6YkT45\nNAxpFIhSAKxCe0DOgbiL79oIfBqPf5KOIQ/yEDH4XmgmVtaX+69/oJVyZtEW\nMnlrhEv2nfwK+BjBl2W3+jMPbzLYheX6oT2k5yTlbK1iqLa3rNz8cdxwazgd\nyzj6hKSj/D0Y3nCCsIxvQAHWj3ITPNlZ7ocF06Jamafl0UxQoFywLhQrShsS\nhGkK47uTMIDM/j8ngZJhufjKU7gVvhRMuDfahK1tgodau60KvQnYMaurj21y\nApsF\r\n=Qlv7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.18","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-496d087-1607461191330_1607461248898_0.2512774916911753","host":"s3://npm-registry-packages"}},"1.0.0-canary-6f52564-1607640030795":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6f52564-1607640030795","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6f52564-1607640030795","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"aa402207f2205046267611114ca2709239784507","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6f52564-1607640030795.tgz","fileCount":7,"integrity":"sha512-3MpXUqUM86Lcj7HFxkWqDkuvrCybtDED3WzUAXBsUtZywUV+5HmY4+Zjbx+jAnSm0XbkmSwQUiDJhTvU55akiQ==","signatures":[{"sig":"MEUCIEedGZMtSELvlFOwpqrAxBpIG3BS6kKgBJarHltYwbn0AiEA99AAGBTABsaXAopz2WOu7wUDkJDvb/ZKgq4zDtbi4OA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0qQVCRA9TVsSAnZWagAAH6cP/29cVIE5LQsEjP5qDEAq\nhgVoR6IlfU+cE9lFcA2jqFdXa2Q2hpvN3c5blCiSvZm1W3QH3aWxcpd1V7wi\nPWtQ06Lj6ymc7fbVXPTUMvY6EGGDbWJchjd7oxT6fsvs/fAipnM77d6PJO2Q\nEA01w9IpG24vlmu826NFlS5v2TmM9aRuojFI8KXfwRpCVBKECcRM+rHPZ4K5\nvTUKLdOjQ9ClRwEeTj217iK5pti8sENAme6unaIbVxKS223HL5y3ilwA0QAO\n8vS1gw3EfCyUmQC7bztVn7+71AJl9VYVtAHguyRkSrQi5foNgazEqb1CQzCc\ndujCm/ivN+Bh7wfRjaYFk9RHSTXV576NndAafvbKR8DL3OY9Wk718p92vdXq\nNyUSO51oawiWMQaSRGDnKBPzWmNafK8Y1Jzw0I+X68GcAysK3/Irocc+gdRk\nDeFIRHZlWXwGyM8BWN/kuGXKQiHoeKaXEk4yPzxW0FGKqsplK4PB/LoQP4oX\nE91iur2hV8ckoYYFe6cYuuwzngZyF7icDmfy5ywKXo+noRvJgxBS2cVTfJ3s\nZTelsq/jYmBnhoWhmifuN6/Bwl+Nb5zz8uT9s7IDtHdXeM3EY4W5G8/hnvWR\nPUalKYAock7F3Z9RVtNbz+Qw8rZfWJdo8/kE86dr1ourB4HRUvy6LybRarmy\nnnrQ\r\n=KRPn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6f52564-1607640030795_1607640085431_0.6760174615657037","host":"s3://npm-registry-packages"}},"1.0.0-canary-6f52564-1607640035089":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6f52564-1607640035089","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6f52564-1607640035089","maintainers":[{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"pagury","email":"pagury@live.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fd304feee3c594e4456ee97dff2a4268b6681a5f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6f52564-1607640035089.tgz","fileCount":7,"integrity":"sha512-qzVVUHPxECFAZ8/wTdVTisaFu3P/+PRfUqlT2qUsf08UorEUtqQNfeUFaKVrYGkrMbPGZzyVtl3gVskmJUAZEQ==","signatures":[{"sig":"MEQCICGhhaNnWu7+e456jeO5RlXiZKcLRWH/c1u1EeakIL4OAiA0J/vRolgtR9pr2CMGxwpwHVV6dJArlhGqRNHv677FqQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0qQgCRA9TVsSAnZWagAAUTcP/R6b2YFx7VrS8GIt4XKQ\ne7cYg7czfXNAifKTOHWJABAXNAKKaVqpxaavYtIGvdbZzUeHodW/c2AW2Bef\nRUEAkcGahojLV47hfiz5vHXPL6c9i8bd4nmiL5h4CMmWlpmjGzZcIUi9yiLJ\nIpz3SUQ8uhHVqLtsUD5Qbx9PGtzKEOh4xmLMYH5Jz1qCQaVKyLyW1c3LmVDl\nD41e50vvcm3GxXJXbjDdnSSfFoomu/KPbLJJg7LUu5HKvPGKUPd8IMzTzUcE\nOXZEYOJgw5ofRTp/YvMMnCTOOUa8RLi7LBxwzI6TVDrNmfbs6mO5Ov7mjp7J\nVOht2NRiXTp6/8pk9IGt6lsLR4qrpGOlN+yh7WSlZngP9mKe6+N/0SgVchQu\n15PWqNv92BpE5hhYy870XIcTPDe8GfiO/c6zgM2+TOpoCWoIx82xw//gdSCp\no/tOrGrt7+BFOl8bnaWlsehtSSzs9NlEK6OZvjm05n4o2IlyB5mNVUBOmYgI\npMDH9/3fP4TNxef4k0vZI5vQz9yQTlXBK9bMp0R97j9cKEBtn2G610iGvo7U\noTFnIQ7yrvc7Sc1EXCiIJJbqt4FnOw34xXm/bEjSNOLlSpXUW/CWTBdodFHg\n3YLYnPd66WD1eczENmI+a4I4P+Gd8OJQv2M9cxXz/exCoHLxn7qsqvdEbNEe\nDjA+\r\n=0Ojc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.34.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6f52564-1607640035089_1607640095937_0.839930771189211","host":"s3://npm-registry-packages"}},"1.0.0-canary-97fc170-1607945148568":{"name":"@iadvize-oss/store","version":"1.0.0-canary-97fc170-1607945148568","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-97fc170-1607945148568","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e6ebd185e8a34b54077f6b57114a774b1e0d717c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-97fc170-1607945148568.tgz","fileCount":7,"integrity":"sha512-5Cw0IqRnxkX3ddmEoKmjWOissjewdlyR+FFcPh6l1+Tg3Uj7IrMtuPb9kjGDjmw8o7+t66k3IOwZaVip16wxPQ==","signatures":[{"sig":"MEYCIQCBPzI+ld9mU8QYdlt0OvaeAwqYeGS8is0eJiKn/WyJ0wIhAOoj4/Dnoa+R5PbXTc0SaejW/SJxMu8e6wRWwpv+soTu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf10voCRA9TVsSAnZWagAAsqIQAJHUQ63n93H8SP8u1OES\nb1NWnQxetIQwHAMWrKl8kWSYmtd3gBGLJNc1sbj/KjCRQa2ake7g/MRBoWGB\nuaqR61Nx2uLbCGgj0Zf7qi3Z/hzQIWEkeHl8Dr/aA1kR2T+ntkhR5dr5EobL\nqKFzKtHdWqnG0FOJNH42s6JZKqNMvbXT/6qiBpHmVQIl/sxF9Y76qTnyg+qU\n5z5O9RCewGYhAdeRdcbjmTlsgZHeXzYcZeI1rdj/lH+rBnVlFmJhw36vt70q\nsKFmqRUuZURsY3uSeH6DXpOMyS2lRDfuQRMHul+R0q7StOGnJuJlyPlGbFnW\nR03DiYodgpIK2jyQhTyg9WwR+XfgI+jTWqU8Sw1lJqkELOShzdQqPET92DLH\nltpZAjsubJIhX31CkNn3R5GmP2tkFnq+EbTEVl7D7cDvC1KUaBdMIw0yyGg0\nAhno73Ntaplw5bhtwOQJQZ3oLsJqWVhi8eIrUCcOFu17k6t6fVSkQh62Hr1t\nSTzSbWjY0PFgTjuYlhXfI3k99LvJophIoTwb5BpvViWycRR+L/CzfDBmEP48\nfssq4UQA3slSt3mPgdM8wcLo+aIteVJcwMnQ83k142rSErXN581vNQKFxAJc\noyqs9KLeRk9ijWj6xDu0/wh8e/kcVTyTsRSmkd539P9F8eow3usgyf35/LIn\nr3dF\r\n=jD0M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.35.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-97fc170-1607945148568_1607945191551_0.33686795479517073","host":"s3://npm-registry-packages"}},"1.0.0-canary-97fc170-1607945149539":{"name":"@iadvize-oss/store","version":"1.0.0-canary-97fc170-1607945149539","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-97fc170-1607945149539","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bac1a72870443fc69482206fe67ebd1a161ed16f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-97fc170-1607945149539.tgz","fileCount":7,"integrity":"sha512-thdefAn6ejgZ51ttNtqW9Qh5Zq6zMgTwfWk/0etlrKZxspDNqUEIBYq+0iNFUsnuXp+KpBbv5gbl2w35McYCMg==","signatures":[{"sig":"MEUCIQCcUhMQApVBiGddJnTCzTTG7D5RVPTJ0uR95OnQOEzF/gIgfl5d4laJZnyexmpV6TdUG9xNQSM59DdHFGb3wYcuNjs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf10vtCRA9TVsSAnZWagAAiZIQAKCYsakT/BrvQNrzFbKj\nZhQfR+VVRmuELukmmp5xBKm6ZecmFq+48fY5g95IP3msjEDMEfX5TxFdMP+q\nfNTEiTVQ2JJPGtJ7W7e4x/AA7bEvyEtS38VyX3spC/95pwv8f1VC3/ji2H/5\nU1mtXAGU7gKtP8UPwmOkbm1/J0fcmxYGZt8+cWTB/6VdOoFczU6fGlN81isp\nxRmwSkd8lFa+jsAFobPnkPY0bK4pndGhO8hXKapaaCFbMrUir86TfFtbdDcb\ndrNGWEUSokyxuvnrBZo4gpt8TyDIGoYi/lnf2uzKCxzZzZo3P16v6Hutcq5s\nrDOQ4jA+ZPOq7Iy/SEZeQ1kpW8LTLt46q67AZAaheKeqc8g3FfAKDDAtxMXk\n0UtC9knnvMxoOfVDL6OX4guD4XgVCRDp0PeMB0SW61I0BUkmMmioklIjfh+x\ntH9gnbxqvvAvY/BNSreHY5DPJYJMhew4PRowgyZoqkjjtwm8oiqR850ns4K8\n/e5BN54XCPtzh63jWPRqVDMAF5tWQ/yYwxCOwFmHgUX9ekxE4f30fZ/hxU28\njrDqyiMg3mmLrxs1dDrj8hSJIDvtNmXcZqBB7/Am6lip4g7udMwRrV482Hdw\nZ+6qjR1HrcRrh0GDyEqem1SkSXMHKXjXKPe7MOR2MJMFwf5Zly7b3Ldwv4Vd\ncnoM\r\n=pHBA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.35.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-97fc170-1607945149539_1607945197009_0.8870190342226449","host":"s3://npm-registry-packages"}},"1.0.0-canary-905f286-1607957930160":{"name":"@iadvize-oss/store","version":"1.0.0-canary-905f286-1607957930160","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-905f286-1607957930160","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4126b059b12e6f7dfad9575b2b494598f2ea2b9e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-905f286-1607957930160.tgz","fileCount":7,"integrity":"sha512-Nw/JAck3Ew9r4E3WcCd7pHav+5cFb+3fhbgEqNy5CgVcB41i2j8CXoORpH1po+WgkjFPeZgvuzvYe8nzC+40Hw==","signatures":[{"sig":"MEYCIQDAxC+/+tBum5r+Z9isdi8evDm2/oHw3Phw9qx3NfTJkQIhANjcdmzV//No+mPOrXjuulHoip+XqZN5fbRJX+FrKyak","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf133XCRA9TVsSAnZWagAAcioP/3fK2Xj3C3VGpOw+l0/w\nn9+wOMv1SxE35r3tP7Xepz1mVuncLQZa/HoH6jOX7DpzhB69Zm1zcs7sD7ds\nFytxhyXqSjQoaq3EEFty5TIg1Zn7PtrAY4KEs7yJ71lPvoxExenIAzRr21iX\nD0nehCueYK4EIa3ZA0PECHhS9vy73MuIfcyTumO4OalZjbTfHnNoxkIy4em/\nCOBvLArj2lvsws65tYZoAicmamiu/cmbg3Zoiep0mMa8yILYBk7M6i7EK9Ss\nEJpbJsK74od3zAMW1Sv3QaNwmN1xD1J2TZzumPYXIReTZNowAet3w+3TsR7G\nLDJWm7lOdk8Z5A6W73Bf5FDJtit59yxP+hM9Jda2X1+4UnJpZ5V3Bh/GsKzH\nob9j1wIEy2Y3n4OkN16e0RS7jqAmYE/ROMQVpDr8U1MFFTOr36LGlV0gA1oF\nhyUZf/sDqYPAp9q/um5tZbzYjpwaGtFp8AflBRLsk5wUYDrxIIBxzXMBFLg7\nGsH/bkl4bYubiZAGprFgfKL8NB5JyuNewiuGXFOax05fmHFLWC8BdVed2C1h\nmsK49JRv0bTX1QCxY3IJQNg2cXFK06zY0fvIRh0hLdGEwCXaYr8jjp/8invJ\nNOARkEAUW5w5H50fHeTCo+CexQMKVP4WqqRQLnuyir62AWfwPK3OEjyUaEHr\ng/I4\r\n=gt6t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-905f286-1607957930160_1607957975289_0.5671577844490698","host":"s3://npm-registry-packages"}},"1.0.0-canary-bdfdef3-1608328935551":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bdfdef3-1608328935551","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bdfdef3-1608328935551","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5d8cf0785189bc945b541a7e5bce963255be9038","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bdfdef3-1608328935551.tgz","fileCount":7,"integrity":"sha512-BkykTjHa+eQDReum8bo25oa2/9GYe5taWmbPtblJoO5u4o+yXXPou1vQMr4OJfkSdFUBqA4DKmPPc/T7mo2nUw==","signatures":[{"sig":"MEYCIQC9nm3pf0ydJt4jHG0mMy/9Qyz3WAqXW+X4CtmoCoIB2wIhAJor4ADtwILMv8tQQCRQvd2g+bLr2CoBzQtmXO1SGgf4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3ScnCRA9TVsSAnZWagAAIwwQAIh4qRnQiEALLKyn1Rft\nYM8MTpgXWFU7oChMqUJNRUbfpl5wiaH03jtn8mE6tMG/arpOsklnK+5JLDPT\n86J7YP+KSDrOoIe05Oqa1dWOHqe4/jSVXFecWZ/UjJQR4yOIuUpU+F4WIwd0\n+MK/v2WyyzsaftBZNq2HNMXSnP/L0YWVmi1StlJUhblBfkMi050QTqHZmKep\n+hpqgOw+x+jNTUsCvakwcgiIbD7gqmglwd3FGioNpJ98t5xw5M68FZQiKmBV\nAvDLiKcFJXsa8MSn6y0VjzesFRPV1fvUYNSsFBCfDMnGy8KOyPdCqeJAlSA/\n5r4nZnvZ4O0JQqRUs5KezLkaEizMQYxBjXCKNIyKStkyHWj95zkrMc/B18di\nowKfJxoGZWa5jYd0dZnVKdAG1kdcrXORYLKcKZaFkRdIwMCgtWlSmNf8f3l8\n4V9xtwPQrZT/7e0QR24j5vpcR/7Xk4p38ZL9PS5ISEC2bC7RFoTEhv+W66M7\n/GagDs9XIKbutDeuLTj8ldcS/C2ZaIW2qUlUhjCRLZBnSLzKdEBtLHcuXnjD\nmvH3K7iSu4zXhVGykSGlO1IF+/E7WfC3WPVk96Vzy04Ck3voqsOVpRkdSdPp\nf1L5BeOL+1u0H8zSxaJvkQXnNupAunJzRaDlaoaMHDbLcg5OTyGEDpAwx/L2\newFx\r\n=EoHe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bdfdef3-1608328935551_1608328999266_0.6296901767741656","host":"s3://npm-registry-packages"}},"1.0.0-canary-bdfdef3-1608328947246":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bdfdef3-1608328947246","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bdfdef3-1608328947246","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"60a2fa93a1fd36d02eedf5bc5a536cd6ba701f86","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bdfdef3-1608328947246.tgz","fileCount":7,"integrity":"sha512-VaE8xLetXVSKnP72xCnaP+Nr9AQYv1dIjNu34+OCt71JMto6cbBlv9KQY+mR9DCh+HPkWQR73FJ4ciXYZMpxjg==","signatures":[{"sig":"MEQCIBpbFntzXkZt5n2as2IHscu1+alvg/huZrLy0Jhmq2ifAiAgdVKHiUgaHzXfhQMqOc8+UBq1K7yEyiDWhH7SGwgDxw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3ScxCRA9TVsSAnZWagAAWYUP/0idzUrOdQE/aEqDgsyb\n704fne0lLw1XgQNztcnVhzkbdriCFQQK0hADUhednMpxxyY0VEFEY8s6liec\nXRNwKKzskP8gPbD9GaoMN/XLwsWfH0Twbn9pE7BFax0AV1KWocmw3Y5l2p/a\nxdC23cQFhn0/FYlh33OtZapGwlXLVZlLrwOoKjBBmlmpW1pPq5B8z/C9aPhb\nGGx/R/11b2ayBzg7XvCKX5y/SMO9Gv5Cgt0mhBQPpL6jndShWmg7HyH/qxUb\nNuIM8X5ueZrYAKMlgD5zE+rA4LIgx+zo+Dd3zw+2rgSXmdLEmDeDmZ7e1KxV\nIq6xRF8i6VUrsD4eJSJtNQFYRzPdR/n1r3KGcVPAlNrmjuG6eTfIMgT5KLC6\n0SGefScvKHkDs446QAy/+OEXvT4tmC6nuDj+Zo8P+Q+ScY+AZ1ztSN/AL8vw\nt8OpY3sBswu38dneZDADCreoMO2Fj+VmXsJsVLuSAIh6ml/RwoNd3OoNdizF\nOI0kf8qzxzFZZ4pHLuEAO9pdP8p9EvOzrP3Zm+5eKzssbI0PCvsc8KUvNwSZ\nyrxObCk4/sfW5UDn1diWV5XmyHKeIPBCNIRCd8u8xLtfLUt52+QsH/Vzif0d\nyrqfgDJ0ewKW9DHqcJBDl8gctvqcu914h+kRBklfYTJUceVFlXynh3VXJiwG\n0Bwp\r\n=ox3V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bdfdef3-1608328947246_1608329009370_0.029346018285313358","host":"s3://npm-registry-packages"}},"1.0.0-canary-3cf6f45-1608506047799":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3cf6f45-1608506047799","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3cf6f45-1608506047799","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39f7fd89a3a8c9c812c2e5faad0f6b8c7b4eb977","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3cf6f45-1608506047799.tgz","fileCount":7,"integrity":"sha512-iYrYebfeVxIWu8XZEM7k2sqe2Wf26OJO0dq0ppGNtkkc6ewVEtMQPYgT6t+X4Aio80jsc2VVyFTLeraQuTW4Fw==","signatures":[{"sig":"MEQCICV7hyXlDgsvOgUf/EAnBmEyYOAmG2Q2DDen2mLRgsLFAiAaIOtS1khu29RglQFaZo4MYFU4Ps64nXi/9ZmXSom6eA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf39r0CRA9TVsSAnZWagAAOs8P/io0HKPoYK+6awcwWUSN\nu1MRuICUYFJgxLr6AjhT87CTqIq7mmfbs3CuktA0fZEYkfwE7nkL7k3jytj3\niI6GuNQ4fWYc+dQ35Cqv80FhIgOVMqp5I5Uj0ue+sw/zbIxctpA6br7BXCQR\ntFf6M4UKu44fqG0bH0D/0crAEfXPtNhfkssqi5C+xJekDoxBp3qgmEsHnz4j\n0i2dESfFj7jponFKY57bjCHEP6MxTLipmUaI3D4n8OyUx8thQ9MNh0mlwDLj\n7RWcfryH0ztsNG2ZLb23GPgfGcz+Cfu0NFoyEJOcDDv5WJYEBl6kzoiUv+xq\nyMOerQ1oOVjyMoTk2poiuS7+XJfsrtVFe8gajnxt+pF0zMyX9RdHt3QxMOiP\n7Zd2+sSvZvaxDMQt3hjmWYoMkidD7Sl8QK2ZUM7iqt7WU8tcy/OVi9fENpB7\nEa9PETUHEyN0Hts3Fx9uM+k1E63I7b95wQ9H6XTrkKB2bJDjfOq2wO1sJOZN\nJLnsSvXGAXnUAgYeBaKVhcV2OI7VTh9g+DqyUqpLPOnSlRJQ9CqBlHREgM1I\n9u8cGDto8twrfmE9dgT1IDKO67Vib8yIKsaz6R0/Bn88x0QX6ACpzmbVFz4Y\nsc9dpHbxqXVPq1/1ZM/3rxr//z3vJadxstbVJh04UzI0P9rGSoff4M/+BExL\nteT0\r\n=9CaD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3cf6f45-1608506047799_1608506099952_0.8483585691627842","host":"s3://npm-registry-packages"}},"1.0.0-canary-6a3dbd0-1608570240923":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6a3dbd0-1608570240923","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6a3dbd0-1608570240923","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f05eda19b5117faf0d850a8fff15776e0c650524","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6a3dbd0-1608570240923.tgz","fileCount":7,"integrity":"sha512-43IEjIsdEh1P2loEoPw89EbqETREkInAqUL0c/jdN2vy+/+TWF/dK5o4HgZX1jSIXpodznhx8kzGlZJpZJ/0Pg==","signatures":[{"sig":"MEUCIQDda1sTIeS8Q17ZPKA47UfO6i8cqwX/SGeGnArA9CPqIAIgKVCJjtc4rw5j/EhxJI4qDYPSRBCivVXMSIv2CGGFgDA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4NWyCRA9TVsSAnZWagAANVgQAI9Dp0fl2hqhFse6FnnH\ne8+8SIANtDCkVo6id1wx7eoAz/Gyi6zXaKfojSKkrTHyefy3M5WboYSNiUr1\nJpV9N+zi6NNxcud2NIy79YiaueGAOXfgST35EKBVHIxMge0kE8ETvxzEGLM6\ng21fKD6+1MsXPTdjcOp8Hvcz2L95QnO0nakTqqeMupAHb1z64dv3rC6LfthG\njbDytllEgyuW11USWPA0BHgw0c6cykpzfDzpupnzropoSOk8cDKmj5FUyMlF\nailSYHkPZIsuc5khpTvG1TyeSgIRJ8TFQwYHnEYCi66AVx5hs9ava0soMkKK\nRH2lFGTfyLJ6n7RUJIi/Zak1JiaPKYDBwxm8Mv9crq7bFMNetsYIk8gI8PJZ\nDFKr8Q9WP7LsWLKSDK0HLMSWteXiVjAedox9BB+VpOaOp9BPl8cRtiLWvVh0\n86fn+rJJtpmI3e5zMAZwkOEVxcVwD7yHEqyAEoveNclFRRIAYDwnUbNM8CSp\n7mf58uicKy1Id7aj3WMLM8DkF2LsbU4F7eFbq0FOSGMQ9uymc7PSwJ3dQF1N\nA/+LC8Gz5gKZrFggaBFD7jHCdntb55M14pkUj8dxmYeQZD8dhFpl4F+qB3zH\n7efKQyVyuGmxz1aXeF+PW93kJfXFCPfKtwrHKQXgsltXiqPKHng27IqTMTbv\nMZbw\r\n=sw/k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6a3dbd0-1608570240923_1608570290346_0.987062616596803","host":"s3://npm-registry-packages"}},"1.0.0-canary-6a3dbd0-1608570240342":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6a3dbd0-1608570240342","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6a3dbd0-1608570240342","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"073b45f8db30621cdf58690cd2948999bd943d56","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6a3dbd0-1608570240342.tgz","fileCount":7,"integrity":"sha512-8vP+DbBlClTEbFButgWP04quq6AU/zUgiZo8LPRDgtSBjEcrIixnxmJWeLq7kZReOZnJQweXjrWm+RnFvJsYhQ==","signatures":[{"sig":"MEUCIQC/hJsWnG1mrzjji3N6B54j32SLO8q8kw/Fsgk7r+s/0gIgYNR7dQvzARHB8XXHTHOGmXQL/nMjINc+lpocVUerEBM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4NW4CRA9TVsSAnZWagAA5JcP/RyoOckke/OHAWKhSTvi\ngEcQT0fIgbqMdjPZhh+b8EZgGvQarbU9krWFHr2qd1cIPYgAXsU0xabTyh6D\njTFYG0+f/fS0Jf6JCM6EeuXatm5PQ4F1tmrq7vg5meqBShKJyyzEvEuTxK/q\nZls6x7Y5PJXVj1AEeQkOqnEIt7UglFDJRS5xgFJ3TFaLwu9v0dLMgMRgRmES\nHknjE43bf+VEWpzTIxUWlji65oGFCfxEVe12N1I23lsM7atnJzvylz7G7RP2\nUCmGjEOoJOUSeAvDDYC/nu9Wl6sv0bR1XDTXxage+V7ZamP9IwM+V6EiTPS7\nnXWNx763OMb07DHRSrP2nsv18txWTgMe5FwP3SGbszJjoOcdjme3e83RrlmA\nM6UB6y3TqfNdf24lAF5hQP/ydFK6DwKAJQyFHB0S4xF0FvHpP9ZnSmOQef2o\n55JbM3jXaTYAuqX9dlx5bckiBriYisIjWpbWeSLfgLPsRGes3d019hMZW6l8\nuIGGDpqLNlYJht4xjRhCodesWdlg0lv/g2vjl6jfsrfi/Aw8+qrV0cVZK9If\nNFoz1wCTFN0w2MBgGE0c5xBuyTUDdAornLmu3SRwRntl7d5NYekXXbg4CNeQ\nuafd7SWW/dAXladMb8zM/ONT7b1UVh0PA2u8Vn2Iw4t7oxWH1ITM1B0BnLvO\n5o/x\r\n=O5Bq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.15.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6a3dbd0-1608570240342_1608570295611_0.12538689319857","host":"s3://npm-registry-packages"}},"1.0.0-canary-ca2ec15-1608592601058":{"name":"@iadvize-oss/store","version":"1.0.0-canary-ca2ec15-1608592601058","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-ca2ec15-1608592601058","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9fd79c528d0c55bf051ece81b2316b41297a41c3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-ca2ec15-1608592601058.tgz","fileCount":7,"integrity":"sha512-47NYk/K711u3gTwp45no2IqCvQc2AoJMI1e067iIFmOQvMD8kLIdfEKWGa196Pww4iv6uUCiwSRqlKvEx/Df5g==","signatures":[{"sig":"MEUCIE7tGtlQI0/zrtAPNv3cgb98Uoe6/RQ2lZsjeRuCs3BqAiEAgXyvp/76pJyt4K7m5aq3AeFE96kEnlhcp3F71a7tJCM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4S0ECRA9TVsSAnZWagAA9lwP/jgVhwptWIx+mOKU+tE+\ngY40USHeMrpJQy2JOTdR5aapQPU2gUjXb01ju83USYOTvCcgLKdqk7JWY769\nQK5FdkXvZMOK9pcbLnzASBXFGC5LVOaPdYKHHw11X82f8Q5sfoj26Y9XYmcf\nmV+pN+X9T+vdbThJRvwnvFSb/x98VKZC5U6I3BJtv78Vsp81qY7Bf+Awugsm\npWyOxWywFaz6nk2DQflJUdL24kDnVyiKBOZUg7WeAH4CfMd6RjJevWLj+aI+\n4KEBTWcBlFSdAYYMaQV5Zb0yQawr8KmNjMaxv6LLlyx4h+P8YbfPHDd1DnMw\ngXG2v4KhyvhziTz3CvXPu7jOVjmqryLY0V8H79/ptbYaMw3nMFb/lE5fM9Ie\nU+XppaQCp58g+XZAHHOpZPXRqcilSnFCa5RmoNREmOFHDrHu3rvduCOVAFqy\nqQbeqht7iS0cCqRM1h8t7xjd9ZxyFWmDuzAQcHTpRsAKO/4odW6CuA7WRZba\nONOvGIcqMB4hBXatZ3A6f3ZEGxeon0h4NIImIePI+wlxVkYbB/tBytM3QNBz\nB6yvdu1sh467b6gMvD3vbQVSPK7oR17n99B80MOkRpHmJae7GPtUUr7yAluO\ntvh3mY1QIn/ibuIHGx6EO5HOD0A60wWIDQ9pdg61Tk3VM+qEiFZlmFe991ug\ndDDl\r\n=SN6F\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-ca2ec15-1608592601058_1608592643921_0.06325387309364472","host":"s3://npm-registry-packages"}},"1.0.0-canary-9d7c67c-1608765293684":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9d7c67c-1608765293684","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9d7c67c-1608765293684","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f2dabd62634a1f9a5246813ba6cd7ccfe0278fd0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9d7c67c-1608765293684.tgz","fileCount":7,"integrity":"sha512-3Nf5uNh6ziyDfiyeev+iCQ4JNLcZRCT9w4kT7pes1IwQK6eImpygX91tqzmOXhGoInWd16DO3ClWXMoHTuMevQ==","signatures":[{"sig":"MEQCIGUKPagu3GGTodemX0UOokTdgzv8il9hRdECU1FwJiG2AiA2ILi4oV4uh1bJDdjaIKm0zFEH1RpxIbRboXZCV6s7hg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf48+eCRA9TVsSAnZWagAAWmUP+QCY78PbzEvcugpTdioy\nRnLIt6CQXTj7kvhYKf8UaEWb3SQ+OrNV5xv+0EZi4jbcwp4JpeSJreGGzMSI\ndyvbotHiW/kx8qOu947H8bsacj3lfu8qUOKTRwTHZuci+WflCioWu/zCNL1l\nmCCwj+APMbCtZGLuJsEZyd5+VBP2MRb1Lnfu3o5Ktt/cKXnIeKBoj0jtN1ru\nr7xcXkSujKFUYL4p2/29h2LEhpc2ckGGr8dDOrUTrdio+nup5cWRFcPn9gxh\nvxTEbKa6r3XY1jrxrhRRY0pILpo/2Kst8dAU0tECnzD/e5aahVf1ExhxpBPu\nC4qbQNx6KjwX0Nkm/9WYMjYoD9VKpYnI544Kt3TLNJtpYO1LGYwyfcPdDGhN\nQnQzkxy8X3qRInqp0EHCfYLwA03K5vI1UeBJ9+6VMOgZx+ObJ0n20QUsJ8zt\ntPFeDQkCAa4QyHXkMWb0TpVGAMI6HUtD8B8WMJuZZmdrtIx+9LPtk1IymFPH\nMaNhqNBD0yB4HSzqe5e/1HFUYpeJuc8OLyLA+2+JsaYMqxOtap26nNTIggTJ\nV9zwrb13S69Wtv8ANDZYF9rpMQwykZdne8pVKYxG3hsDjLQKhfoafdOGul82\n1SJAgkzZt3XZcA29U1eR4XWyvTM4VxWKdzHOHwtaHKKj9a6ePJQwfT5DhT0y\nVi0R\r\n=XQav\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9d7c67c-1608765293684_1608765341621_0.9852762652461986","host":"s3://npm-registry-packages"}},"1.0.0-canary-c22ce68-1609181445796":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c22ce68-1609181445796","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c22ce68-1609181445796","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5d9acc2fe81623afbfc0629454e5ae80be5180a8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c22ce68-1609181445796.tgz","fileCount":7,"integrity":"sha512-pm/tP6j/0Jc1uCCS+yum61gf9U418vYHeVX9+ZdTSgkbfbBnDJDl4ro0Fbl2g/a+/QN2OnGwGjJ1s8/XKdfZYQ==","signatures":[{"sig":"MEQCICKXUf6uyPo8DzjArwkJfln6Vs8djrsjatnytnVr7gKrAiBUKqTqgu9UZJ8JF+neWVkymJePfqjQb9RbJ/xxy4keTw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6ikwCRA9TVsSAnZWagAAjTEQAIFhpCx9/5jwvcMZH63m\nbT6nHp+jN2WrlJE68MPnZ4BmDFGxn4aRqnwOgLGsV5bZ3SPu3UfqjgAKghgo\n2RLbkxkM+OHm0qdDgaJhOjuFV8aOh2l4neJtbq8f9i+6T9TIRB8eftXSEBPd\nX/IQr3kSq+P4JnOaAQoUUq3atGVEvJA2Ln5dHx3hS6mMKNmybmbtfVXJk+hj\nbGg5v9Bs8eDe7wuLkbzhd/VjAKYbu6Xm68K3W9rI9fwUglYQ6804kBtcFG5i\nWswEFmL3NABkVObDyKM3elF3W9BEZfg3bmTibhXjeL+kJZq4kRLrReYew+Wi\nL73IlDVh8mnzD9/lR6Zx+nGyxFQOMWJ0ztgSGGsONiOMdyQHwar+iP+/ciq6\nf4OvM3Cl/II6KgG8JyH4wgzZ0/x8SB4WW3puJcYeIGPJD+5E7hOk96HAQyIx\nuIvYvD9sojCTjfi2C7WQZM2hyx2VqVmxT8yE0AR8KD3tPZt36PUGEZMF+Wpx\n5YbwLyU/yooAmipho0WXoj5N01/sV3JfrV4RiB2AHJC4Pj6TtPS0dVxUyaIG\nUxB6eJtAVPlnCk1ZzpocU0KDYOfO96HcQDJOqY7jUPUjSi5RedHx8G4fctQr\n8gHU8TstS0keZFbBQKciOzSckiIvGHKuhhu8NuiwZf6NxuVeD5ZFANQSM0Ts\n9y79\r\n=kTSk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.0","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c22ce68-1609181445796_1609181487685_0.5085059163141419","host":"s3://npm-registry-packages"}},"1.0.0-canary-c22ce68-1609181449264":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c22ce68-1609181449264","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c22ce68-1609181449264","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"07a237c8edfd16119d40970e8276327f8ff7b408","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c22ce68-1609181449264.tgz","fileCount":7,"integrity":"sha512-0o+g2J5evPqli73fAjwhYk9O7Y37U3aRlYLg49g9naDVJ5jmzj435+EIP4xBGfI4WUtQLSbs7EzKkvPPzauJhg==","signatures":[{"sig":"MEUCIBDX/hHf4TBnOOkr+S2TWsY5MOVq6F5hf0iwk8N3crHZAiEAwUHldF0/velCQgPH460KZDHJdxhIXZMo5ErlcfUkagQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6ik8CRA9TVsSAnZWagAA9jwP/j4AD3vuk5gpy+ytX2ob\nETVTKQJZUyRgRe312afHSEOxHqi8teQd/dlVkAZuZ7BYZwIAcKTlPk8bwO6y\nPKI3sEMQgaJMJdbLaVQf2v2lDGk+FB5zrsAs7dxC+z97DeuEheIRcg2aSEQU\n4M2gUmSfM5Dldo5PzR1LO1ODDr6KNFQSnMUK8eGH6kL58QPuJ1D1ZW9PKQmZ\nlDNCqLmEOaYvzr28oBl9aRHgvyciG0sD98jqMrCff/cD2Bla51eyR8lg+YYZ\nfvR7uuefiCwJYMrQndPy5n8vTx8ffiSzu1369dnKbfcW+GR6/3UmZ2hs6/jN\nXf3D9mylt44143jIztYRnCyC2/WoKgyZFniZIhjlp75Z7X6wx/TiQJV8AoDT\nJXRSKaunaKo2xWpX/4mdqL+4ytrpLC09P2njKreKM/+W/mNDqjoW4HqZ3/o6\nHUEx0jmWtpO0EUjcQw8C8NCY7hEcmZ25hLg1lMt9zFCS6HKXZOyD/G5ok2ds\nkK3PUEwNQQAq+/uK4oBWsGHphYHUTPyeKr7Wm0kgWsoalaEiAEuq4xOV/bex\nBt2kRIQYUFaRhzub4N8G2U+2KT1SM2+T20S1n/hRskvaHLTbkBd5ZEtnpjzF\nQ+2iwPvsiMzCqJeSGM30IFMDD8kgnb4cCN8vcVF7Qm8wbN5PoChtYv9rmyN6\n74aS\r\n=7r6u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.0","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c22ce68-1609181449264_1609181499792_0.5086133545272904","host":"s3://npm-registry-packages"}},"1.0.0-canary-4277c88-1609219419948":{"name":"@iadvize-oss/store","version":"1.0.0-canary-4277c88-1609219419948","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-4277c88-1609219419948","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"491b23ae74d37f87bdc47d21aed41c23f20667b8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-4277c88-1609219419948.tgz","fileCount":7,"integrity":"sha512-IZj0iR2PdCpPhcdJSGtnX+4ZTEMcJdkOmbAAuiKMZtXVW8OTM6q/lGK2aBFAEM82LJywpZKUSqOec3fYar8m5Q==","signatures":[{"sig":"MEQCICdIpPtyvgjFIxeAWRKf14t1gRa1DWaDUULx86BE2jfTAiAuDDW6vRYR97TNSZhm9/Qt2frgjWbsIxMF7Q7CnZbNCw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6r2GCRA9TVsSAnZWagAAtpwQAIOD0jnLx1BElU168Xh2\n8ex+eVi+6lybw0poOVoTzOUT/zcaqmfk2u84jqJVZRnKdvZemM9uTq8yFj4r\nQftZoUv4wNuHm5fAGAErH0en/EYvt8OAZYWsfelpZ5OhkcuUUCnp3v/C7PIG\nLmXpzNk0HSgv/29M+52uw4Ru/uMF7+cWVioEfzl8qBZci0fOF9T6w2qelqs2\n6G5TfaBn0xygrNJ+BlrThkkdxf0sYPzPYpaoNVfBJBGHOZnNOcaTSPQ9D/KN\nUIjNCVCTVzwPiPvp/5XCpck7ONxTH/W7zqSyRT10zws8wfDnUsOS/Wx5p6+5\ndPJ/v/awvxyg3BfR1vJ4xoHWFzfrthN2VeLJksD4AdjB2XIk8D7h5nfb3Zi9\nNwnrwc2ZG31lWv3TozWhWQSkGq0WTWDHQCxblHQ9eJMoMPhl5N1i5W6kupoD\nsqhprrqHz1PaSe+s54JeTtscgWp7Qu87bMRgbmdLdB9bFzehmtR6qBJ1jOee\n2eTfRchh7dAfCKEvZ8ZFvAGPy4IZYY6mX14nIxYofho5jAbC17qw66KS41gQ\nnTPt6VeiChGXgIFwDp2HIjMVYyFVzJFP+dMe5Qyv1QlUNcJsCrzA2n+2f8Qc\n4xwZen0RxNsTkr535PSCak4wMpo85dPaqhSp0SIb6M3PGDQbsXycZ+ePEdHm\n+L3L\r\n=EoCE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.1","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-4277c88-1609219419948_1609219462321_0.9579823603574869","host":"s3://npm-registry-packages"}},"1.0.0-canary-0e05c60-1609264777995":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0e05c60-1609264777995","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0e05c60-1609264777995","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b5a67273e8e4c6ce79dafc6c7cb55fbc09b59b57","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0e05c60-1609264777995.tgz","fileCount":7,"integrity":"sha512-m+b0OYZRvMFUAZWuhDrmmXo+NqTbHpL9ak81vXKfLsxnnuqAFQikJUYikybj4cQWIbdvwdgkjdH0J5vt9QWU3g==","signatures":[{"sig":"MEQCIAERsBM/QDnuNgDs5h2zzZ0BgRmPZHHWyFFwtTTwzvvNAiBxbA9WUXgKyOshX+60KQaJ4slmhYj2+RnrNb3U+DYuLg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf626/CRA9TVsSAnZWagAAUlkP/0J96Aj9EkmFe8aBXl1B\nwrR8BYYfe61ROhfXJJ21DHH1kJm0XRHbXOMW1tEIoSn81HkZ6xGC0j9wxtnl\nV29PRJoeqDDJSSO9HdABnLQebyUQeZoc0FZlNWShy/eH9sP/8DxC2vGJy7wg\nVarD3IB0t65pfcbdb2IqIXs+4oTf0gPB8XXUTX+xkJC6qpPy1Y9rPXYDYg20\nLTYIo5ylT2vYIPB61a3j19nVROcdbSuoxBi6tkHK1Q4EtBxsJAi1Sa7ywe8r\nFKeYZOEaw9kWUS18Krnlof9rXCNrnhrAa9m26EDzQCPeZCachz2dtTDs3D4k\nmxlvHg1+TyGKhjoISDoX93v3kx3jsZnlWlI0UcfRWfQgAt4ZowXppKaNF3Lw\n+xRm5LOFKubZcpSnUyjR4aGyV7U49CXhidZN8CCGt0RLCdjesc18hMFV5W8V\nNSVZhjCWxUiMamUSwCPwLsptDEbECf9xH4Sc/cHY92/xvpPKpjwK3m1oDdgF\nx2D8ibtKOpdFrkGVXtIcEzPp08W1cF1qKK6UwNbTRjqvc0EMa96A294vFGXD\nCdMIzUalaaZffKp/710Z6kR2D8mpi2LPpTV+47gn8ZFyjzda0gq0qB6HW9Wt\ne+5G4CXEYppsnSIocYBDBRGiav3RnCNbl6gmRhtLLbqksS8FxprQGtW+8Kb7\nrLEp\r\n=eDbu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0e05c60-1609264777995_1609264831227_0.01338688650465314","host":"s3://npm-registry-packages"}},"1.0.0-canary-0e05c60-1609264778879":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0e05c60-1609264778879","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0e05c60-1609264778879","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"716cc4c6b98c0edec35ea450c6699ca378287b76","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0e05c60-1609264778879.tgz","fileCount":7,"integrity":"sha512-E3qCkVfkiLDXSSZObo7eCZVE55hYz+t2Z9qVGznzlEEmVWmjxkfwUUdjNHlYccAP5MnOHyejR2XkbTRrtaFHWA==","signatures":[{"sig":"MEQCIDGfZMed+viXrQTp3dnymoYoXUh11sDPH9wZgWTEHWtbAiAlVL2W/bonPsnh8x2RvwaQcD048iPJ500c6VZOP8cm0g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf627HCRA9TVsSAnZWagAAPoEP/jZFQBd0xbkmTYkvOzyi\nX3hI5myvqRmC5i/e82rCZS7ZXsTYtC3mq1cgUN2WUnFMtpD8cmywGCgiAE/m\niJf2c/+/2ddYbacN7Qipw3Q4wwh4OhYXW0gvKnysgwrYoSefT6mxCTEtlCuk\nJ61/O25s+T/iBV8IVPjnMdkqkcLNMEvf5lrAZcxa+rbdBOYVadVOKZrNCiZy\nw/XNUr6QVa+roqc25XMSMEuEifZEBpekXxl/0XV3FdDTzKJDgHO7ud6/aFPs\nOgbEUm2xHn92lW5XPG8fRkhp6GwonMMffjqPjZEbt5ublEIBHQ8XmA7wW+9u\n/LXOUZXJeryBKUQoUIAOej4yPMnzyplYPkZDMvZ2LUQRGZQWHu3IlOQnUKoN\nD6p96MrxNzItWmwXpE2Lh1qqBL0WaIIXPV8thqjln/VGBrTsYzqldJWVUvel\ntaH0i8sBkS0YvXhdlN18iam+E4pyuDqFta8zG7Be73COc6QOuwDctL7yA4Uf\nFsfjSp/z86UwKv5EIxEXwrcl5CSAmY3vraVNgVxwJIxcGbJVxwwWIhiIBh7F\nEKQ8eHQdRcV5b6FTBRSkis2mdBxYJNlkDM1QIJAnL/NF+yThdOf5NwMD0KGo\nUIHPCGCfoEN1uYHjvMWwSIbGj3AKilIvwn0k80bBk5YOUsiBMfuYYaL3LqxX\nWzdV\r\n=x5Nw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0e05c60-1609264778879_1609264838605_0.4375460142127727","host":"s3://npm-registry-packages"}},"1.0.0-canary-34f1387-1609272408823":{"name":"@iadvize-oss/store","version":"1.0.0-canary-34f1387-1609272408823","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-34f1387-1609272408823","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a381d1b850c27cb6e284410f646bf730e8a53004","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-34f1387-1609272408823.tgz","fileCount":7,"integrity":"sha512-Qe22EntfDBELWRQfgDfOFpvyw8d8XFPunYJnmtKz7VH6IRfWl/C73Hs2Pe7yjj8n4eDZqmKnSMtDHLqHLezc5Q==","signatures":[{"sig":"MEUCIQDPZRIvZl7dTBfW9anohkbYi/tN5XxldxtMladjUg8UNQIgPCmvdkLPMDDzunpJzXch/de3Lcu8l8gzWSDILKwtbzA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf64yPCRA9TVsSAnZWagAAq0IP+QGyI6TPCU4N5n8RAgf5\nHTxvn0nz03udZ+csqgf72UaxQZTe/xREYTXPFKl+a1T8k2tWj191tQsMlQ7A\neTCozk2/VyeLJGrojNu94AsmRpThbvPJuD/6aaG6iSAKBBiFNPxrC+taTnai\nQgDXfFRseJuTXUOqR9zAGkwso4QqYeWptuQJTt1ouuOXxVqFLaKZlKi+G6YD\nDNJsvi53mdrIEfM9nqUsAyWnC3ZlXfRZWHwf0k1COzjU8j7RUh5pGNWa4H/R\nYsvqVJnFrLTOMnbKdA2+4IKEE6iH7Dyki9pyvaK+c4B4cWF18mJZEkF7hLaw\ny71PNVg5AB6sW0e9rSnZzQNUf4qyBaySVMvfgbrKyfxxqOM8pnqJUvMLQ++U\nESVuHfIDzxOe0gAZf1SLMctvijiq2EGXsvz1djyb9R7uWMGcXTalfTRNFBuw\nTO3GBeGr7TJ3B3WFhyo9RqQRx1RDYDVSq8fPf9nzdeUF6iqnQyURwZqbHwvC\n3mkF3+RNw9gjJfFOhH4mYO8QFCxw4OBw8+9PScSDZgf5FLVHqpZAPmAknl0d\n/HKyx0zugtk7yuiwz/8CanCDRafn2gx0WI8WZ0sdRx8Ehx3H9r0WQBTx/eNP\nBCxCrHwVuANJjw1JQ6HEDtED1ubc2sRMy7GIN9EGV42OlKPUlzxw1G/H1hYm\nksdN\r\n=YPml\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.3","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-34f1387-1609272408823_1609272463471_0.9068905666215916","host":"s3://npm-registry-packages"}},"1.0.0-canary-bb2364b-1609286726295":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bb2364b-1609286726295","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bb2364b-1609286726295","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"64c44452d952956d8a166f1cab07c042de03e49d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bb2364b-1609286726295.tgz","fileCount":7,"integrity":"sha512-wYUvJWTTgcKQnko/MZiEFt2xF1Ru8YOcvqyzWojWXEqyOy665C3Rl17k0mNYM8o5qCAcrDLFXVSaphRTdO4Weg==","signatures":[{"sig":"MEUCIEM8PzQdDS6SZbAIJwxpOvMhtcF90WGnSRlbBbJ7EjXrAiEArRujuHAo1sg9SDAOiS2i6bMQwwY9kgTFVOq+rl8+y88=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf68R+CRA9TVsSAnZWagAAehMP/jLkuHrVFjyWjtJKUUB+\nnInRm6BsFGEK8nhdjOGOZOFn2EgcdoXv511aX2m+1MhyLeo9hp6UvnkhZD9z\n7r5b3LCmwHlS0E0b87oft4El2BLyyy+A3Yr9bE3aKVEaMgfyj1qhfCNVl48p\nvKRrnRKfKfFztgdbooWvDoSwumcMxrpXiM2GdBo3C1R/YTmux2VEn2nP6lmj\nQa8xxVwHDLl1QbFWnvt5cvHAzM4qiaRMpnHO6mrawYqf5aAGfvRkn0nykCak\no4qNdoARw8RNINvFUurH2ZrWTpR6nJLQBWtNEfzFYtMYYUyatVSTBb8XVsw6\n8nX7Ja1j7zKyYVQIT3cufNaJG6Zg0/STiPMvcCRXM55fTOPtj5F5m8uG3MYF\nlIRYtzJXHROBRqP4dL1v85tNqxJ11Ovupmgcjufbt+XuzxfSeHnoiHPYwiUp\nNphg9gcNQBuyuwtILHtFgjbf3Hs100xwiSpvtmO49bD6ZJHUT9o0L2w5mWsm\nbjnYncoEuMSCe3d2S62O16LT0H+NcF9xHIw0tdfn9ndI7tW9o0pnawd9TTIF\nyyr6HHEtQYmLUaFGok4NXUQ1dS26bo6IxOBf2QEePVEcLvPN1MnEiKuJxSZV\n4M7ZPHUFc4lFkK86ORH5PRVBcH9NNHMleCiSFqx+JlihxyuCFHc8p/0aByIb\nujYp\r\n=b2Bq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.4","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bb2364b-1609286726295_1609286781753_0.9600705203310977","host":"s3://npm-registry-packages"}},"1.0.0-canary-bb2364b-1609286730276":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bb2364b-1609286730276","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bb2364b-1609286730276","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3ee1f5361555cb572fcfad09e9063c0d0d1eb523","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bb2364b-1609286730276.tgz","fileCount":7,"integrity":"sha512-f7OqVrlD+Hl/B+VyfW6ZM1DpAlmcfZUKIz6hCLav/S3g2nlU+9rk8inZ78A8n8h5cKL9cxRf0xB9eO68rf1G7w==","signatures":[{"sig":"MEUCIQDQrz0uG7ZVFtPNnBeAV0Hn+dEHXAeK3KEWnLbULAt2kgIgObzxkddmGQhEXMoIiav/sW+Z0LNkIsjWixfuP9NX0RQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf68S0CRA9TVsSAnZWagAAtU4P/ikToU7zie99uIOMIP5b\nlMjFPig/LZzQr8LuDkXucFDDxS+GDFnrIDIASYRiWyeyyzL7ohqhbc3qLoM6\nvdFORiDT1AxRNYfI2aYaHqHP6DkkEgl1eEFMIjiN1SxFNOUcmdVwlVchL7aV\neAV8z2XZPkO9rxyAkfYke+yOqxTiZ6A+WwJyevezzZhDetebfndF7eIa+hig\na3M1wKhfqAj/T2jJpg9ebxQpinSs/ii7WInaV1Guch7QzJixRYDFDqOkiWsA\npJSEtvzQzLuei5oynXWz2LAeCi6IBS5YqXEpGcQ4jTfK1rj2mxGjmRESHjEz\nimHkZhM+wTbgU8fXmcGh0gaBdfIopN2qub9BRJDBQn1xzdl5APLCJ895Mk2Q\nH+/ydpq9hD/cN67YRlzh/ulnKfP8WpnISxXFLsJmakmHGVvz8qAWiDSStFIs\nQ4/idysqBt+3Gz1qIp11cVjv/4IesOn4byPmtWfKFsD4Dr+GPyIBenfa618A\nbWofjBVyNb2z61+623Rtgy65ortNyIO1bWrgH88M5ejPT+KQC7EWTmf75Mco\nrPbhryZRBrPTK32pD3qoTPGPQ2ElKO26Sx3XFey7HTcMM6Z+Nld3YYmrGjtj\noC9KuLUpx/TAFJlKrutFLVPtS+dvZgrj+l9b9Vw+MHD8m4gEWwHX7+3w39J9\nqnZB\r\n=MynS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.4","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bb2364b-1609286730276_1609286835692_0.3728508409973641","host":"s3://npm-registry-packages"}},"1.0.0-canary-f213f77-1609363135444":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f213f77-1609363135444","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f213f77-1609363135444","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b6807babdb28f2584434a637df39d1fe86d5e3c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f213f77-1609363135444.tgz","fileCount":7,"integrity":"sha512-nkv7cHUCOEAoZ5iDYtgmWCpxAMuCpbLx1vCooPYiljzF7k7WaE7dhoYOGkO11zUWDkBIf4jCUmhnucBCuchsdw==","signatures":[{"sig":"MEQCICVleLFtjp47dxupG8UQtZU7bt8RVmnK5Q4GbNFDaaMNAiAZqThtcr5jQeuCaEFo3n8VCz837ezljugl4LxM26Pvhg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7O7yCRA9TVsSAnZWagAAjJYP+gKworpebg1zQh6t6RRj\nQMcErzxfxjjPLFAyLjtOadJQhsKtfMrAUskpE6wcYcrxhGOGTgeMy/ldCNrc\nz1pXWFYVHtpwkh+nixOJ7/5IAm2H5UsyPcLSDlsvVHsUy0/NWRwbUE7Po9Jb\n29wThCx9VVuWCpNxZbDZlovE9AdHHMqai8JwGYGN/2ALr9R6DDGH4FYzLfhz\nt2eM+rTOJHNZCyXwqPo0iFw1CeGEe1e0cJN5ZkKxynGBuSqFeIPSVonrkXP7\nJOdWxZPLZ6ogmXy3B2X4kBztZP05SEoWoX8bs73yGdkS4L7nqE9dHX7bOVeF\nKNjy4lJDP6l9wvT9Cobdav0oANncekb1w2LCMc8WMVZVHhjIYCyTvFKasUPr\nhozIxTwtUtfMg6S/6bcKW+9SerW0w/b5CsU51zL2ODbMvsNm+oUYYTbVmUAT\ngv2ES9AcwT60GpTMt/LulGEXwOB7OmWxgK+b/CMjrjijs8SjZbN+5ko/BHVv\nWLM1QXL0Xew47kpPnc1jNuSYxZH4YSWHrRnRIZ0PaXkULNA8tWW1Cuz9PLOY\nJncwyAn9ts+ZmbIaVG7/L4KlctRxcyjesztT5+j0Lx4rA+CojhXw8b1frLhF\nIrGUyaEZO0jDreuerxVJ6NMOcKnfkHxpDU9mzdgWH+qt5YI8pczOIBBid9A4\nzQXJ\r\n=s+4T\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.5","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f213f77-1609363135444_1609363186371_0.052254523154101395","host":"s3://npm-registry-packages"}},"1.0.0-canary-f7b8a66-1609465237193":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f7b8a66-1609465237193","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f7b8a66-1609465237193","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4acbb58ffa02bfc55cc52c1ff37334dc2b6345d0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f7b8a66-1609465237193.tgz","fileCount":7,"integrity":"sha512-CYEznqYigymTUDQvgoRfv0FlJ1fhES7PVVel/i6GaVhwJ5mupX34gYJdnfr9mb925FgIIcWZnrCZuNlKZPxSeA==","signatures":[{"sig":"MEYCIQCoVSyxgv5pJZGII2IN5WM9IqjWByJlRaFGCHbPln3OqAIhAKJNQtWhxkbIxNfMTe50OR2QUzK8Yuv6zDbLXwjEmA6P","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7n4ACRA9TVsSAnZWagAAcfMP/1ZmrqdDIbISJY+zmt9N\nE4v2MTfPyrkd0vD3SjSTBl0+YaHi9NjJTrWJKwaRPFPF1zQKwwZkNdT/rNEG\nrJTRaa+RKKzWXm1YlTW/Y7pc2V9mv/vxhMlmGW6k/g0w8GBiqQISw8PACFw0\nBw7aDWeCKmV4XjdKTOI9l5L1RIvFbrLwDx23U7cIDaaAJEwaK0k/CkG2lc3A\nfR1RCvS1EaS4bPNQSoJU+ey2+KEMrDwylZFO/rFp9ITAEUM4N9MYaLRlUAx2\ngUVP2ZqWrg/yqh329/fxQhQSJG7VGJ9dCUtQtxE9IL+NlOuNHKu7xl/CTN0L\nMA808/RfDYaoc7SXBwl8zfWpP/jXlDMdMhHiOVQyllT8UGQUh5XGNMqOGD+S\nFsxJRFdRtCImwX7yimQxFyf1rops4/hUyYjAPqN4w8Kz/SZohrYa7UoSjgBL\ndwcrhhPcwX/87dmaDhobZyYPUKd07V+fymNveoENqeY5lalFKehYv+8fpMM6\nQ6v5X7OMFRD0bV86ESlhg2bN/GBaaY7Gq6+t4uGkqujdgidTzEgcNgAy4tTO\nr8AtHVyqcAZGQ8v9Zv0dUuNXA7sOUgCcfxZ8dQ42JNjBHa3gGvXLA1y2MhtZ\nTSNlZ4AP0OjZf905HM8iSBXr9RrR+FeUdXGDy66kN38zHlJai8P9mINbFm03\nf60r\r\n=+6P9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.6","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f7b8a66-1609465237193_1609465344474_0.5943725053125164","host":"s3://npm-registry-packages"}},"1.0.0-canary-0100fcd-1609492864296":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0100fcd-1609492864296","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0100fcd-1609492864296","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"aa6bdcdc16b682e392c988e5ecf055f18ed086ba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0100fcd-1609492864296.tgz","fileCount":7,"integrity":"sha512-WEkzVpEGIQuZnZoibQJhkUXULFC9ndk5pr+lmUUTFqHYLYw114EN3p0MZcQFxmknbQfbhE0X6no0Qt8uo2lt9Q==","signatures":[{"sig":"MEYCIQClZduSit4127H6muvWfJxKjCo7NW4x69OdUrZhsmNEJwIhAO6fHtboimvfwNMVWSxO7J/zD17dVhU50iGj1nSKuuV7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7umzCRA9TVsSAnZWagAA/YMP/2cSWTDF+emQOSPEYfTs\nw4djjMyuD92N66mO3j638+FkefRfDrhoICm/i7hsKt5d/T1xOvzoePEkbshh\ne6RW9Yt8kqNRefAfxAmYruacAg4JTe84vWZnxiPA0sQFCaVWpkONpyHYom0Q\nIkh4/lzjswFcEUcbA/2QdJhQgULHpmX+2GHpPXn/fuF1ZANAbtWg8+toTuKV\nCp44eFmc9cS37S4721BqqJTZzL4nlkNEnIs6tATeuduhuCmHCx3Ao71wpIpM\nA0Kjjzkqf3XdTRVOxrUJae7rmDAtfsaap/FucFMiq1HUUw8FxZYOUGX31y/f\nPWn0ZwObB0riA+R7BbT1Pt1cgUp4evB8i98dp5t19/mVCBZBeLwZplDkJu8x\nybWdzVfncN9SfeJd/Js1RMqDODpz6AMXV1KoFjf6ykEQGmxM12Krv5Z2Bv/H\nYQMroKl65Ldu4niGLFcZQi6HkL0QaSyesA5g6RyEMNaQhpOM70Zqlnq+XjH0\nBFhAqrFKaydK7iy5aJaWcmuGxvsHbRVupwgGqWfSvyoOc1TNBnkHOz55tVSW\nhmLvHmV+ERqXMhVPnSskiDR1cVR5KAUcy+XIcdyZsRE6CNbkIY/+MKEgRuFp\n+7p2E2MDHJW7D3CUB5/qdjFN2d2UBZ11PZ2C4d605inOyAj/39kEuBtG1ePX\nbcoY\r\n=e918\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.7","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0100fcd-1609492864296_1609492915167_0.1716029361176865","host":"s3://npm-registry-packages"}},"1.0.0-canary-0883853-1609541255340":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0883853-1609541255340","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0883853-1609541255340","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6b0da1098ef300abe53f266b95b2293dc126e8bc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0883853-1609541255340.tgz","fileCount":7,"integrity":"sha512-z6CKo0AcTy1Xr1Li4y8XJJ+A6dSQ6r/M/fTYjxvLJtBWbaWORUCqgxhmuxAz8wvJlUWmtEuxWipxYu7qqD7QmA==","signatures":[{"sig":"MEYCIQDSUtgMZ5z57I22HnadYYIcUE5qD/BOPXwKhe2M/PbUkgIhAL1cxF00PaB/pPSsGx3HC1IkiROR8hwDmNPBGab/J2tJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf76bnCRA9TVsSAnZWagAA8A8P+gIQitfsulP957IWx5DG\nt/ArC1mfWk6qkBZVy+6R5XFWUSI5kXsW09vKKQrIPftzOT/3vFI/PKM1OI1H\nntJ/bZYUVO24RGdJUuri6mzMPYgmg3i2NdbRwMhqMciyq6onPeLmdvXWxQWo\nEn6s20ADHimYXMRhsakwSf2rszPO/a8P5ql+RV3Kt5xbrgHC+sclPH3HfSv3\neF3uBfsZTAGnNxKkM10mD9sc4Qbp9oKramBozXqMnsK2UTgjjmK5bL4hRfqf\nArG+wduLiEQDEslbNb4DK9GjIzgcfWSISizH5BK/FNYkjYyG0cQz7olUa6ZO\nkXaMK/UAgVwo0hd1CQevilz9DkbB2Q/XGXF73BnTnG4xJVgPZ1Fz7ALnXp0G\n5PUnvptrXOD/TBpRVP1AbOfxOtBKslcDeNgXx+WNkD3FP4Mw4NwlUuhi6T7/\ns+hJMl1nVYE4XW9k10tcoBmcirhstO1I2L0+ZzxGJK+/fVlQC09qTcxqQ5LO\nfNOwaIJJWVG8Qy9B2ed6EY96+S4pM9JzG9b6CPUkDCwV1N9gUxI9np4yfXfB\n7y3JALbaH4Qx1LFQLbBAMU1AS5IZkNBDVGT7zRnINACwHiJWgJ6DHJmSbrlh\nWdEccsTKWbk2dpYUCnPJJAhKA8o5/tCcpNJRlfdmcopuFQZv8nkU6KPlNXx7\nVEzc\r\n=OXNn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.16.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.8","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0883853-1609541255340_1609541351246_0.852417598818499","host":"s3://npm-registry-packages"}},"1.0.0-canary-0363764-1609557107467":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0363764-1609557107467","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0363764-1609557107467","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"75161ea73ba01d87ccd3794ce3301a2e5a113f45","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0363764-1609557107467.tgz","fileCount":7,"integrity":"sha512-YwEGJY6CPTqJKThowsh6+5I1y96/0QrEQtf4c3FIb7nWW3Y4KlEoq0w9DJi1XKMlR0Geh0jN+6bLBP0ahT66nA==","signatures":[{"sig":"MEUCIQC5uPSobl9NihFOCx43co63Sy31kuim5bA8zc49NWU86gIgUM5LXgGWXHAxIlkGUCLIKdlMv2WgPoCUIxcX713YGCA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+SjCRA9TVsSAnZWagAAqsoQAIvaLSW3aRRFSIdcgp2w\nFztnmsC1OQvuxJVVvXQj+t923P+Xd632MTQdJZ8yrGqKGCJYeeE1klgis8HW\nZnPqBrHvbR68OR54zY/aCeMKqE8BlLeExo8k+ix8sOLAlvPkbcD7DPDo+wzq\nTVS2GAEUR1tcX/rHIOV+Y4Xa90hW456Ql4twWmSDf+mZWPQ9Zc8X4r0XlZ+b\nWMm5rzFtKzeRPf8cLINmERR17q4ShNYVhiUqiMwAKs+d+XFiZBStf9vW8IBY\nSqVia2lDnlHaNt33yxmbCb7qCvfvn1XMYgbHKISZkd21Gp4z5NhVZNEHuiOw\nHS9d5DM7PJIhhVC8zvPj4ylMFUbTtam+Wzb9ZB9MCBMgHsJa4iVk+ZDqBkf0\nFnO16pguo2iVybI7VqwBWTEQrAJV6yKiaZyrBtwWPGLFGjM2JjvfyYPXDC7g\nSZgbR0ajXab3vOO/+0JF7zIS4kFM6IeF5ka+gJ31YYrlAWSXqWnRomW3STDS\ng/5IBSq8AZIfhvTvTlFXZD3CJJpOKwZ2ai2vlLCGn1jcjJ0HitrH3lyjxiHW\nt201qcHtIbu+bFgCmiyEdOsDRMd1t2xVW7ZyNRyhLN6j+x3dPf+dY1mUjzfV\nCN4CwsOB7b3EP8tVIeVdsM1rXxsfpqGM/T7cGR1JzjWps0dGyFSSS09z+6ac\nqYhJ\r\n=xbZ8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0363764-1609557107467_1609557155409_0.21564501956847693","host":"s3://npm-registry-packages"}},"1.0.0-canary-0363764-1609557109409":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0363764-1609557109409","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0363764-1609557109409","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"24fd4c4aa8ac9a7d46f3886a79bb353f04770665","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0363764-1609557109409.tgz","fileCount":7,"integrity":"sha512-S7AyIbmVqQCepTTxgHz28Rzl0zl/1qY1Pl445KYb3g1yizrC1TEapM71JTpVnuXVEgDz18orpYXMVH8CS21UNw==","signatures":[{"sig":"MEYCIQCEleuM+z7l2B06mQtd/7Op7J9xEuoK9jTy+a07veb7VAIhAIcsTdjxzAG3izP8Di9folO0fHzOb7MXItacC1YqCSIr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+SoCRA9TVsSAnZWagAAxCYP/jVrfq2DBtO++c6SiU5F\nDq71hJQI83QkqRPIf6ZqE2YOXlKG4Fy2/vFJJrYxQWds9/blu1EGPMvRDkDc\nD7ov4p54k0N/RS1QK9Tn2BYHMrNtsuO5KlF4omEdF2QqeBZ97tcZmk/xqH4Z\npERdUzpYWMLNMqcqL+9Ztj71zd0Bmtj/W2IRi05yd/LOwxhsIjxsTEXJMZYZ\n3QsdZnaiNm4Yu5YyHzF9OwJZ71fGCnZWgoeBSvhkR3Wuhz6a0ZLicSgtFNxm\nyzEHsd02XebFLvcc/6a5xsJ8e2A+Gx3CNFhNkT/2qKZcEhLYKhqxADqRKjXL\ntJCtt9p6QihG6yzX80Wpw+T49ZAKQx5qvOftZ3798NVuy8KzOlgfg0+LDNx3\nU+8DsMWymvK0vfkFvg90hWRAH1AfFszDRUGJ6rD06Cl8bQNo5M01b52xO4sy\nn6CQp1S+KH+CFN4cYo4GMFytT9ec26dJEiGkzfk3WNZK+5YPw/zZlI1ij/Bo\nXOHFWGTkwySNriZ5wyrdLw3HrX4TgKFCsZZj0ZyzxnlwxOAs40Y++mURHt2f\n2WROr2QkiHmL+sFjv+JPwF178FQewLTX03+RXzDhn7Rh+k3f4z8irp6xxG7U\nKmXkwbQZ0ZlQ3l01ulYuxg8I3Uh4syXGTb2FhBHOGI/CqBswn3w9293xgLhB\n5skb\r\n=jHHL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0363764-1609557109409_1609557160346_0.3607938225629921","host":"s3://npm-registry-packages"}},"1.0.0-canary-af28370-1609557256034":{"name":"@iadvize-oss/store","version":"1.0.0-canary-af28370-1609557256034","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-af28370-1609557256034","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"085d9e449298947538d8661e256dc7d3b001bc61","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-af28370-1609557256034.tgz","fileCount":7,"integrity":"sha512-GSPRaRlEAvGLgwh03h9aqBzoAmGqGsqmD0nEk6WX+glLlrJMdtO9aLK02E74eDB4ICw/tGvgywrO+C4TifO4zg==","signatures":[{"sig":"MEQCIDvJEw5AhR9gkXf5lQrfN1V3YzhqzZJxosI0nmfoB7NlAiB9PtlFR+X/azHCe3NNeSZzw/Kx+fgNYYcnY0NHcz8Llg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+U6CRA9TVsSAnZWagAAoHEQAIHJOfeurPIuvtmZoqw0\n5oUiDa4MmmUYVeEBDRovLo4DpV5MgAcr8PTI+o0+4fkzMMF1cL5JXeJI0kJJ\neUljOjYKyHIUYIeTds7GggExUSyUmzUHuTmtfiS0bk4qsAir0GEaPaBv855P\nF0P4nz184AeTP5xM608qghwfMDNogr0wyEOXS4qqq7//zzrKuCvbqbHrTPS0\nuJNT5JI/hgANqp7kjD1z8+1+UwGusqb+OHVNMr8a5EOkxaM9hQ0scFq95lBX\nJEd/Ckvp8pTo3lauQ/6oQOShZSMi0eXzlV/9o2j28y7nIKcju9Wab9gSpP5n\nex/Cp1ypdSgG57kpzkiB/48Xsi8qzBH+bjcoBon1YWvk3aTDjOmnbscg2huX\na9pJIlQHtx3j0MFfHBv3weLTeQdfrZwJ5JkfdTVMFHaMmehdOjakg1LLa946\nMf58xX5vemNMW81CaWijJPCEZamTOWffFGgPLW6h+X42Bz+hAsv+wb3B6GMP\nJpn1mIaOdKM2GyNXlAUKtwtsvjODUXL1jrk6QSLvMA6m0AG0t4+oF+bzSkqr\neZ+rNY3WKI7xR2i1pIRA8lB0tvsXdxCPwKvh/uH+RpBFU+XfLEr58XxMTfVj\nM7ML05s+c+/BZQcP3D9HQaJGJHqayJ5uaY86CnWQGExbMkUYeM4BEMNVvrYb\n9h2J\r\n=IggW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-af28370-1609557256034_1609557306212_0.4860310222499544","host":"s3://npm-registry-packages"}},"1.0.0-canary-8b416cb-1609564185832":{"name":"@iadvize-oss/store","version":"1.0.0-canary-8b416cb-1609564185832","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-8b416cb-1609564185832","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c53ad155200c5f9f669c101fb6435ae0a1604299","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-8b416cb-1609564185832.tgz","fileCount":7,"integrity":"sha512-bAfvcuUDFxQNmSlgRd/P5fp5NUOT6xgdxfiHpR2fwmWmGkAOnupszrTs2jCWzjGnxQmkusWtXHDw5QN/Eq4TKA==","signatures":[{"sig":"MEYCIQD3lcsoca5UGQ/y1xZ+R72vA7bsfIdLtqG95ADCgdE9XAIhAPLntN+GWfGYBx1NIP4qNUJ8MnfQKPQ/NMXvlPT2xvG8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8ABKCRA9TVsSAnZWagAABqUQAIVcPtgcJNKsrUv2VH41\nr/d8xSpp3M3dBKlkukuwkjDzqZutzdVAk74vmazYzsCnVXQl2RU91eVYj+d6\nUMLHYqXU1JJWkO99+6E5Lb2mt3T7smq9wDYL5W4LIxEhM01QFrExB52nXrYZ\n0C4nTYF9t/My/W3Xr8foBpN+YF8IU1qjiS1oic+e0iN0HS+3OSq6yj9ny1A0\ngDTYRHLQmKg5MpftMFPTkcRPRdQNYNLMFz+YLSeOgkQY8LJ5rrr5dFVDVNOJ\n6BzRetIqh9p0n8ykumvThgNsr7xHJJP1Cdh/rRZXWrc+u8z/IrjV6OX1fTYl\n2DXz2ucS7rzUaqTINi4TK3tKuryPdoPg/ekh/fsBL8bH6pVbdnHkBAhRgNek\na+vKkymqBVDq3CvMQRV+boWK/Iw6yzFLrgPR6BK0W+SfR7iKcOEbfjUd3jSr\nWIPz0L0M9LacmEPv/nLM+kQiWmxpplVu7851CKHy4Y3JwBsqzFKn90H/P5dT\nSCuRZtJFWdUxBO5jD6M9eWpLsfhcv+qsK+llYY5lChWJXPKHcSwuRT5kda9A\nj8seT8zXKvE8jYZsRObjI3UZ93T3zEEg/VopO3baWdXn0A04eEjr6agTsEd9\nBDA7AELFG2kXIQd3qASkFVgiPX6pYs+9PvPfauV8jl5VUpP5deLjdUKwEZyd\ndlPD\r\n=e7+c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.9","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-8b416cb-1609564185832_1609564234053_0.7170975554013794","host":"s3://npm-registry-packages"}},"1.0.0-canary-bbbcfdd-1609638823580":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bbbcfdd-1609638823580","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bbbcfdd-1609638823580","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"90ab9c8b34f313f92e86ad1ce4811a879a884be1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bbbcfdd-1609638823580.tgz","fileCount":7,"integrity":"sha512-CEVDynNf/zyrxeZSCJG5+PW4iMecMfxhDTD9MzMaCvdsBs0vM9iMPLdnBwIur5CKhXGob0q4OJijBaa45lrQUw==","signatures":[{"sig":"MEUCIB2oTUd1yfULy8dEkzELoNSPj7BCWhlqHixnRSdEQvDSAiEAwOucMsdw/onDQCktMFgKxElytiJnM7xYTVvJ3Tm/aro=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8SPTCRA9TVsSAnZWagAA5aIP/3s7PFZTn3cDskVMqxiT\n27k1JZyYOpZqMkCptGk5WP2i6qTLh+yzaMLz0wVcvcE9jd+3B3bBw6Nu+vTw\nxkTfq2wyjssXUlJSluMx0KasbyTvZT6Tj02mHmuqRRYPgr/O6wSxkiTAOQMo\noJXPw32GfzNCF6q5865yugClohXdcctWWqYPj0us6ViW+jZcMDRL9AJDlhA6\nzuAvU0TZUIigbYvKQ31ipOOzhHpcuHWY8sPUWBUhbTY7S/5HSKxEdubE3uBz\nqRVW2qG2IusiH5G33xhGIHCsllVau4zB+/Kvj1R+seQtKJj6cQ02jIzH/EeI\nBRKW5MyFHczjEWumUUoziPkMvO5mEyehpMhzOVWg48RVgAbz8S4qWmMIr3WQ\n0kquR7cezLgFTlFv7F+fF+MWj1FBRDjbE84wYbnKQlvx1B862CBsHXAb2hws\n+92TParWHHQ+ynKAyfbKDkWirFTpb5/B0Bucme9roUA9x+ceWWXDVI7v9Kv3\n61MJ7lIpMA6dcukDu6lp7u3jE0JuxOzDGc7b0IjBhjVK3+Qsn7foTKiRvBSS\nJmf1ftIxn0WqrFvvwiKiA7abctSVu2mAYelGuBwxMS6IwFI4WMGDO5Jo7WDI\n78cXpevPawG/C3bnSzz6lyS9XDSMz6otyAqTwn8m3MD6+11ZBZZAtD835Ucc\nRDpK\r\n=D/VP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.10","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bbbcfdd-1609638823580_1609638867264_0.8114461122894137","host":"s3://npm-registry-packages"}},"1.0.0-canary-bbbcfdd-1609638823716":{"name":"@iadvize-oss/store","version":"1.0.0-canary-bbbcfdd-1609638823716","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-bbbcfdd-1609638823716","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"09f6753bebfb2275afc297236b8388cc6f5419c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-bbbcfdd-1609638823716.tgz","fileCount":7,"integrity":"sha512-Plau5LM6Ad39kLxQcd+0cWlSswIUCNffO48G1GAvX0wVnb0a3C1x5WOUXBSduNLlN4GeFfgD4x7t9IFBtKn/mA==","signatures":[{"sig":"MEUCIQDmD5h5NK6urr8p07RIEOXVnjKaJ/V2EIlqGgAcwmC3jgIgcpK3Tyz9tkO9AhFJyA7NVNpM8nBDYPAru8iETfILR0c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8SPZCRA9TVsSAnZWagAAODIP/0AvYJ03fxn9EtexBaNA\nFyEJZnC7IU0agqIy63wr6B2mtFZYeoTfOUtAfEtiylLdYaG+mbraUSSS7QG+\n5rKgYKCRdhaBBqVUpy6ouQ50/T0aKkwv2eWXfQrq7R1VuDDPT3B6BOy8WhJD\nWCB8CJpgiKcazBPoKcY4XCrsb87DMZ3edP9mcta0usJdAqimd5R2Yk7YwkXS\n+FPt3QdtcnTRa4WHFrc94F9RNz+l9O4CcEqJRLIYYguSaC481UEORQ74CMYV\nXAWsLkMWzbMYQoqloKHKissGayg6NtcLm+eOZXdIcZqxBebJP9TXzal7c54C\neMNJQDjl2ZhwT2qvDAZlYBO+aGFUafmlHHx6iRpXca2eF7nNejKJQjHdcTzM\n/MX5FdYAEwV9k8e087g+PV0AMLey4YBx4Nj/fDnM0/ETAEXlJs/0h1kWm9Vq\nOW7r4e8KQF4rnVIOyRcBOCxmnge6Y1hbObrOB4tmMKTtUTnVDUCWjj7bThWi\n9xspF6Y7FqelsFwYsFLypYoxpq6qO8c/4NMVCS4X4X4YwT1cbduwceBvmmMo\n6HZjR38CuKRt2TEi8l4ytbFx0je13bQ6dujx0io1QuBsc/wcRroB8blEfSDp\nbHgRa11NukOyw/qxK33MF004iID3ej0RgOzk6Fp6u676wk3EwmiZZs33SQOp\nnt24\r\n=g544\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.10","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-bbbcfdd-1609638823716_1609638872939_0.7338336499720377","host":"s3://npm-registry-packages"}},"1.0.0-canary-aa92248-1609715650286":{"name":"@iadvize-oss/store","version":"1.0.0-canary-aa92248-1609715650286","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-aa92248-1609715650286","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ad5e670960ad37b74224f451de06860ae3f1adc6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-aa92248-1609715650286.tgz","fileCount":7,"integrity":"sha512-hOenQ7s+KCZV5Zr6iSvzEUuoE0qAnfp4LXDgLPURqm8kjIaFzfOPp7Di8tNBMOBNGhzNbdJhHf+TqvxL6I5z3Q==","signatures":[{"sig":"MEUCIQDlSkcGMrEDzB6vlqoeF7NNbSKXfIXUqhDCQqvwlML9EgIgTltZZ+ZDFLCcqQ0JUx0igp+iSuPT/dHSMTsDUdikPvA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8lA1CRA9TVsSAnZWagAAS9MP/1jgE5GBLS3kz/bm0z58\nShUliqVlT4AFI1pGU7G2cnwaDXii55Mysh/KyrgBlNnhNwFU9CzQF1BdsdFA\nBbJxjb8UeT/rIt7Zv+POCoZO+XPbnA+6EBzdvarvUSYI8/yb3vGdk9CitaEy\nlEyNB5wVdCb7YgtUzVmX/mH34ScFKhrYUake3r/jcASWy9Kafv6x6YXOTErG\nb0NR6EeDeJzKs/oe5kfC6DrOacLu7wh9iysSYakddEtY9SSatj2jpUbXhRQW\nXLjIIi4Ug07TqGSzTn5p12CKh5p6+Fz1Il5RyZUP1uQE0kdG71pAcWnnYqgm\nBWCQJe2dhABIYW0nJ1y3hofSDyHkYrup01x/YsmhcKtve5XPrMgwrzPhjEl/\n6ALCF4RTU7E/ESfPj3bs21/3SipeKAzQE/ZV6Cqqz5uFcg4h3E0NPqDXDfue\n5sm7aMgRaCdr7IaOzQGMa15nFOIIDz5BXf+EkjEVHFDLZWde51coDJH8LFAb\njn7esrJqxwpnSvS2vjPc7m9hQHnht8KlGwWCP0n2q+OxTxikRm4FC/Wan/Yv\nAXEutcabKTa2zk6Tkw4xJYsSBAwvY+BXzJWu3gx9wrnVtwnH6tirKp6Cvlb1\nzDfS0dy6V+Q+fBtXZSgAZEZ1haLmAcUxKLAgax4hoFXJZjqApaA7gjocnqmz\nBQ/b\r\n=Q6lB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-aa92248-1609715650286_1609715765055_0.7245065998347986","host":"s3://npm-registry-packages"}},"1.0.0-canary-67a0e3f-1609715773702":{"name":"@iadvize-oss/store","version":"1.0.0-canary-67a0e3f-1609715773702","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-67a0e3f-1609715773702","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d0ebf8babc31cfe47f4890623725f4c4e7dd0bc7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-67a0e3f-1609715773702.tgz","fileCount":7,"integrity":"sha512-NNIsXHvI5F+iKp7WnQkPIKW3AU1tSC7ZPJgSPZYDSdEJpVsrHmSG0+fMLZZx6zoPuo0wxP7ZQHSvPUVSpEvomg==","signatures":[{"sig":"MEYCIQD6GbQChOZyA3wA+nsfVAqh6aPgX4qN9JavvN60xDrdWAIhALIeXifmAQC/1FLO8MnvMZHPBqPgLhPac9zNyw0IVokp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8lBxCRA9TVsSAnZWagAA7/MP/jsncWWDIUCEHbmxgmQX\nmrjF/zVZQD9QW15kXRMeN33iVM1XEMAXTq0CYABeGqTBBgMUWc7sm0h4f2AJ\nzuEFn59wi7n7lObzYF+2CM5ItoyKpG8ruM8Kic2R43Yv1E4Lb4uSM1cLMgpi\nknIoVCbPpLYdyO43qzT0cLR3Qdti6Qmf/72fDFXfjmO5y7b5mPQa2vRtgYBo\nuwF1nRTVkguiPxxM784JorPFxIXZPiFqAmXD6XXLoUSdG1f9x6UZZaIs1fXh\njUeXp0dYy6MQPs+3/VnLTZxKCiEyifUD6zXQCachOEHkDn1Ib5DuNAPCJ+09\nTVgwFAcC/5QciN+qAOHY3sMpgahefIMLyoqZfPYqAq2BNTOex4WlZsbHmCrl\nnCdRxadtys6C9htDq5XrYSo3agnALUKZDuB0URzd4X1cgyUDYfYztAknKmO/\nyfiHJMYD48IOw0J6CiqETTo8vJm4lCL9KDufQI1JnepzNy/QKtZGODxMt6+R\nWjFBUBQ3FGRVLDMgCXY3gXBCDtVClgU3GnL801nE70p6zic8cukufPR6JppA\nDrBDKylK7BFcVyHi09przBbOxTzLeSCcqs9fCXo3IPqKRQ9PPJtNvB63Kf8E\n5KrymIx7/f7GSix21pFc/TOkrK6WfzWGYQxYwTriENY+ITGVWaBG2Qorf3qC\nSr82\r\n=xYYd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-67a0e3f-1609715773702_1609715824846_0.4190010650770284","host":"s3://npm-registry-packages"}},"1.0.0-canary-c986ed0-1609791552981":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c986ed0-1609791552981","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c986ed0-1609791552981","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"35b4a417aa0643e47b4051c47e4afaec770d3409","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c986ed0-1609791552981.tgz","fileCount":7,"integrity":"sha512-T1pRrRdimN6v+XP8wSbERYbjCKrS3AGBIJzrYTemE1lDeLydz0l9TRPpSd8UlR+5twQyxo/+k41qogbhDtz1KQ==","signatures":[{"sig":"MEUCIEp0AiR4CCW8aHaAgexXJ7DT6THPK+6gsl4XZ5pVccP6AiEA5HxLZF708Bk6duXMS0vyt1cqQjQzH8VRuX4j0UVyslc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf83iSCRA9TVsSAnZWagAAQlcP/3feD7SG92BrrPZEW6k/\n2ojyKwng/CvNVcvlDX0wL0PhjdpdwD49VZc3FtBu+I9wMwUaDK1l3c/TQyOe\nIihBs1V2d4EwgGdV5zz/bFRm/kayyyH/3Wb6P0Anc+Qhj/9sK3zR0Ms3N496\n/pEcpyuUS2jfhzB0i7ff3pvj8RHCjj1UvU35wuep+YdoR0QYT1ORjAJu8cVa\nZLIzTvzQntblZT7PO3UjW1PTYNGpEghH2yjTJljdn/6emh/nbb/jzNW2RbaC\ncJYd2P7GAfgjBs/FEazOashcg7iHELgZecAxXVRn8unQlkFaO24Qevxz4fnm\nIBaFSgwCbAHf9n+HdmQH5PzL3rKX6tT0tN1ugWikhJ/Gh7v9EX80wxCs0F6i\n0SlNUucvQTqLef+mcmxmMZGew4QmDfz8bR2KxxVHle5aqGuPKhw5SIsrt/b4\ngOWQwODnyxyuO3xU7+d7h+HKxXVnq4UG46edaJ58QWY1i93zJS6LQ4uekCpq\nnJ9RCuyHu02+h0HhuGjCfwOxp6kBmy/nMvertl00tHVNbE41Nn9UN5BNQ0te\nk9P67oLDl2xT3gXekeOKEhGFTNGwOIZMjEcHUms3s9chPvp2QpoV5YLcL6IF\nHKcXEM8+fNlu8AogeoPpz6OXBppvWPwxVum/3BxQDgX2CItjhTowR6y/idB6\n7LjH\r\n=hV4V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.11","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c986ed0-1609791552981_1609791634301_0.4620130059631309","host":"s3://npm-registry-packages"}},"1.0.0-canary-89fe5c8-1609802242521":{"name":"@iadvize-oss/store","version":"1.0.0-canary-89fe5c8-1609802242521","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-89fe5c8-1609802242521","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"81d282906035a578e4ea288862caebdaf51dd42c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-89fe5c8-1609802242521.tgz","fileCount":7,"integrity":"sha512-FgyErkDkfyuBmBDDMH3ptDdJs4FF7dlCp1kUwAbastJR+ovlZODY+93vFW1aqy+2TycPKa0cmaYZ5ftZMnZ1ow==","signatures":[{"sig":"MEYCIQDZfNxDrhbr3ZKWm3ZcBfL2570QlN4psn7hh0Qyb3hSewIhAKh1o9/dSABJDsPMiufLf4X/ejGI32Df/GXNnvEO1IR7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf86I7CRA9TVsSAnZWagAA3cYQAIF6e+2KmPYDL/DNdr78\nl9Y1sw5Uex4ARdWaI/A8YsXBur/W7/iXfS/LgLwJGAm1zxjcmUkZaa0lRN7J\nglzEWAOjOaBootOB0vlwM4GRztZASuJ0zsdbIYjGt1w/8N3sSaz+T50xCS5E\nYr0dhTYytZRHc8bDIUjRa+5j7pVrbMWAWVhr00SGXwoNHcLU0aRvBOyGRqjL\nEKdsz8+7dOkXArzDWLYNm/ORmuUalhenqowYlCcJwiD/aTALJNbdcpy0LXSo\ny3Pi4C9mX5wKV9jX5Ko037K3TVqtu4ctYWCZGK9O52/wi5EuipWlgIOVMkqH\n5b2x9u338M5/TFHWzha+XezB9bHxoWNLl3jKDP2PW7LEUn6kYawfmftHdToL\npLgTwzk6LaHK6ERnZqUWhkxGzFIn9OS7s4qw5LI5/uTbZHITsNpUna3/wKOI\npxk5RVH64vkvu0DU/ImWcadOTBSr4G6L3dlFoXON8PnlLcRFT1/1Fk0XDRqa\n45aQOFljwhyDEJE+mls19P3hk6tvOJroBi6Lug9zUfX+QvnfnXJjZFiaHSwM\n1clzu6LhB3UqPLG0BOXjEuopMDK5CpvO+usQm9rXWk1Sfw1yXEgTCO64pw87\nh4nCProvHF9B9TpE/vNgbiCEc20ppgpdFy3EdXdQ29fGASd/Vyyrjc9r6fUl\nRJvT\r\n=dPfS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-89fe5c8-1609802242521_1609802299026_0.16060440013498822","host":"s3://npm-registry-packages"}},"1.0.0-canary-a7dec2b-1609802373061":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a7dec2b-1609802373061","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a7dec2b-1609802373061","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d6c5e81bf51ec5b30a60e438a02fcfe03f5ac6b7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a7dec2b-1609802373061.tgz","fileCount":7,"integrity":"sha512-PhvfTUaH77XsX7eZxVg/vdIGT4Bw8dFuJHffrJDTJcqiw1DIFkamkmIO7J7cKBV/fIoddbxgeve25ZHYXWA18w==","signatures":[{"sig":"MEUCICe3DqvIKng2rll1itUiVZ5qS3NIgcHSSTn2M8ySHE7VAiEAilVIJs/3ZwWyXki4T9nNu5Lz/W45u/ek2UguT8ufZEQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf86K3CRA9TVsSAnZWagAAyHAQAJJrIvLebqZnLVJN2bfZ\n9uig+vQtvp0TtaE2/oDodtpvnN1PBn3Or6+7JsrTd+ntgezknxabmK22Zp57\nRXSYYKUpATE5Bj6md69MtxoTxSuw+pDT8d/QjfpgbTPvV1F6mfJ4OROWeV5x\nWK+NwWS0DDTuNaBZvoJVc7/vqFtSen96aRok2mLBLh67qRGPTxNoET4OQipQ\n3y+gYn1HewdgSAS7ZKqtSkjzp1cHVoy9lCDVy2F2BD7tBRDkZmtNNXIdFGT1\nmJsn0bFkbcPCP/Z8CWsrt2rVmAF8MlEsHTvDAOzGAqlmplgWS83CoWDkZbkK\nebc7g0T7IprAJYBAgnZchXO3nXcoV6RZDYuS4yTQETaG7FrMrqJBlPJHCRK+\nON4oxzeW8fIzSjUpErtq3kw07FzWJ3FrZUNt9jankkN5TxPjcQHjpqagXkkq\nkAmLeAQa/pLlZvW5Km4dFDXTJcUGrjODJe9IikEO/1CDu0xixAxZwjYsLJ4Y\nOYIT5MrC5dSg6lFrEIvpYJnUnvjhUUFLggBbtZVwDD5cBepzyqFQ4lHLxbV8\nDurbSsbmgcHpMZ2uKyyOE1RU0Fib8YnMFpGE1Nyp8TWVMcTZN6lenvv1Al/T\nSoeJEMoZNjJJ9+NFdgwHGq0ffCZmFulBe1E/XAeoYI6r3bk6cgQJcH80yoSs\n9SSW\r\n=3vMA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a7dec2b-1609802373061_1609802422763_0.41420367574720585","host":"s3://npm-registry-packages"}},"1.0.0-canary-6c6d256-1609806743713":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6c6d256-1609806743713","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6c6d256-1609806743713","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d1c18061614f2bc45689240feadf92d90d856cab","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6c6d256-1609806743713.tgz","fileCount":7,"integrity":"sha512-WtWh4Wo4iOhGZX9oAmuM9VeSKBg/1itTdWuTH2hmmahABt3exbLBDESJU0bblMyV/k0izpGoXigJVL30uV18LA==","signatures":[{"sig":"MEUCIQC/BOrizbx0ES5+L7l9agCleRbncuQUcNJu3lPUDOMKzwIgFt5s6HGtxyxsK4tIwPzY3W64tpK7cbAWlqtpFEYWg7k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf87POCRA9TVsSAnZWagAA9ZEQAJ2vhOJGqqTv3nCCndeX\nC4t/dYg/f88EYLDkNQDNosIcmBmU5F8vRB7ACaHCvAYQTqVJ/xuGVrYenYYt\ngfGrJauA/3vobS5M4BOgC6GuiPEpF/E1s7ADD3wFGvMD2jVqZ+kwVimIvvuc\n8SrTGakOrzsM7sddX2cqGdpMODThQ7SHEBru5rzxa2DX6Ae5fntLLcqVwsbp\n0T4kbHVqAocR2sodQRpWeOafaILYSxekVub+gOafxTUO3VRYdr4mWiaMaeyE\n2ndzOEAmveqKcoZZoVJzxAx1TfNC0nYrwKpiuu0IZsXP0Wu0/ByN7fP3jVNm\n3d/OIrNRYtv3TN1A4uGb9W2V7JyycsOrFyVXaKz68IlMLg8jMJgS8j+PZR4K\nEMpNzBFuFp93Q3+tGaxbyMmirboeumhEuIslm1woQ+WI2DFmD/7P6xyYJ1MM\ngFc99r8zLFigIdHf6NzaIRbDm8+YTC2oMJikrf8GQVr0vkeE27ug95fsoCNh\n9jbmBUhHct9cqXh9z4zty0aSxFNQkPho6B/pdOz17zjUqqtTU8fmz6pOaCZ8\n/J3O5qY839jq1Q/KubKbSHc9Z1iAVnMxzbJ7h1fSFT942XAFr6ap6vGVquv/\nUGqmediCHsYZeeLLhWkiAuHw/hSkvAjy7l46OSgAKEejmJmXuqHDQnLzACbE\ntycy\r\n=oRKp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.20.12","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6c6d256-1609806743713_1609806798438_0.9147677910407928","host":"s3://npm-registry-packages"}},"1.0.0-canary-9305283-1609854149140":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9305283-1609854149140","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9305283-1609854149140","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7ba85241666d9289ecb84d3a64bb53597d6a6fe6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9305283-1609854149140.tgz","fileCount":7,"integrity":"sha512-7kwxv8JBfSGcW4j7o49FjWVypsOeNidRBK4zzh4bCmaX+UrNCuPjJxIisX9BcHIswOAPRWOH4kkAM1lXjskclA==","signatures":[{"sig":"MEYCIQDRArbtuRpTwRXpj+LvqK+D5DJWJNc6FoxKNyaXbTe0AAIhAL9qEDGeR2y0Kfna0kcThyOzo9TTqD+BFfp4NVS9C17F","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9Gz1CRA9TVsSAnZWagAAMxgP/24O4jblZjy4N6dj5KlO\nRJTRN+74rE0LUTz42wXf4tLL0xSukhPwyyTDcE4DZTMch4cmgzHqxdQLEPR/\nE+AbtjRBWnnB6iiGOjqx8eLJrxySe22Z1LWoZ+mNsu5Jbooh/TpTroi+DnLV\nKYtB59riMOQYYG/IsMMt/aWIpVGI7ns8QK3ZFy/kUOFVtnvu/uLtOJZD/MHM\n/v9AEcARHzhtiDgCoMYWrenoYXwuOD+yF+ozlcc6va7GMsg2UdtMZw+vB1R+\nNwzStHGV0ftC+ubtkwZEX2k2y3GVDXex97hPvULKzfCjQPSnYAh/Gx3qhZrJ\nMc/7N7Jzeyf2k/LEPR9FDc5spYWoKlYqLqmS+s6mdJPCDpuVDdDVSA+wiOJS\n5H35PaxDiQRQ+bFNhN4pvGUbvPkq7hW1nazuXnlTe4U1xHmPxU2BkwoMyUKL\nxojxNIononxAGn2Sk/jda4XKtowx3iE4nxc3qlROiAmHC7KzeLAnH7o5O4Mp\nuu1OcGeATlmF7cuDRqJJDdHr1wrKFQ5a55U4VDy0oSQSjNV1DmUsXF80qYzQ\n5Kf8M4PdZkAwVnMOBSeaZCYN9hT6BVOayN4lWxGvqabtakmpjx2efqYVqQjB\nhdAcvZp3ee3CioVHl75HFUHiH42X6fuYgFXL1fn+mSdSiE6P+23kMeHnvBu+\nZQzX\r\n=fqIv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9305283-1609854149140_1609854196569_0.1635372213365487","host":"s3://npm-registry-packages"}},"1.0.0-canary-dc72271-1609854266237":{"name":"@iadvize-oss/store","version":"1.0.0-canary-dc72271-1609854266237","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-dc72271-1609854266237","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"27c39d7d4588f84d5de9cf333aaad8342c43897b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-dc72271-1609854266237.tgz","fileCount":7,"integrity":"sha512-s7jtS8lTK/wH2gz0zTh9Uk7yPJ8+qyq8kwxncofvn1HsJqjQ8nlzNLe3y+AESrvrx1jmtXK2T7eikKGyF437Xg==","signatures":[{"sig":"MEQCIBmfrQlH7JAV+RIgsUVXiu38ZaL95QQvLYom51fx3IDWAiA7ba2ZaZGy4BkTsyGYxXYYf5qojPhbBMigMqCY28eQpg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9G1rCRA9TVsSAnZWagAA+2MP/iWUohV1hyEoQddAjUPl\nZN4SkxhxV7wvU74NaMaCw8MKkQozs82l1WS+VJhHeIfKfNgkS19HLZ6Ujryw\nxkOYAsPFrTLLJjuHBJYygBCsHu+Z1lbU6I6lTnhS6V9/t4DMFfzYX4YNEBTG\nar9BzGRvmH69EouyfRG8QcSieau3fCOlrzvY+a9s+RgvlLBxIMhOlkMRYje2\nQoOMDWv+fksageuM+ptdv7N6F2RcPjyQvs7HA/Aasz3GJwwloK0o3m2/WEDt\neY6he5hfQUMqH6OZqriIig6CE07ZwxD2NyK7cydCTVHjVP2fk7exhFu7hYzR\n5guT9TEnlyyVE3I/yx69quXv9tmwgYbx7KVj/fKJoNVMBMuTY4Q1M5CFatLY\nZJtEtrOcIUMxlQYntdikLwEt/ufKu7N5t4RVwUVgMaq31RXPGUryuRUl0Ku7\n5lPHMnaOETwDhb9HBc+nnJ6BLDAOq+aoLY0vb69Uk0hyz5JL/4iyrhL/PuQF\nyh5L/6Yfs6iuyXsYL3XoETknVuwCcIAxPoTfWXKdKBBLE52cRIA0jGQI5aYl\nxF7QXoK/L5QhwOu8gk/q6XJ5n247EafksXabeICr1QaWFngZKUlZwpmdECpO\n74wNo8yLcQ0H/aJTVzdNYFWZpqgoED/1VHfrZxbYHISSTpNv0oykCRt3kVKW\nfESv\r\n=Et50\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.35.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-dc72271-1609854266237_1609854315213_0.7874145645323731","host":"s3://npm-registry-packages"}},"1.0.0-canary-e942ee3-1609888652343":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e942ee3-1609888652343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e942ee3-1609888652343","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"437785859d26c79104b487ea00371f1887212fe4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e942ee3-1609888652343.tgz","fileCount":7,"integrity":"sha512-v5bW5JMB7baghgdv766EUOoRJNQ3PW2tdGo+kMON+iKHUNtb7DS4hnjzXA2rZd6QjzrYLiVx+yr435s1Y7vhsA==","signatures":[{"sig":"MEQCIEdXPqZiCe5trP3EPTfXjWF9nhs/4tPKxWJMq8TuXTIAAiAXceofjLs6gTyPoGFY1ctcznWWVtEH6rZwXva8c6SWeQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PO1CRA9TVsSAnZWagAAulsP/1R1JTZD33RdaQdDzoMQ\ncJUL+wG/nn8Tj3PrDKLnQeRBHp5i299tXFTEq6Z+jWCb8pJ7GZ6kA1LvgYn4\nByHEYrAJisITiTyCKgzz+KMYQJe7Ugt6azXp56gmkDuxaktDuDx1tblCXb4F\n6xGlkfnRJiEGbcHXij8uXGOj7xl96d/i9vgPtVQ2G8DUIuxMAH1BJdbaSQl3\nR+ayeKFU0gLSYES8opahQHIgayGXr4t9ym0zVdLh/9IQW1gSIH7MsvJ38Vmu\nCZDmc5ZPpx3ed+eWsGDboFWI2M2q/zNbbXWlJBBAqjoBXOdwRb8IbRQishyt\nDJwyW7dFuzEW5fNeEfGLAKdJd6jrUdcXViE+hcvP54Uj4M06Z+R7duo5+rqe\nQ9sINNlLX34b9QOv9imvVt9OerKU+IBzI0FvydKoEHaFNPtOl/EdpenXqKBW\nhavw2Jb5/AeIM0eLE5r4zQHygurERicjB5fR2aw3IIeRNkengYsoAIx3+3ck\nz5DYhdiudqCBiXvyq4u67qFTvp/TwEUn35UaK66PMCUSpJmw/kN4UR4ox2x7\naiVIA/GD9kmllDdIi0Oop5qv//ud4/qghOn4TaVpHCVQ1W7lrwgqESLqj9Y0\nMPswoaQNhylyNTu2CUsfWEDxtfEigPAjVe4vJwenN7hlVWa+kkl9yXi4sqex\nneJv\r\n=tapT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e942ee3-1609888652343_1609888692871_0.6968692851928533","host":"s3://npm-registry-packages"}},"1.0.0-canary-6889c81-1609888809847":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6889c81-1609888809847","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6889c81-1609888809847","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bee730f9a38dec3ffb08afd3446b1cafc0213f8b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6889c81-1609888809847.tgz","fileCount":7,"integrity":"sha512-wgMtWDnymSQgHmM2p+YtGFd0W6OuK7ixAOM3FTjf4s5ApMZd1TmRCOMSObvGTEoIVhKWYMNtjw9jMytmz6XO2w==","signatures":[{"sig":"MEUCIBViPDxElGbHnLb6/sK/xYNFaZdA/CJvtS0m0VCjL6BPAiEApsHRNBlMS3QtSIkJe7SShqceGxhRyKrkeeG0L/FNODs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PRYCRA9TVsSAnZWagAAYYsP/jjJTufIPW9BoRAggI+a\nyx+9UZuBARmtrdMzX+7jfcsNlPi8ixddniXyc6b+6nh1sB/AsWQ9cZAQooF8\nmW471YmNUzYjfemJyDZEcA5VyzAMaYoPEkPY+eQVJhxyTgY3vq6sHT7AcOse\nW0QstyarHbRispGCwOlt15zXSI1sXdQGY8/2OS09SCt4z2bphc0MbqgfDQZp\n5755S8mjt/Sb2jqIVmyWVlf//M53wAl3OAXQRTj+h72IowrLFgjogXI8yllZ\n3Fld33NBwUCiMSylQw1PUmaYTGTu99aA7AWBGc8aVPcr1n/qQCVKMF1UeEWM\ni7sODgRvoRJsq3Pec6J+rt0NmxSg/xRF/Dtvq0t0Dk0pCBGNrxROzsoNzJ3g\nhy3son8Kqi9VrD2jn4zWIh5KtxarVUZR072+SeevbtgE7ZVs5n0ESBlR5OwS\nZ7D0mvUKp6bwGsS1pc42xBHYmZ5ewgnrCsR/mgpYqxotpullMR9AtXcYU53e\nSWz04HBM3ics6t+QKbLpHLxgwwjW+DB0fUYvj+BnsbuakW1MDJlMeAHkUhAF\n2lQrwQetmUw5zpEu4ZbmOIKss2X80sfdoqo+SluK/JXdnaLXE7+PjUtE1md1\nuCzOaQoceZz5StWezTE5vg5YQmUyTD3NJVjBqU9A+Zggn+mBQ+fJk8SKIM4V\nUP2x\r\n=Bqh6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6889c81-1609888809847_1609888855681_0.7074377958700564","host":"s3://npm-registry-packages"}},"1.0.0-canary-f724266-1609889790834":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f724266-1609889790834","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f724266-1609889790834","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"848c2c49d35eb02c01c68e20695b1ecb3b2699de","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f724266-1609889790834.tgz","fileCount":7,"integrity":"sha512-hKr1JrDAQ8iwH8l3Wlu4jqQVv2S5gr+YInU2HPAXAOKiBYlekeSuu1Cm/0anbKOGXteM2Pz/z5xqtpe4h3BmsQ==","signatures":[{"sig":"MEQCICA2BV6sgWti2T+uDB70pRFHnbx5/OhPDGwgpZrumvh5AiA7dH2lh477y9n9rSG7K1APEoz3KubbWqfNkyEaQ0JlFw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PgtCRA9TVsSAnZWagAAKokP/RehJmhede9kRELatMXb\novZQSIk/tuIK9vQ/LEC+YvFN00iso1zc/0Cl2+VcdYpeKh375RqTq0ZigCwr\nBbzj7gyDiGemblg8Msi1g/Z6+NsXbsw/utZ8uF46+Y54S2wA/7Hb6p0oaZLW\nDvIOav/RPt2Aqbgu/Jom79jhsVf3Ylxb/Zzt8SQp7w8PAi7fe7PblvH4eFVo\nqeu4q8mggMIML+pLDiSzJMXfWZT7MwaiXdWUseITyhPI60tIe0Qe4OGJJNrZ\nRd8QP5+S/fRxh7vA9vyvIhPmBSm8WgX4iUjz2JqclPjs1W9omtFt/KbLJeDe\nnM8JiZs45cc0fhCmtU83WPz1vqn1g/vfShidizQCK7EmaXuMs3QyUEFCqQBP\nWG95DRbur53UkKuVTNcLC47kmBm8+RuJgRdLXQnGrfn7RcVCZnDN4JAmhSve\n8ZJvGBWO57PKPYS4Ll1bpKqfCrBp+9d3aEYeINARhdjt9Ot7gapMt1fLXfxd\nwKBm2ZWNpehiNL9rCLskuhvL1Cu8CqQ0GC5cMGDVSQcKfR1zVl4zDtBaLPKB\nzFss6QbdVkKszvr2PDV9tNmtR1ruHjPqtxjDzRJlbfUvtFjBirKPW4Rhwk+2\nIisbDerHHx7dL5oD+xzh/382du/CahUI6PKIO1mDUAv2mPgujD28WQWQsQ2I\n9WXs\r\n=DLf4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f724266-1609889790834_1609889836654_0.15433723370224972","host":"s3://npm-registry-packages"}},"1.0.0-canary-ff12119-1609910669802":{"name":"@iadvize-oss/store","version":"1.0.0-canary-ff12119-1609910669802","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-ff12119-1609910669802","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"52377b08b309f3fea82fbd74ce4675f7c1a39e24","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-ff12119-1609910669802.tgz","fileCount":7,"integrity":"sha512-Kc3C1O7em+AHWPIwYeaeak8hq5ptji1ZpxBh5C3WhdXuR6KacgwlLdrplMr4LY84dZKxA9/VSia/ZFz3J2unpQ==","signatures":[{"sig":"MEYCIQDA+QWjf1PbClr2Tza94YdhTdhqRKLYxDSwPs+0L3oWPQIhALYqSeVXGRfRzC6w8rNn9smKTVCBRWA3DyA0zqkT8+Ag","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9Um5CRA9TVsSAnZWagAAi9cP/A1U2WAHK3vSJz4A6wt8\nkQPbOhlKVe224ipu87zeVa9z/Ds3sDAI3xYhxH1GyHo5nxYAyJvonlIZ34Tw\nzMufDJfawWVlWhdLslVvG0QHkQg5Nwwd2lxRzzCMJ13k2fW5ccbGEKcTbez+\ntqLZvrZGpMshbpBpqSDAevCpenYoK0MVkKxOTS/ihs7mu4FytZw+LiSXivmX\nw2CwvkdacJyKWp4xp2X6SqlpKZVzeFz2WQpUUS5MY1SqKrtPl7ORtYWirCHl\nFpUknhfOYBWt54NPLaxT6+69QRaKW8gIJaAnUFptX2mP4fdfF8b1ww7KDI4P\n569Ny5tHQCzyfXK7I5kPUrpetme52zGHdvs2arVkt4hELTc+m35n9aT36k+l\nnZCPnXz6Jacxi+BS1YHFbIYyKgbOd+9JfErHm/66VKBrIyCLSG8KrxXb/0eB\nUME4HoIoJMbhqdQjEMo9/slcl08MC/DzzVkOEIGs2QU0/5VHgn4vWd3wU82U\nDGFncT897KHIzoMxwXSWLEgqmx7YgerYx0F+6/qLFzxXvRoOTTtDTy/8VF47\n3R06g8l78chsRahmuJy+Jguzm+q2crvTra5prnEQtYeb6Bxm5BEkKAIFsFJk\nF4gGeA+/z04a0fxIBZxX4qFeOqGHiarLeUMhJbtijdqjce11kE/c+VHrc8BH\n2m7d\r\n=YGuR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.20.13","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-ff12119-1609910669802_1609910712607_0.28313265063778337","host":"s3://npm-registry-packages"}},"1.0.0-canary-ff12119-1609910671576":{"name":"@iadvize-oss/store","version":"1.0.0-canary-ff12119-1609910671576","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-ff12119-1609910671576","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"12944215146865e6b3182b3d0dbac6d560f848b8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-ff12119-1609910671576.tgz","fileCount":7,"integrity":"sha512-4QzBNyw9s3fVNLoRkziyJ2BV26eKP0hXzDrSV0z/1ZrGAuZ9TdOGGSyF7jvXItBGccpg+MGumjyo+xWZQWGMzQ==","signatures":[{"sig":"MEQCIAD96WjStgdmIeLeF7vAyfF2DBnlNIfx+Kc0vbXVQX9fAiBuzwuimMORQimwIrLfsCXIn+uDqOr0XTkE3jtvT4ov3w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9Um/CRA9TVsSAnZWagAAcIYP/Au3nsMZj1n6oaB9k1I6\noSrFAcloINt4zoBZ+ovMJg269cVw6bNsDovqlmlSBCStq5UVqPzQJCx7w4AU\n7Hs57SPGbP/60uf/GBUBuE0DCsh/I4g1W8G2sGHF2h+JMPggdFywDpfQoZwk\n4/me5DM8Kz6v14NzugZTXEXgqmRHjxzAYA88eZum1XIbwW8HHcmt4gscabPw\nRWkRpMrk6JbK2w0SpKWiDr/OSZJVSrXXyU2F4zKIrZzb4vJrjfE+D2HxzQnI\ny4DZlcgDxFkVl2V2zujMqNxv/GMUeB/shsh+9k/o6cHwNGU/VpjERnzKZbMK\nbTdQKCgz39f5QQ1DfVDpZQWjFhhkPnJxnkIysP9SxJTDj8YCf35Z7TXGUDxX\na6C5MkChRbKQENunh19vrqFRSOt5wQYewHaVUv09xnWzlWyXhPTXpZbd7Tze\n/AUgnWVahWc5fSMaBKgYZRCcWmVbI0brJ7zxgHJKSxZt7Wezj+rkomntEc/N\n5FB7D/KM7bKHJ/c8mHNYkM2xkUC0niBeyx8rbyGbm24l1U8aOoAC0DqQvx2O\nd+K+wDWcZIm1xzQ/UvH8aNmJGeCbgraqrRsZwXW1r4pl5CmSTVKI9+75VByK\nE8JdHFBUXlAG4amjoCLmbhlgIIYey9f3J5CJAa9f8lROEHaFU4t923q4tDVh\npKjk\r\n=Q2j3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.20.13","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-ff12119-1609910671576_1609910719118_0.3529491413737529","host":"s3://npm-registry-packages"}},"1.0.0-canary-1e06a51-1609944005991":{"name":"@iadvize-oss/store","version":"1.0.0-canary-1e06a51-1609944005991","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-1e06a51-1609944005991","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ec88a651e0e45d140914fdfcf8675833d36626ca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-1e06a51-1609944005991.tgz","fileCount":7,"integrity":"sha512-0Vqa3V6vJcNy/+9DxH3lk/ZcWXD1+TPYy2MqR2LunV0upsa8ofk2pY/6UNiiz3eTWZ0AkDQdM3TUn94h4aN7Eg==","signatures":[{"sig":"MEYCIQC68kmFPY4rsWK2CuTeVlmuUUBNDwgVtvRzxLOnxM8fcAIhANZ+jOA5CVRBIvFCnVVICcAzMHx4x2lV9odhiq8KSn6Y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9cv8CRA9TVsSAnZWagAAxHQQAKFkiI59+QpokYkAIhTS\niKUAPvDfIRrrybszj5bG7paycCbOspLwysv4z2GliLqes37A8FMKP+dottoo\nYkpB4yP35P+4AAjx+u+8yWo931su6ZB22cL6CNYCfCSSvmQPYfFkO5A+HbrN\njZdODQT4E575tX0ZavpNimEwQ4NmNxX9kszs9WgbiAsfrD2kMe6t4Hac3OmG\nZG0oQAey5UDZNNKa3gPtuKHZOaBZ75KIXvm5suYRhdpUjJPHHeCFMCgV5U0/\n5/NbKcvPNmL+pMdh0RR18g8sw9pCIUNlWJqLGIIofnkhSC/l8wgmZWMqkDPZ\nFNqRUlz1SRc/NDPq4dQHDpE1WsJwVDxtiGMMe7rc6feJSy5ENT6Fj8PrB57d\n2oNfqRY7YGjhP0gh1KXhe8xNuY6a+9hp/LQuYiCXJZ7JeOfKMyLpmlGdLTWc\nLM43qImIk5IO1CxrLpRDoD14jSh38nYKczepMzNl13yJWo/sobJ8+EAkjioe\n04Z+1tqd5sXecODRcWduF4s7bH3I6FePN+NHwnvkH1KvayCmTo8YnCSjHYgq\nIIF4AkHqqYG0OtBNq6qq88PHC2slKkeeetVkHwYfX3YHVEuRr5WzeQbFEB8H\n0eq+BUgEWeTxZJCORifwpO6Cz5eRwO0wvvMEA4KLtR8B91VCQwOUsTlxS3Z1\nezn7\r\n=9njG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-1e06a51-1609944005991_1609944059775_0.6549635638450153","host":"s3://npm-registry-packages"}},"1.0.0-canary-c2a2646-1609975263623":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c2a2646-1609975263623","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c2a2646-1609975263623","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8908c872932be8333f81cfd90d8a8a5774ae4b82","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c2a2646-1609975263623.tgz","fileCount":7,"integrity":"sha512-dKs0FOQQc3LUC5bGm5u4xXLwkxSkgmcKFxFE39GbP7pIi9xSNeuvpP7FLIsdTFchDIvbWBTs2c+1OwW+WdsEcg==","signatures":[{"sig":"MEYCIQCP9lGSC/U7vwuHSrPQ6Hq0Codexi+CXCR+KnE+cA5dBgIhAN6Xzsb/Lv5B1IhYmkcacUKophOna0neOYT4Nt03kIUA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9kYWCRA9TVsSAnZWagAAOgUP/2Udp19ZYOBq61PWGhTh\nXlGa9YNzdOxaxAYpITZzJzQ0V4OFUq3XdDet+kvZeMEBw+HjWNB7bZ2Qkqz1\ntsSOf2TqmzaqgjBxl0mndvNMl+khPMZ7nH+2wcbVxb5/K8Mz+uHWoMOWf1zG\nYkcB7NLYqlfVumaD9IXcAUCl2tJYL4lc+ltHC0v77Ppq6YeepFUICoatvp98\nsrUZb6RU5ykd4Ml7tKAobsMvCokxS0QfePRVo8Qr7mwg/oYHwtQWQZjcEjAh\nnnwncLuuxwl+mbH5ics+URKeh0afxC3+X23AseH3FW5vQv4EsHKSE7b/JwDh\n5l7KSlBtJWOIsP/S063ez6P7w3d99zq9nFEEH4eNcqXJ1C7R/WB7DFQhy0i3\n2D/8+W97w1Cpe+czbjplDx00BBWCKE7HGEdfrs2XigQwjRpzihf+4+PUJiRl\n6MUfw9W+q8GGSdGnJ0sPPP67tO5Q1p3psf4fjBw1HXIu/p8yhP+HEku1ar2u\nBDSfCiq+ms5zfaMGf/expVPA5Emg7iDNPQSbjR8ucJbCVIrCJOEDnRMdlVth\n/TBPmqr/NRBnvSEkjv0ffnJ6cnwECLJKL973CroCKzGY1o53YuE/xeqEa9AO\nklWGuK9C16rFSp9SgMzkusga09BEVRGX9oeXA+hppVRjsowhxm8niR6mBQ9r\nwk6Z\r\n=v8SG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c2a2646-1609975263623_1609975317878_0.26385047567088304","host":"s3://npm-registry-packages"}},"1.0.0-canary-17235d7-1610061466343":{"name":"@iadvize-oss/store","version":"1.0.0-canary-17235d7-1610061466343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-17235d7-1610061466343","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"efae144dfe4e71496b62af0dc16482418d467266","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-17235d7-1610061466343.tgz","fileCount":7,"integrity":"sha512-d6R5zdUYKG8K71tIcskXuXhNZvy4WtHfSSQtu5kc+0V2YJlvTWTV5MSMjSwGajWKhMsEGjIX7O+gdcCz7QF8Hg==","signatures":[{"sig":"MEYCIQC8K6mGtLrgdlqNTbQOCeJDfkS25L64A0VkbQ311VpNvgIhAI/a5E8qd2b0odDwbNfFyKQEHkUci4BrSCX0O0sFyyuq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95bbCRA9TVsSAnZWagAANmQP/i1t4svEV4VsHN2YZ1jb\n+BlOPwNfN+C5AJ+a7QWY4YbjeMI2Vbx10kyHnOGae7e6v/jFugTjTxHOON9I\nlo/nbM+oKEsN3hVPZLvSHimie2TviVfApNpKpSAp1x9PrJtP6lKQCJ1BXH8S\nMxdCQoJUt8GRrmWRfCIhRSA2frl6wVdtxGVPpp8Q9wx9AZu5SIewSJ4KsZ3S\nGywCX+9PcWHoNJ0V+aHR/Ou85wHjjW7lRokG6J9sfnRacGs8IPHN1kr9AarR\nBHRc3VsWR7LFl98f0fMIQbnNn/VNY/uAhn8BICfCdzR5S4lxYox88e2RGfql\nm3Q9KSYOZzQsacoHIaicpyndyAvq248Aoxfr7qi+Dr25gTCOMEjNS0cCDgW3\nGmOOjo2Ej2e6FG0mE0wcJyj1uWMQCgOOJhbIDn/+2+oxzuaNVc8QVWclxsI6\nD1FOnMfmW13DJR2QakPAb7cMWjBKrTM/j/jauQ6OSt39tUCOQC58Wj0JNPjT\nauyg7ej12q3c1UncrsJQ5lVOEqpMcjfHBGMvo8ot4h9CWX8NEJn2WBG6AEha\nJ32YNlEf/2ZrwA7EggUGCOqmxlNYkmSv3gpRmGuxZMdDANzfEby3ePX3anKs\nVb9XXdLJ1NMJzlxpIeSqDk8cSwPE98WcLszYTPjqZoMJcWxbOifj7RVSlVZf\nQCIi\r\n=xbHk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-17235d7-1610061466343_1610061531475_0.9042333284323796","host":"s3://npm-registry-packages"}},"1.0.0-canary-e5c109d-1610061508520":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e5c109d-1610061508520","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e5c109d-1610061508520","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e23b390dd22fb80285cbbf4b480532feaa779a51","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e5c109d-1610061508520.tgz","fileCount":7,"integrity":"sha512-UAk1SkWcXNaxiYJHrONFTnACUvSgXXyqenwdTbVFlqDEgAlVWyTPtyTmycvanJ9Xue9/SgVHjgrzhYFmF1DviA==","signatures":[{"sig":"MEUCIGmUaLftqszOfCTDz79Uc1WW+cVUd5VDfLCUa/2qlQuvAiEA5PRAF73c+L4e2RXvrB0VKjTvZZUnsFgx8vaG2wFxAjM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95b4CRA9TVsSAnZWagAA8CsP/j2/lpNzRwVNLLa0RjG/\nbijmQJihFr5VZkegFAvOJVt/LjjbP2NmiFW6STwpO/v7vgsIPasl7wrCrTDR\nwCEP27I3vOtqW5ZOn3bBzbrCrM/CP5AZ0mo2jDA+nu7tlU9zMcWSlBh1Eo1p\nek7hkB8YxtIimsRPLbQzlUzEtRtGBVMCjd0UecbLJ6A0l3rK+Dy4i7M2kqdS\nFpfMIrPyRZuOSAb5PB+HGaX2gRH/BXhR0djHdH8VtUfCDA0c2sxb/6m8jDdG\niOacMkqzL6cSMziFiXj0XQ8MBGubpJojMkWqx5aR9RJ9HIRfqtdCxuohrN9w\nD+Q0WAcOelcwC7BOXtzmOpWJzmnHd+3OOBveXaSFLzWPzuiFmVqre5VsRpRk\nT8qazxCLlDFOWujQ7uMSTBgaGqGRnPXBIrTU6/oaCSDlNs5IoOQ/6iXLcnSh\nYP7GAruRrFOwwjE+szqLYDF1ElpsqsXhOZYASv7kKWuNOTcWOycqLjxKsHME\nYJEzMhcYDRFXyxxngnPhVlD7jC/hNTMp3SA25nf6j9xsluQ01E2P2683zEMf\ndUCRHHge/Sovmx8OQ4NYtNDSPQtFkH0oxOafxPmckF9WgDZg3gql3MwYYoux\ncQAHEx209Amjexjb2vgbPrh1F9rcXNPQOYzmuh9eJ6wKFzetIXYplbkt4gGf\nTbJg\r\n=Ka8e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.20.13","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e5c109d-1610061508520_1610061560318_0.46670705389887024","host":"s3://npm-registry-packages"}},"1.0.0-canary-aa9e786-1610061564488":{"name":"@iadvize-oss/store","version":"1.0.0-canary-aa9e786-1610061564488","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-aa9e786-1610061564488","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"07d5b81e7c78c455a9bdd81f44fe433bb2b052e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-aa9e786-1610061564488.tgz","fileCount":7,"integrity":"sha512-e+0JFV/plmLkp3kYr17Kgmo8heegCF+yjPrOliQJHVsGsn9IJXk3TYfIQdJXSxmhqOMXtFFqEv3h36f7l/pImQ==","signatures":[{"sig":"MEUCIQCWdwcUbx/mPvmIZeisiMmlq2our5BwbhsU5qkeOofS/AIgC4Ndxplbl6ktkZYBnA4ZmB6/Ghfu3RT3CR+mCRaIsIo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95crCRA9TVsSAnZWagAAvk4QAIxewwMIRHkciUV8j3Dt\nLhybbOT8WM28HXGuIBYXQWuPf44+yg6/IrUo3n5ay4ngkGEFKjr6HtktyB4D\nDQKuPVwBfDKq8cGNx/9dbP6a0+9+is0rJy/cfGc1UJzsX3bkF0d9Yp8MAIWG\n598lfR5ZJxHM5fG5wzPWxyN6u4dM5WaZ5YeZJlOT6RLR6jTpgLWlDYAkFKFB\njyOwiLeOYrwaAfPzPSoXMP/UPoKlyQ6LClP6QFaED1CreoqQXJEi3DTKeCP9\ngKQynRHqhUGyUqNzfLCDVFOjOOg2HutET5ZdfgTbBy1darzZ4fK/Q6xcuTgw\nOkpq3ydmfCUACSY685KK2IuzD5bLjmdZMafDUSHC4OYI6r2K1uS8X+4fbzgn\n5YCW0tjMCXXPemlL9DXYf3tU7B89M+N/XHCDCGuUJfSahxhLDj7DqcBXVIgz\nn3JJaDkTYkNo0KlcPxTmRjbaYoIq6ZyOf70LBtTGP8xAbf7/GMNnVNjswdOd\nvCYvdoVjXjgaRMN9ethEk8q2xkaKSYjxCbSmzJHIxCjYiqLiF/XHlpQXu3NY\nexs5GLQBq7ruJuGA0gGHfLnTcDD9+pgyQC9DNTxTe7rjwQcWFULnAkA+wbk7\nJfStBjlhL0knqOiGqmsna3d0gurWtU5JyVVf7jC11L6ZijMbmVYrA5/ADqrW\ng7gz\r\n=psto\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-aa9e786-1610061564488_1610061611259_0.010114536221358161","host":"s3://npm-registry-packages"}},"1.0.0-canary-c59173b-1610061671033":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c59173b-1610061671033","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c59173b-1610061671033","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a0c8cbc850b3f214fbdfd7d05cbf5bc1a068fbc0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c59173b-1610061671033.tgz","fileCount":7,"integrity":"sha512-uNe9zIRdYUMtwX4JGPn4CrDeWiWzDbcKNUYlpdlM0GhOweYKK00xrgZc1On2OyWKzQHybWkyBY2F1kGBYHMagA==","signatures":[{"sig":"MEYCIQCKXilkOWDE//1urYVgkfiQa9FlyE72TOKeZQuZ+Rpv1gIhAICbSvq6wK5YS+8RDhfyX7vzO8UmQh/0Vlme4xbODhPE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95eXCRA9TVsSAnZWagAAjKgP/2Yq2PACz/jlwcv8farD\nGVqAecBOo5lmej5VupxrnD0MSykiEyQS5C/W9R8K0lqu7HzembHi73sOgrwV\nrishN9S7kHjIUh/7B7IH0Wl31S9vBwbLNCEDLjE6gaITi6FnHkjPLvnNWUMx\nX11sir+rrGFRtkvbC2zgarsDe42jbqobjtfUZGCxp5CGlMoMX8KgBz2QNPnV\nRezsRgBO+kOI1DW3yhGLr/1OzJ4Rwc+oKkCTrcn2ltfNMd9FHjiv8xMZrur3\ngRIb211Rw1R0GKilI9l7j8jzoVH86NeqGwRt6Kevo/WlsC2cDou8iobMvN0/\nfKtvN/uIrWmNNka83s/6BB5lT81WWEyqYMm5c8NRSMN6LpV65QCuk4VKqSaA\nLndUMIp5a4myL9BnndNZhx7XH9rqzj213aqfFdhLwB1GEJTEQ4CGspeDrYeN\n7kry7VDkYVa+9y6pli0pGGTT6pmqNjlIs3XExCZcbuKPPVzb5Ao5Aw2AUSkM\nYIZf/SuISG50HUNOsLlzHzYjHKSkhHxIyQMyw38MEUYIwiMpBXHvPTCUy+z+\noqpA+T1WONitni6O7ONsSsd2eyvigQhDdyD/5G5HkYHYG8L6ffyPm8mv7dbD\nLnyrJ78M4bF5GciqfduGJ8/77w6nz2/r8T3kM3j6zA+7I0eJrgHOSOLAt2SA\nNGLc\r\n=cxZq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c59173b-1610061671033_1610061719030_0.35922119080996984","host":"s3://npm-registry-packages"}},"1.0.0-canary-2e2ac88-1610223842439":{"name":"@iadvize-oss/store","version":"1.0.0-canary-2e2ac88-1610223842439","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-2e2ac88-1610223842439","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"06bbb9ba9e7ded3c610d1c9a88a3a029bbd5f338","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-2e2ac88-1610223842439.tgz","fileCount":7,"integrity":"sha512-fptDssaZPw/gEyOSZ7OjN2DZCpuagZ9RvEaZ42MyHwkck7Fq7NDX/SigOs3XnqXcOSp2rU7z+2RdsIam4AI/fg==","signatures":[{"sig":"MEQCIBmhGo4aYJRIFYriGDMKo9cZAtST9oDUncjYvW/FuKmSAiAlTjKnuy6nh4ajBWr9S346qGTSvgomMg1QYs7NZ5J0Ew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+hERCRA9TVsSAnZWagAAcxkQAIPeF+xnqgz6p1nqDvNV\n4AEuUgwupviaQVe2p9ySVUslei1qtgem+H0aqUFC2YgNiLD0jtPDvVMlRX1h\n1mCyQNOtHvvH3LqaXKvA0J6YGRrJiArEYyAYuYrv/s0k4noTgzBTj0qLWKgf\njxxNvcAu6H73fcgGsgHKd/ejl+so+5LEpYkqI4V4LFw6XwMC2xgBuUlRBc4m\nUvbEcMVxCjHiq2BQLgJh4LWMOlhF2zH9gmmlhmxSCjhWdxrk/qyoe0fr8Glx\nab8dyNQgDYAfc/p2uJtT2dbg1hZhgQx+oZuc1InK0O10gEGHSvP9cBmjiVyv\nSGAaanO+s5CuxDCZ0tMFuK5aYudk5VQk6N3DNoGUeze6IwMwnZ27v5A6n+km\nWSKYwCqHyGxE9BB+qQl49kPXkORZcR/ee8oDzHZQGghjPQyqXvkxAkO511tE\nBcbBgNsaoe/6VrSkYZ/9hWE8Wtj+iQYlyH/Q1UmqULYOm+9TKVfnE1MfnsPb\noxVtthoFv7Wb3VQkM9/PhD2+zM/CwKxkwcM27oEY7ph+B4yAlTxTvdS6ga5F\nq5HpNRbyI/dBGSUBkQqqHqku0Iqyd4gEU0nJRkQ/o34vzLYYmudd1yhycGSb\nEnbCgRfLNuVlm4FavGMY0vgU0D0pUq38KqfFH9lug+OwOnSxn6Rw8IMOZOPG\nwpRn\r\n=kHr9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-2e2ac88-1610223842439_1610223888507_0.15325299483246702","host":"s3://npm-registry-packages"}},"1.0.0-canary-6baf277-1610320471022":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6baf277-1610320471022","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6baf277-1610320471022","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c8724b620199483af7ac4ae4d91ff7d2d41b77a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6baf277-1610320471022.tgz","fileCount":7,"integrity":"sha512-ZtTaiCZ3khBcVAU+pQrqf/roO1/tqTyhJro8V6n0Ze+/Q1kkBNp5jP+ioZtLps6heFtQt82mLVPSnxJNsFPohw==","signatures":[{"sig":"MEUCIFutlZ9A0MKqJxL4WQAeuzZGDQ+wxTE9zATjxL/SZEDGAiEAm7kJrCfd36xIjlcsFufMFPUhknH7o3XxuWY5631w7AE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+4qHCRA9TVsSAnZWagAADYkP/R/u+UrRKZpU5P5BJWRq\nNHJn7qf+iazFhOf9aHw1KKAyM5GkoyixylUXMDDUWKnFpGcJAzyb3hXEjVJy\ng2WQSxhUBEDYtv9lSrCfKVtJr33oqek1g6A+U7jqdwD7HYapM3/8TFanF7JV\nf3Fhoh/tMBCZbm92Eio06Wh34jnDVSWYl7FxDrTtlxn7s4BefK4XoPl35Znb\nD4qwLUSu/MzD7wSj5LsUUY3oFD6oHQwoiKhnkq+vB0UBu9vfgyP/nT5RfakY\ntrXiqi08a7E8Nc3eu9svtJMg6PPy/jkYHQZJ+lkoor+4V2kmaKORIzERgjcc\nEvcuJWAWSvv/E8ic44fSvu1VwK4iH0xIjDktZYPjLjdxh6JClZ534BREwZq4\nfGO2ctjCNViqgWTtu/6nQ9GEa0mDYROsCllDhF/Pr2U6ZBWrz8YzXvygj5mO\nYiu1Cy6wSUHITPr9K00C1nSHgYMFsouzY7mr4Kz9bybf5/tdGMsOKxbCl8aZ\nVgWQQnnO7t40y+n6dB35xHXa95xnOdZ/JpgyYGJa8qaaSrxkvA8Gmh0/UVTI\nf979SfjubnsY+8WpQ9wuR1ih++WhNXXGdkGRH1sAT2HyDWaiNhaXvq/6iitL\nip03eEQSidihhQ4qtJEHaCWNQaHQYsz0yOKwkHjYIx/GhszqKQVTqAiq/MkL\nGqq0\r\n=y7dm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6baf277-1610320471022_1610320518984_0.2241504744588747","host":"s3://npm-registry-packages"}},"1.0.0-canary-5be35b1-1610320504988":{"name":"@iadvize-oss/store","version":"1.0.0-canary-5be35b1-1610320504988","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-5be35b1-1610320504988","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9fe485df2e71f4a69917c990f41bd33d0f242c0c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-5be35b1-1610320504988.tgz","fileCount":7,"integrity":"sha512-trFrGWurvSPplQ9XBlxuOdwXhdqCjeA0rfc4YgpcYYHLPoI+DKegBLtNUIMxQu0JNhW8LiCWgrw5mhVZvuXx7w==","signatures":[{"sig":"MEUCIQDbOSRMCykC4aV1TJJkTd6xNhIp3Z7lZDBJYaJ+nEn6oQIgLzC7gRLMWRIiYNdEh460jhSAfGDeSk33dk1Mim7Cf70=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+4quCRA9TVsSAnZWagAAX2UP/1ocrbqNoPpkuvAJc6p8\nqLQlTDskNHis5+FavfirCMHYRh0ZR6m+R4l1fZjsRyrMakp+CVp9MvFwd3rV\npxjSuowc/Hh4WpNtesKjNo/nwrJXHQF/fSyHhD44iMD/+gzXGaLC3Zx7f5AP\nUC2YMGR/rzZWes/24qxaONT7sgb2WPFQBiWZaU3WI91RRPiYiZ+o9gxMbTVX\nwF0DioNvqUNzDybSz8g20H0TRK3w8J6Yt2FDS62+ugTaPHYTaHGuy3AwJs0V\nSWXFHPTWtcL9lcbpFeMUouRqAogAlHJWLH/IZqLHkZC/N+rphHiJqdZVRUUX\nHaVhN1CV1nzbTwUEe07iCTIeFCRjaDPCRKlNFE/alHXSLP/yVnNAGG4+CRMS\n3fFTCbcWtN+dyUYZOCRzA9kYrmMpoEOf76UG6AfJMn/emUjFWwuQA1JMCuIp\nPjBwmjyanF8tBRgxlLn1e+Dj3hnAdcgVuHYzqtX7+DS1Q7H6WImf5Bzh75+I\nh8H3eYil2UQizM7vKH3ItfF4dMfxseDZsF3ZGILAZg6jCxqxR3/zlFOouf8m\nBdtyeM0wTSBBfIcfyqNR7SQlvU8s3j+vtYTj++rMTbdIv0usitNa0i12IWJJ\nxXpzbmLajwm1KwpbkDcZzY1VPLQpJijQ+4rVWkDkFMTNogy4r6X47oAEPZrR\nHlxL\r\n=91Q0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-5be35b1-1610320504988_1610320557705_0.9353575373913228","host":"s3://npm-registry-packages"}},"1.0.0-canary-d7a94b9-1610320577158":{"name":"@iadvize-oss/store","version":"1.0.0-canary-d7a94b9-1610320577158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-d7a94b9-1610320577158","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d4cc64c48fbbf9ee9310ac1de1b3382fda366613","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-d7a94b9-1610320577158.tgz","fileCount":7,"integrity":"sha512-3TL6aLCAMrmecVV8V0Tdlii3UK1apyzW9NjDBUHyluSJK8DX+aMre1fRlG7idwYHPAm3n6ghev8Fez/Tsdd7cw==","signatures":[{"sig":"MEUCIQCBT8rjImumr4sAWUpNMbWKU8QTbAAeaQlirEs5sJci9QIgcSKj20BITIXscMSiFnAwHixyE0DODIi4yz3VDCSRTsU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+4rxCRA9TVsSAnZWagAAC+QP/Ru6FnO2YdpHrvmgHc/Z\nhPmqJr6+CHuYGcAFibJ5H5LVOvqNQfWaNnZ4inqHwJeDXgou/lnBATP6RqYC\nmdPboC4eFJVzVC6Lf/WDVxlRxPtXULUI8kksLqevjTHpb+IH47jQe5c4XWg7\nBwW+og22M6A/MPtWQ0gvTWKf2clSoS/H4g85q+BlAzJb16m+D8rljNPfisS/\n5LctA4WAiN8iRsB6NxEw5s8wXW0Mz5jBVRmtvVLuiCWovXefvPXy7IpiRH/I\nIo8OaAlQUza/J10Ms8D9dSptAA1rpyFNx/jLgwbHmbw7VK/TlRHYvNFESEgg\nQUmPclZxeT4wDbXQ+lLw0+yj1Wk53SHNo1I/JoC0rNZAlAaJZtbqi9IB1lli\negxF8AuTfEgYhTCNynCqqtCCdOspHhAmwWqYcyBiTelVN2DYrYPx4WakCYBS\nMCjc5ZAemGbUdkh4ZmZ8SqdtiLRL3+QETSkBYzFKf2Dv237leR+CXHKhMzEI\ngeCtdNEgR3IK0RTQ1XSoKZDsoi/x0bhivCsevaJ1EIJOXeoHwoP2o0rav8+T\nUmMsLMV/HWUJy+H6TmyDKXfHozK8hHJaTBMWIuRygzKiXIH07Mt5ga+Ue0wH\nBNuO7dW1/aFu4ciLndRY1izoz9oz8eTCBY4AHsQeN7e0KIJ3UY1MmsDgGWBo\n0DWl\r\n=XkIx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-d7a94b9-1610320577158_1610320625335_0.01768257269450224","host":"s3://npm-registry-packages"}},"1.0.0-canary-1772cb9-1610320581307":{"name":"@iadvize-oss/store","version":"1.0.0-canary-1772cb9-1610320581307","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-1772cb9-1610320581307","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c016225172e19a951bb61510884f036138dd5a0f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-1772cb9-1610320581307.tgz","fileCount":7,"integrity":"sha512-2F3rmk/BO599P3BJgMmwUlG8AUjQD4Wr69gtWsb8us3ZtwY/gV9qae9OV8sA4vdFj65PJmbfget3WzkoZ7XJBw==","signatures":[{"sig":"MEYCIQCOev7EPy7yVUFQnA/hlqthkllKfJaUJDL8ZJtEscKzlQIhAMvLgLcLPEFjHp6F+vRMDAdBprpNYt4VosBSxBGmiyp8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+4r2CRA9TVsSAnZWagAAmOQP/01SX0moaY8gwd8aaSZc\naM380fCEgLeNUek4kZZbpEHmAK6DT8QCnXi53qi46WKpt6JCqgeZInQY7/Rv\nmZrh3qo1BFg0hUMNzMdiFchYM7D3bkvcSNO38g+ysHNaGcfycsGKtI6X005z\nQNqMF/PZ83WMqZXuXO4iOnqEBpRelTYnY0NT6rKI7Bmc5t6hzwL6UZGPf2rU\nrGnPEyDt8U3ZjRvP1yMDpnkvfZvVM/+y5QYF5wianohX40ktWUDim7j7xYBS\nCG79myVTbl6392KVlohyV0yThTZyAHFl6XV2Zy3cpnxQ4UAXYwC6oX5fI4Ee\nqqNbJ2UTPsdexnq6vXb/WHwsbm4auph1CbSMk/AgZ/jzrHMHFugDFnGkHVl2\nB6Hk/PUd8Viam+CJm5mYvuithqV6B0khifVyHumJqNcco0xoXDTC8jxotiaM\nQS2Dr1xFFMzS9jfdK5GIltfmVQs6H793V+nXdAsfoGKN9/7b8GmqPktu0f+I\nLadqjK7Sjx6lqPM/HpMfalMNOgu4jm09GfYUqXIqUhj63TJ6TEzmPEb7peBR\nxQ4NHXo2yXQ8ZP+rHsw33hOvAW851xLA19V3KoNvxBxA+LHZIo1UCm2DJpk1\nubd6F2D+Qmsi/M6vF5XgZ/uGtVqagvZGd0HEDapp+rKxzZAlrf34YVFoL/m+\nMPtU\r\n=9QtY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-1772cb9-1610320581307_1610320630279_0.6290481851653225","host":"s3://npm-registry-packages"}},"1.0.0-canary-4ce702b-1610406977151":{"name":"@iadvize-oss/store","version":"1.0.0-canary-4ce702b-1610406977151","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-4ce702b-1610406977151","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d852ec54504d97b8baacf8e244db0cdb16b974ad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-4ce702b-1610406977151.tgz","fileCount":7,"integrity":"sha512-N3WQlOHH/FWdElrQTavKxSaM9GrD3NKWG96XJ/kQduPp2jtRUkayPuBHyBEegMapgvU6nIIzU0Z75IxoMG2Jkg==","signatures":[{"sig":"MEUCICFH5TEm2+7Kx0qY+DFtgxe6mrySKvZDun+cRHsWPjyMAiEApIyr8N2HXyUTfyCU2mS8iM2ENMbQAXa1kEWs2klHKmE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/Nx1CRA9TVsSAnZWagAAGZUP/RDhKnXW0NLqvi2iIt3o\n03a50aF+l5ZqnrT9TREe6s8CqTi67vGzIIz83CqiBsgJjn51hQqDpxF2O1ul\nLMSEVab8cEI4rK0uBvxQJD6ZO7DxNVqn3r2KAWUOu2WAiuwh+gdGeIRtUfgg\nbD8w56ejlVk64XqxBQS+93yVxYCkAcCS+m67xZ6rbELxjKobwe5aRmvW4Qxt\np6Ta0y18ZWS9zYlurvM+QpvEVDLUYzehJEFso2tjkkF8S6ZSnsLh4o7H2dwM\nmkJARmTTpHnz7hJDXappbr/CPv9ZlqeUsIT1wDT67SkMwgQcXCM9vGzCVQXx\nGBGR6SIDkOM7e00xi1gwWoj0/VktAsZzwBRa/0541z2E09pD6yy824Y05PF6\n66K9LMMu/Gao2Jg8iVpJmiwBMviTk1ypI7y1cTL0Mr3v/+/+6QYvDitRotnl\nCHmi9WG4kBoQPxrLyl30ajJOdWort/XbD4Pk9I6tFqC8XNkYYVZ/opFJx08F\ndSuory5mr4VrN6z7wHGGO5TH6Mxu74BoHyx+CR72DN2hSeFAe3+38OfuvfwU\nWyhIOdH6mxJkvRUHYUplCUelcxNau1IrDOhJU0RTm5z1iyNC6sBLuoi8SM0G\ndwQKnrkte3e55RYS9CAErWpXH8fXMLPJOLOMY+tPPY/0jA+LHdFzgZIjRKi9\nmyBz\r\n=gkF8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-4ce702b-1610406977151_1610407028952_0.824382924859373","host":"s3://npm-registry-packages"}},"1.0.0-canary-756f319-1610406991200":{"name":"@iadvize-oss/store","version":"1.0.0-canary-756f319-1610406991200","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-756f319-1610406991200","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b68ed70a9e652c9a0b3707e1b3ccded5afa1d8d2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-756f319-1610406991200.tgz","fileCount":7,"integrity":"sha512-azz3bWSQbnkbQBaR7ARblP0WYbeV6b/kW8Xyrm8CcpBQNXAEurENQKxdMyq7yD/xHQh2sDHTuO2RWLaLdI81uw==","signatures":[{"sig":"MEYCIQDo4XHAuy/lSLn7Pa64OYQvDultgRE0cXuUlpht0MdnyAIhANAd7Nf4tqhnfuuBVVumlWWBOXzfXH1f9ywsgf0/pxTb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/Nx8CRA9TVsSAnZWagAAKdIP/imrTmf1LQqvArjSfH9l\n6qPRDMoXGaK+MrDvp+6ArypNg9DOnlarnlMCnb+TOx4Vqqp7jAusgcvXJWBH\ni/mY3eCSLTNJFixXe0rTfsB9tV9cqUHg+FRPqU/Hfdc6ShkntHPTiDx2o8ZX\nM4N+vy5n4Fog/GSGfu3H78dpz6NxV/o+LHHVOlZksnb9sGmPNV/nTLEcVFv5\npHZuXwK7hGZMUKUFnyyVwSGIsJg9jCRneJz82l4k+P8tw0EmnQ4iy5P6aoKz\nrfO5BBsBGleeUl9pPj0L3MpZAy+wgdGSaNyYdNhHq88AWRW3SeOfB8FcZVWt\nYu9VhdAH8LuWRBfo/B3ozvHe7h7fbZQTIbLjJa6USMnmB3kRbDjHy4/3ULq6\nDdvKz91g7mhPOGktdPmKxKGA5ObgLwDhpFTmr2IlQAWDmjxm4DMSdod85HIj\ncfyETjR1jwZnB/AOCqPpnBD8MaHc3+hnISZEkH9SpVQ4sFmHZ9uJ0G2CjRGZ\nagwMIYqubj1jIJPO3LeKmDqyyerDzKbhQwSTDgIK8TwzEn0Xx1s7Qx+2oegr\nciCyTvUHimXKjH7MvFzPFh43jzuuWNtctZ4GLctoc5VIog41L9w2jWvnfsoe\n3tD3urRlnpGP2UWSrqhg+HgrJp/2Y10bkY8TbIizs1CKw8OqbtxcRzIxfrcC\nsWnh\r\n=aLt0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-756f319-1610406991200_1610407036515_0.210045641073634","host":"s3://npm-registry-packages"}},"1.0.0-canary-e26010b-1610407115198":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e26010b-1610407115198","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e26010b-1610407115198","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a2d71d91dbe38d74cae8c70674624dd1af3268d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e26010b-1610407115198.tgz","fileCount":7,"integrity":"sha512-9okEArun2SgNoRHd8J8hSzRW2VgrwOqpfZVxbHra14iG7X56tgtpmwnc6SPYj6h+TkxGDi599Atz6+i9C00gNw==","signatures":[{"sig":"MEQCIAWCs5lfE5zCVGkKTddlOWR7P4el2sLAU+aMNDs9BDYRAiAFxvdVHOh3D0idZ+viihlcp/ip8uhL3wp+GOAPsAgueQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/Nz5CRA9TVsSAnZWagAAILQP/14x91kB7rwW/A5eWmUh\nacsEEJyM/bdlg2zyB/zlW8d/nuZBC63Upamrm1LPOeot1Zk5dL/nVJE1lcAY\nmMlC+WAvO6V6u2q3k5v5qy3Z8UV58wH0ypcyJ7rsKPH75Ik7zg9IAs+yQ6io\nOHmsMzgNkuGfihbdAaPHyi/iKx+zgtE6d/Q3PUz5f9Osio7zvI8k3PlUwDLi\nWwFoBJWUo7KtSbiAY0LPQ+C7AuGy9SKmY8tc094+B4GKU9SnbSgFZKmsmjJI\nqBP40mQ+4N8HcTslkkC1UwKOGFf86EU//oevtC6yb4Ql7jCPIpTfyOS/kmT+\nJKdTQZQm7mIl1MjE5exHrB+Mk6JYBsX0+vcDH2t9lbBfI+GsfgNyDW81qFOy\nMfYNmUt3MitcmW16G8KWVDlZOKb01XupJjl9OUM22Neqdbi46+TDhuaqAJnp\nwzDQI09eMxR5klHopRxz7JKADofEhiqL6NPaOPOdcNjCyY/Awi2tJz/g/s/4\nuHFlgGBo6nXXSpi4/a7K6RycwlAkHMBvgOvYp+3PJPsERATTGu++JFMIFESM\nQ0bQeFwz3qSvkr+3JZ1RslonHCtLeOXU6OBNGR0b7EumPtQmRURKNh7+7RWl\n+3ErOMV7pvNnufR20A+ECSsjS97g6KSrQ3i76HlZWul19g1dKSVZR1rGwlH9\nwxC0\r\n=VC0l\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e26010b-1610407115198_1610407161180_0.00869071234692953","host":"s3://npm-registry-packages"}},"1.0.0-canary-0578e60-1610445790482":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0578e60-1610445790482","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0578e60-1610445790482","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"721904263f506c1845077930d88f9a5bdb3263df","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0578e60-1610445790482.tgz","fileCount":7,"integrity":"sha512-xvXpUC4DSP5c94lObbxp9p+cwNpMloLFZM5mtSr2HBkJei5LSI/5PZfypNyUX6C8/GUD18R2WS3LgKlSXiNX4g==","signatures":[{"sig":"MEUCIQCksHZaydBixr+i8eu4f7uQUxMpgyBqOn3b9rd9cWbhzgIgDLbTUGcYNvSNK1vs65ikmVmxcn74w4p0zKK3R3ZW8fU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XQMCRA9TVsSAnZWagAADu0QAJx3iLzSxAvXXVFz5sk9\nMZhCX5PjNQKz+X/6pWOxVN1kDtiHWyX6kUmxMvRr4Tag2SqXjxz4VhhtybQT\nhet2bAJYFroqZetELnFquXVPTc8IO/HACh75WHfHxOREG7EPMmU5ujzSZmx/\nCZNFYCAuoCRrJ5u3MlfxCo46iS4Y+IcONjEma2Kh9gQ7L5PDOvjwIBm4eIRu\nKJA1hrNKeViwq1YTNLOMJOEdb33mpvfWGQDMVKt/jrnpGJSUhbMF50Q5efKY\nfm2Sx4CH9H8iT9sReIVb2vXUedl0Oi1xkSf8a8xhYsVinuGjqAA9JW6zvf/x\nUD2OP4RcfaSyT+fOWzfxr6E049P+d0NlGf0J0Nz9f+7pcoN/Fv7KB3MoxRdn\nMIqVoWctafHUrCemZ8WBZ3eNLdDQGTXdn9253lXD4fBdW5vR21NWfuGbTvBi\n6plTXrfaUChccXexRCFveypqlv6EV+/+QNPViga9CpkMNmMjWbcaBlb1cWFq\nIVcjYfSoEfWd/uIWDW9qDxfM4A8jWjigIxrqocMCGzm5EQSh7BXKQhMXnzlP\nNdTSFnHZ4UqJyYTt0J5e1kkA9KCwiIjQeTKO0zezotQZhIQTbs+5uI3JtSyJ\nhkigaxoVY6waaSmuGevdEDhU4H/5i1o7w8IDRMxmSsh7jJn+FPYoIxqi8247\nNPAr\r\n=uLbP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0578e60-1610445790482_1610445836459_0.4775565215220634","host":"s3://npm-registry-packages"}},"1.0.0-canary-7ffa224-1610446103166":{"name":"@iadvize-oss/store","version":"1.0.0-canary-7ffa224-1610446103166","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-7ffa224-1610446103166","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3fe7bfe98e1b62cb076e98bb89ac3d4c34938519","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-7ffa224-1610446103166.tgz","fileCount":7,"integrity":"sha512-XmigZKB9S2isvwCscpK+mhqOukqjJxSXjurkv5tAEv71hwi6hHHIAYQTXBDdEMeeKvkf8k8v4qIZpTW8lttG9A==","signatures":[{"sig":"MEQCIGTRTq3rk3RsEOOBjvJIsXRYPVSI217VIncL7Syosn31AiArnFnJ/RfwkUWH8oiaSgOhORtLVSrDdEqVZx3tXGs3Hw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XWKCRA9TVsSAnZWagAAZh8P+wZ4OF/SSh0fYtggoAqB\nAHB2N0K+4zcXwiGW6nDqqfS9rw7Y+x8Amcxa1lQ8XqIwMYzVEz5T00/+uInV\nhOTZd5AOuPWh4F1/AalXvFEZGNhlQDKwxcYkXbFKi/Q0GIzUSo44W9sgOXTT\nDf2yQZdEY89SEzwnOI3evtB+vv1XLBtqJkvLrmTV49Qxc50qb3/L/qfkDSl5\n8sPzy7hIke4UEmsnnpuCIGZrn9wQpQRHrVOyuJ3CSZCsPD3AF3WwRWimQujg\nXAv7iwfYOqJbdkvgY5pJhCWTG4rdx2sjhwaHmO1wPW8dd47SUlyI93YmtUH7\nts5MO+0aFei2WqZXyH0i6i9se9YbgBbcwHIYBRI6Gm0WqgjBkN9WZmC0HYXl\nTZIyKWUhn+EjJX8vr2t8V/fJ6MSmMX2vn9EftV/ebN3Ue9uPitDyz6OY1HB+\nBsO5F+Apr1r5aBCxspbZefE6h/SvkojGhoKmWd6pRVQ5Ke/sc2scfVTs0f2n\nUCcIoyy2UGvizjuDzVME+4VGXaPTnxN0wOCxC+PJKYfD7/R9unVSwLoy1pmg\n1E0mpzMib46afHrEXCbs6BJkkwi1iED55AUqYDXT0kX9ZoiBNYMrfxNaSn0C\nXgeepTdIUbEYX3ScDk3LqlgwjAQmSwpTBbeXMzIRGAiMrMG7YFqN1Zubo6K9\nWud0\r\n=VDeH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-7ffa224-1610446103166_1610446217843_0.9199455280162407","host":"s3://npm-registry-packages"}},"1.0.0-canary-b12bc0c-1610446212065":{"name":"@iadvize-oss/store","version":"1.0.0-canary-b12bc0c-1610446212065","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-b12bc0c-1610446212065","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b7be5192f8d21b9a1159c8279cfed3e8f7192dca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-b12bc0c-1610446212065.tgz","fileCount":7,"integrity":"sha512-6gcL1wYKg1WKz+0Gz7Zlz1bA00fCtJ3s0McUl481Zlb9UFs0IqMUzHdtwI8uohwZsuYp5lamKxFDRdtR204EiA==","signatures":[{"sig":"MEUCIQD75Lhn674574esi5uO9Lfp8gpDp92jsXffijdZ7nU7dAIgQdSKO/FYfH3IafPqkWCt6Fauy2DPh8YobU390EMFvQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XWzCRA9TVsSAnZWagAA944P/RbjJNme5bgHrcz7/CQx\nBqXigcc23ztpHCR1IeClVK3Tx6mPN9qDrmbT9yOLxeiWkqlqgYE+tuNnprKt\nirlg2oeumXx6Qom4sl14qY2fCWw527NKoj9PlvBOPeisykAMr/BdnE5ZI3oN\nFNEaWd+kjqyEjwJ3jA7382DciylYGkRAnVsWKC5Z4lM0vYwe3mZoGidACIWm\nnx3ZSIRz1h9G6n9g/UOe5OiAuuIbrQErXd1Luqf6k1McBLwyKF2H5GFKK3Kp\n8qa5n4Pkpgwu5GC6qYy0I8/jzkRRYzmikPG9XPA6X4C1eTrIa5LIg5IT58tb\nHN1UYkbB5JjraxmvHq9Fwd68igHuaIUgDNo0s/3pLsrdRBqPfubxbNG4CFS5\n/tVthbL7Rl2661+4asejnLKPIAXQBOrnzhFlA8KW5b+bV/1tn2JsNMCwMcJw\njcBcGpp9ZX8+Twqizln7kWZ9mJlfQb/OjqhZ5w7tpFsecF1iUCj3QCnXxyhA\n035yevdT/Wxw6aeJkhYhUIRU+i02Sx+Eax/or4HGQVelSJKFq9mtDJqLGm3y\nlEpzprU0qs4TWcoli9SZ2aAk6ks9gNaO5FgUnwW2JsU+U/CB2qdG/Hkgxhfq\ngjZWBvzc3qdw9Rcwb1AkmiE8e24g//v0wC1gM+AGSczYCAlEHTNCB1venYL7\n9Vru\r\n=mHdP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.0.3","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-b12bc0c-1610446212065_1610446259079_0.2278374557550249","host":"s3://npm-registry-packages"}},"1.0.0-canary-3bef17e-1610446611431":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3bef17e-1610446611431","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3bef17e-1610446611431","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"658e131c69be8a4b17425786521791e5f251350b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3bef17e-1610446611431.tgz","fileCount":7,"integrity":"sha512-R7eT+2xza/IdpyNbybYT/BbrohPNPJz8pvc2kUopVOwN4lyyYOL/jOVTWIwcBUJKAi/Xq2821GfXAIr5FYRfgA==","signatures":[{"sig":"MEUCIEqnDRDGi9+WQsB4WQ71lPRHXjCSb2sNK7Eei0hhd0VuAiEAkGBkNCCcPnwPOFo3PCYUKqoAz2GTtS6QIvwuMdwSgMY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XdECRA9TVsSAnZWagAA7zgQAJ5jvXyzJJ3x1GqyzzJ+\n3Mp3iFhx7O54Bf9SgkjNDyT1yNHasZI6nQ0EeVmL3hETquJFrSoJuiPrgH5B\n8BBLPk2L+1CVucrdQhYXdye2Q+EsHpXHwpCHSKEw9XQVqC1IKkZZhvNRIMpU\n1yR5CJ67Kpb4jozzV6yyKX2rY46lRR0clFb9p6ZdNhpskVxELJ4LlGWImVKo\ntyeAZ7Bal9bOTf+nAhlS2sezHAhsw9rkYyAn8BZKC/4nBLcB/CyhUkWmSbWn\nAKXDZI3LKmxkxq8f8XipvZpQMTSfaKL4R6pjWqp0UznLnoQEHPJ8H08l0TU+\nSTYT7YOwpI1ZB3BETEYitGNmmQpsLpdBKRuNLeaNi1l1MDkdUu1qhHjKQtpu\nnJWL8ANLwZG/djdslikh7EjfuqKPKiZocsbwg0PtQ/rzVQHUqorqHkY28CKs\n/st/bTYcQWZQhYnctg6893+HGCv61iR7wNGXM73NdlGXTYUqzqDuvzZks7P2\nSNZa1FWFNzPfbWxwsoPw4j9qyyTHBvp3+dEsMzVD3axMlxD9Oc0iwqZTgr3D\nwamSbeOZZ3DKXtNvZz7KtmJTloLvRW/5d+PbWQXv31NvPq6drznCQZGceTl+\nvWCO4ueBLp17RxumQJ835vAV1xvN3RVWFoGnlsPI+rVjr7cJMYPUkG28UHHR\nJ+zW\r\n=PV2e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3bef17e-1610446611431_1610446659726_0.9638424721133647","host":"s3://npm-registry-packages"}},"1.0.0-canary-e654a07-1610446918787":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e654a07-1610446918787","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e654a07-1610446918787","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"09a144a89c52e9b97857e65cdc07bf3a52f9e080","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e654a07-1610446918787.tgz","fileCount":7,"integrity":"sha512-hfrEFPHKCBOVNuFbR0FSutDiqJYlWwQvRXsntA4/CONkzvWBU92qXbStW45ETJcjVvvaC6qoo1P1Nz1kK/eD+A==","signatures":[{"sig":"MEQCIElNF4zGnXNFP2PWltEQjTmqYphL51hTi9oZUaWYeftaAiBC9pcvrNRzhsm8HbT5iwZAF0rqc8xm553K55Rg/Dyl4Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/Xh4CRA9TVsSAnZWagAAN40P/RLoLaG4fSDsin7FmXPi\n8HCriRCHp22HrPYBcBcNsXD0D3z41W/4Ajt9Dp1TMGma6QPqm7eGtRQII8PP\nGhkTydxiQ3W2gTeufaxsyU6b88c/am2VfFY2ax4lVHAUYfb4ZI4EwN1o2an6\nywMlbxsMziEVJljMx/9Po9YcdbVRSN1NV0QIqWEBIDZ/8q71cKFn7bRp60Pf\nElZG0wB8TpvuZspH09KSCnuiQw8c4NXWICWBX+t5ERy1uqzVYqxkyd/fqGg2\nvvNZCGJb9HP3uuRXMLNw5UIGwzi9cglTA738KJbDo9IxxFP2uVATVtcRUsPq\nrEmUZElMDfEfvnjI0s1ATD1zQGa5tzvzBO83vWv0/x8Am5+nBmg+Gm1j4MPR\nBZ8NZ5T3KhGkMvlhdaj9fdz93u0lVxcIBaveGQbS7FlXGizXHCL6gl1xXAQ7\niic3WeZW3MRlv0or20qe4ZfUOii7A2U/c2ccs364G+s81kA7xGKIgfW6D0W3\n5a+cFHtkeI+0DHx6A7LtmncoBYKhvg0n1rXgL9kVxYHNQSPeOzPXpuj+767n\nkDe2dXBVYek+s5Fori1aKPthsAYYBcSzObMsteqAyxkhtG4F9mGwUGdScRng\nZM0ft8eTcBh88zdL5SdWTBbLvDws2trdhwJX7TkDOBX39XycGq4iIOzJ0wCp\nZdsg\r\n=G1Fj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.0","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e654a07-1610446918787_1610446968255_0.2367693637385948","host":"s3://npm-registry-packages"}},"1.0.0-canary-58daf38-1610447029596":{"name":"@iadvize-oss/store","version":"1.0.0-canary-58daf38-1610447029596","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-58daf38-1610447029596","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f340a1754e84d259ec29e24b80b89505638c41ca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-58daf38-1610447029596.tgz","fileCount":7,"integrity":"sha512-ofWUvrnNbgey+G0rnXSx0UT8WmGjv4cbcrcwJkvqRAdFAMH/tt5Zeoxongq+UuwSGBaAMNCYBRF/kKLYLej5BQ==","signatures":[{"sig":"MEYCIQDRRkPELem77W4FOM50/MgSNT1Bw9uO7Llz6vKZmKYHbQIhAIrOTodS9091TjN9ILWOX6sSwlDNAXp4GSPArKyqhsrk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XjkCRA9TVsSAnZWagAAoF8P/0UDq0X9a+yK5ySKq0pX\nh2p5ECI2htqyv0HSgmOiI4FPpdwAed95cpooSkq/y0ktoXvGPe+sQATircvq\nU3udFbEkrB9J8Qg2jLOBLiM45m5i9vG0dc1SKlzzknj12TfPmWapA31gcp8k\n0+y/YDukAIh8D/5IrJIhP/NqkyP3V1lwHJL0hfCalB0KIgCr1D/7jpSifS5L\nQTE4pyCqrvur/ZGtycKpUgYd0veaxFX8kyhEzf47Tkoz5o185Sftvh5pwc6B\n+MF2PcYOf5fPZWZQnHsqt6mHarAlq2SffC2A0sUQwCxmC0SV8R9it02+05le\nzpT6QFlSOaHblI60X8ppw4DjwWtvk0QmVbDqpinPiRCk2T+vmFvWGd0kXrFl\nK3O3YKsgPUfgRsenm1hk2HUiyxfIAwTB4ZBlgTxttF2ykhyRZMA+VVhQbWTe\nd6bhDh5TcJEGZJVBUbNsbeoW7bva46pPssqeLygUlhx4Zu+bR2TTSgW0iMqv\nFZLUW/Mwg1XzgjsbKw7KrpR0UIdxQGxMqCeqbsRpzQ1zPSsEphRn1EI/u6CX\n/0Z7iKcoOHtDWI6SS3LK8PB+ao6rCHw9hR7yltr3uOfE+MZhN8Amog6kZEia\n/COlBqhY8m7BySkf2IQ5nn1EbovxNi2QsY/SX08Ww+6anc5Vu0iP3iKFZXBM\nrGAW\r\n=ixT5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-58daf38-1610447029596_1610447076007_0.6260661112276098","host":"s3://npm-registry-packages"}},"1.0.0-canary-ad4ad96-1610447299963":{"name":"@iadvize-oss/store","version":"1.0.0-canary-ad4ad96-1610447299963","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-ad4ad96-1610447299963","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6a186c03a0cd56415eaef9a718e42bafb72cf79a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-ad4ad96-1610447299963.tgz","fileCount":7,"integrity":"sha512-CtuLh4iErz2Cbj1yZwUvRLsE4ipGQUGn+wBPJ1VpfiMl93k2bSw0hSy4iYf1eey94vdtIu2NU+YWayRxKNZ/5w==","signatures":[{"sig":"MEQCIATs7aqO77JaZ84Ec/IUHE0kPD75JT7eXKvm/KwOQnKWAiA5zLAMChtGADmGabPjsFQeQX6FrkwINh2RJJNAyzjOlQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/XnvCRA9TVsSAnZWagAAWckP/jRthpkrUbffX3q2u3zK\nF0XnG2v40zuhg1EAfXIN9zxUy+q6z6FFYXzo4pSYiLu5cn95dXF484F0Akkk\na6qPYM8uVouOHcAvoBjXbHEdalpIu2SZJiA6Dba+u8vYhcjdEVBI9uA4fdyA\nbp+RkCVk3LWxKs7+8XnrfQqy1lOvVb7UC8gdeiqzi/HZHMlaH1xsCSX4Px1y\nihwl2e992GA0J58C4i7LSi/zydDAdsgg3mAZ5azbFmGKp25tpXCXc1DZVzP1\nuu7Mi8a6hlvrqx1PY/A+I9una2aV83FSUlzmZM195F0YjfuZFY9otRn87Q7E\nvvFq9fJl0xBq+iagqwmYM9x5Mka7/PDg/VAkvvsqTLDhqJqnxqfGIwFkYdgh\njxsZWNJgNz7VNonpFgh9j0jy0wtgqV1WTMInGliGVqJDfiGUn5ddcw4/e+EW\n3gV3wqNzKATSLh+GFrIWflh78SXwhJkUYdAQ8dGwsWqlp7JP0PEfH53lEmqY\nUq4CAPJCyUksADIHnK997UNrA0GRTp1uZrrjtzocaTbHTHaprLt0wzY/T4dm\nyCGLtY4gnfLPQkHcwgXT4wxU2jx7sc1pkpZha0yuYYDXPAFy6v84xfWSn4Vp\nb4Hw4QA9uBNptO6qLQ/nzJszO0PqQD2XGjAa5hFuJ+7MxMPJIioQ5tQElY9g\n/Q5L\r\n=dT/k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.0.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-ad4ad96-1610447299963_1610447343278_0.6009045451036994","host":"s3://npm-registry-packages"}},"1.0.0-canary-e0b3f53-1610498581480":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e0b3f53-1610498581480","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e0b3f53-1610498581480","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"99648d75a3d030eaec4a65696682b6b0e933b5ed","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e0b3f53-1610498581480.tgz","fileCount":7,"integrity":"sha512-bYrQmGStV4usHkI3bQCi+JKO1ZELhL5fXkZwMjp6wXRLZ/TsUpDq6JBA4o3ONDOvMDvj7IZl3C8QhV4mYPX3mQ==","signatures":[{"sig":"MEUCIA9gfx2YWwfbT+GTyGcE8I0igc1P45cDwOOmBvoccA7mAiEAm41YEHEJ674gWPZihNUP8sUb6kPCFq+brW7Wuijnea4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/kJDCRA9TVsSAnZWagAAqNkP/3l1mOcKPfVgp4sdczbf\n7InQusuBrL+8kPd4SH9qf7t6/abRY2bUgv6zj/Ji3KMy1AacuAJxgM9fuBI9\nZnOAgrHoY2IeL+c7wbEosfS7vyC2cKG1F9qjrAgqu5eqNZtgHt+hSVEFHB+N\nWVxM7YZtATJ+DWHFfosKC12DVKpM4KJPeRrYO1C/1KBg03sDquYaRp1f0kT5\nmSKoni+v0DG1EQrj7exNODiLzXn9Z5RC4wYA6iWtDeadrQ70XrigiAVSCI02\nRqq2nwYFVdw9FR8wayIeejgrmppitXeg9xz6BsKroX0FltHEjcJDb02yMW8i\nUhzd4NjTrADjUpf5cylQoEJTyx7P1ligoPMfm0HUwSj6EBrT+0zpVRBWZFEz\naAitNfnXwjqUt8sVTujvwHItSrsatgxFn2gZ/M6DGUDwIOen8JGb1OcR8xKZ\nv+1xE0gKZ0mfeMe33DtzbPHoyU+qT8Pf/Sk/b63z07G5vYRcuhmWlqUlidCS\nNItVUfUCvN+QgdXgzGRGtgKCBjhnApuIt0QJYMHb/myMfG0PoSWk1W2I3UVH\nVbyNQM3jBO5yM8nwPVhfs9AeuYlBUEqAU9uKwngKBi56YJpbPQ9nORgzPU9c\nRzEUrcqGAXm1VmlddCAnkobDShC/aE9zZxb7Sa3i9bZhS2fdcyiExBKwjFcj\n/Qas\r\n=g3q8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e0b3f53-1610498581480_1610498626918_0.6454693241617597","host":"s3://npm-registry-packages"}},"1.0.0-canary-e0b3f53-1610498582516":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e0b3f53-1610498582516","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e0b3f53-1610498582516","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"41a974371d351ef29addcd01a66e03ff7d3a8e69","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e0b3f53-1610498582516.tgz","fileCount":7,"integrity":"sha512-W9gcdSPeoRBZHf59f8UC3lim3MYbEJ1gV1qc5+1yO2abqoVq9itPIiFxLZgIw9WiqKbhKm6iRH/4NsRqeDM6Zw==","signatures":[{"sig":"MEUCIQDo6mcOOcYC4K3GpojXYw+GDuNHeO4qizERiKvZc6ZyOAIgU4QVmBA/wqojST2HKz4qG8TxX4tBDG22Ahuon2KjMA8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/kJPCRA9TVsSAnZWagAAD7IP/0CN6u3vAJk+RuJM0JHv\nKTTBDNxaF/a7hWUckHfff7KH3hfjT9mnXtEG2I5S1KbktXg5PAvrr2/yWu1x\nzQcAa9NKZWyhEbslvmgZzg2YTWXO2daoTzjE2UK+Jp7A0tCUwfzvNGQlZJxa\n4j95Uu1+73lqYkAUoFt3SFPYrwdRO22MpK2lx2pxAAE6KXOGWwKhQixDD9OT\naQ8hw/GPbAty6ctiOgryHw5x5TfKwsBM3jgWfhwh5hEouYMfVwRnocnyoAbL\n774jx+VTZXWmAuc5PXMqNzLxR3YTOhV0JPtrFNqu2VMDNsiNvRnBRWiBicgk\nANAl95n6870W3rDyGtUYtBRrkfxmU7ctxLthbZFyFCtwrIEFd8xJUg2tAQ5T\nnnQCAmj9pVCm/wafJzlrkakEEWWSWaDUcokw3rYN50McIENfAqHOr3iEAf6Q\nA1Y6U/cWKqSTcFSAnE9Gf3wbr/mdOozLzEwmaGc9y/xWj0dSJBtZSibj5342\n1RGWQXjrrwHVz96/vyCwo9VtWM3cC7ObsqPbYnmHVoJopXm0pafLQN0OA5Hz\nMxvirRpzUoIJuLc4FGAdfvg1PhIF6/zf42kd2E1AsF1etM6FyGKaLEc/pZRN\nPvxvReoGFbzASe+vHh0CaIupkLV5PU7xDzhsB8yinOkU5lEOne0fcSUyW1w9\nZWA7\r\n=+QYR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e0b3f53-1610498582516_1610498638675_0.7239119996179473","host":"s3://npm-registry-packages"}},"1.0.0-canary-2a72046-1610752203602":{"name":"@iadvize-oss/store","version":"1.0.0-canary-2a72046-1610752203602","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-2a72046-1610752203602","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f325cf68213d380eaef04f99e36dc1874b64be19","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-2a72046-1610752203602.tgz","fileCount":7,"integrity":"sha512-Der4ocR9i1661IBtj4LSq1+JrPpY7DXh6vK4NqAaz7ZHCaTg6+QVl9ob1R6BnyxeVre+da02+Z2IbuxmDBIbrg==","signatures":[{"sig":"MEUCIQD1UXAa9EkC8OYmWdMLYK29gX1XGeovALNuFdaUSHnftwIgaOrY3vVBueNF4PvcsNUQYJb9CyBqFemOYBaMTTIDVSM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAiD3CRA9TVsSAnZWagAA6xwQAJuqmvYrmginIEZOUxTm\n2TRVBRO40XsdEZXliS318v/HWYFBnF95ofn0Fdqta/DRQcLQVANIfjOfgdjq\nPZ6m8UcaOPFbDDx1/ni9nB4wq9IxS/9kXd84277rw3YgZxnUXZz3ng2ZdYTu\ngO1anxRJA1BrFI/gO5CkxetTUW/aM/Udcn10M9xUaV2vh/oYeQQoqgfHGKG+\nqMjoLIvIRyWBQwl7hnPyVK5U85MqWpIhL3FxMKloaq0jlRsLsxr0K/yZx7Yv\npVF4tY3PXpH7EIz2grXkJnsf2WpsUUtJQI3FbyUQ+REkNXRrqSLmm3DLKxPy\nySib3DUg7BQFt3VVXQvt4hftTgW6fP7rKsJ3gPh00o9pGiEf1IyFoNZSxpb/\nM0WRagmlYi1OiXNBtgrWFO8Ym5iv+YlcyPGHCIUE3mRbyC20iXkurwRrKwWJ\n+cv9b41crbICsyHuQmYJOBr10jGdtuMwD8aBqcG9TrOTrTY3s2XdpyUUPht0\nCzLnBFlDEQz75ue1LBgvV6hmDRZWTGz6o/62iplEE4Vst9HWhbUgkPexLob8\nBf1j1OFVnHR/RJfLzO0a9t+aKBNwaRdurQ02OBJlUJVYy7Cm06t3lPGc+JgF\nmZTp+XdEF/0Z6IKk2jyQDDFLx5LTL5ZcOGvk1bRI6JmFChYIS2/laYH+0Zq8\nO4im\r\n=WRUV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-2a72046-1610752203602_1610752247436_0.756579596942405","host":"s3://npm-registry-packages"}},"1.0.0-canary-2a72046-1610752204951":{"name":"@iadvize-oss/store","version":"1.0.0-canary-2a72046-1610752204951","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-2a72046-1610752204951","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"764fba88a1f0b54b70b007bee3632c3131c1776a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-2a72046-1610752204951.tgz","fileCount":7,"integrity":"sha512-38oi+Zkxc7PzaWymYBLPtF1byKva88WjnsYGK2EiwlAsu8sy5TpZBj9QV8nsNGDpepf5n9MPhrvlprYOJ+dSfg==","signatures":[{"sig":"MEQCIFn97HGA4xnHZ74vM/+OjxoUbgDN8sx39kQxCoaiu8BSAiBxtlP9Iheoh1M/P/QesEjk5XuUgLw8Xa1F7Ffa1RsITQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAiEACRA9TVsSAnZWagAAZsoP/1z0pPnLO1wFR2rMfvUF\nYrZu2VDbPux1e9QuLXTjy//2bVeia3EBBKjxjWvkCwlS6xB8FQuvaeXZDM11\nw/3iheoFwMRJY1dRnK8egab1q5jt8ou1OrOZ1up8JPzLlnRmTiTz5A7kOiob\n1y8G96MI+zVPkNgdh+0mamARGfUyu4JK0Oq4ZveO1cFwFg6LhPC3fRJxkKV0\nYiO4X0rj08TZN/6GcSX/JSORFiiud5Si+Vvq82Yw6wN/MJtSmLdzaxhasUHO\nzJT4LKig+zUmp2SG9PBvFFCL5m8IR/OAUqAfkIhhJFDxRPdniMXidMEtbjzp\nDQoZbBQQSTQraBN3ZYtDPmwx7sEiLwyfvcAf4f+kt270Bqo+DisQW0TlfOID\nWGFgUvzzHNDlshXSSs0cus83EqlskQpyjQQPF5Stkg5VhDyvx/dm+jSKo9Mb\nKj+rGCL6x8kymq1LpvUButC5S6KgXiN4T49hDDwxhoCb1KxvTTDEk9uywULt\nk9CL4yo/PEdfMQbCk9IKd1KsVX8ii2nnGABIanJtUm9G3ISm8o1w1M3xJNru\nYDSxdOJpNMIjZrrnzRjq4784raJ7exFxZukHqz7mHSMX9xiizhIVxqXx9vXi\npgF3B/2SCnObGoZ1x6o1gyb2jej8pRG2MW4MxXGdmwdAlh1fyaxb5m97qEIg\nIatL\r\n=olNB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-2a72046-1610752204951_1610752255756_0.35034986484988995","host":"s3://npm-registry-packages"}},"1.0.0-canary-3067210-1610778666890":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3067210-1610778666890","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3067210-1610778666890","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bb6437c4275763479407a431dc4417f58c5a50e7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3067210-1610778666890.tgz","fileCount":7,"integrity":"sha512-czR2QhzuWT/zKNcIVhcBY65FLj4TfLmrSZJKXbCPUwznMRQbyVaxU/C+F9SI5bV7XZoYbMw8taFFpFl8ZtYV4A==","signatures":[{"sig":"MEUCIQDazf5w5mLQU6rGwEruZ/d2IjWUwUy+CjYmS8iBiINBUAIgUFURs+ohsSjWRy8GXZktM1iZhFHDVfXwxFDRrGDoPws=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAohdCRA9TVsSAnZWagAA2dMQAJQ/pDGEPxRsBHGr02OP\n4Eynli89dkul2DCjWbsQBvcNBfbASGzrYgajU2bjW16AYn907RrRuJFjvwOT\nTPPJCSe9vl9zSFP6SSvc+pFJeuqHfeQUpW9MQ4Ehg9s7kN/VtJKnXZtMpw8q\nhifUrwYHNHa/B1dFaCpa7IR29U4UYQ018JjlT3eUwqpoWDNkPkYXHY/JtgTF\njdk7zoTNkEIudZ3I4iksNaRk45/5P0MyzlcIEWB3HUqpY8anJDsUfHhljO7s\nWx5Eu2HlLN7Gnl+8xjReEjKQqcITFGyoIh0Kh1cyVgq8+2pddmy6ktSew6cV\nB7UAo4F6cxLvY0TDfSjR3MHBIwOZcLS7beSXTNjSZ1zdNsUe8ZUM2sHJXHMd\nJ8jcSluv17lM8bRqzctj2BPAO13kVKDdlEKGaG6XUWKuYTKpne+sXpm/iM2f\n85L665AM+5RGOcUn4AmSmEOKgNmTb+soygedDjQAZXE9sT1OIVcqqjWQPnUV\nftsNEn6mkW9ujiXwj2RBtcDMa4qdSRuZ64Cp/WMU6XncT9kDPJNRg3GRAwuu\niV2Q/dgdDiWfX7OtNycUMVEcnuQDjC7WMK1ESnQ7+vj9YP56wZb81j14wLgg\nv5ur9iDdZaOP1hJLYcWrecNfi4PjN6tsVzOBwYCYybhlIigzYgENcqdv//KH\nD7xN\r\n=/taP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.20.14","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3067210-1610778666890_1610778716650_0.20567854428242427","host":"s3://npm-registry-packages"}},"1.0.0-canary-f92e403-1610820648008":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f92e403-1610820648008","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f92e403-1610820648008","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"77220118fdb4ac1161ea10464667364b6744074a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f92e403-1610820648008.tgz","fileCount":7,"integrity":"sha512-B8KxPeob2RFXn01y6sOBRYyIUDE6d7wyni2lm3jZWlBiQzpsl7szkNqhtsj9TGEoM/Wrs4qmemqJKuETOMUHWw==","signatures":[{"sig":"MEUCIH7oYN4NwkT63u3C3LtHIkO9SIvIQl5egVL37ogciDXAAiEAgMzVmFf98WI+skPmM/Qj9hgXkIS4NJADxkYXYGYukOA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAyxXCRA9TVsSAnZWagAAGoIP/iSO/7MYANrGk1lGAqSQ\ney/j8Oc/Tdrmnl+UzSr7okrZTKwdfeFBi0Mt9fA9/wwJ25owrtCqXMtYn/Xh\nGFQJcSQUhlmppry+6eXbpJmgPFJyGXe9h8nAHDGCcY5kOJRzXW+2IJS74ga5\n3fOIq7+ZQ5ztWOUc46OdHZX0P+PCPcZCiBHsb2n24zMQzW18XEjwJ4erMNh6\nXmQ6oL2bDuprKGqpGhfwUIbOhkcuY+IOHVvtfCew/p7A7biRmHfvy+ipCM78\nra5VrCyiunffSp4ndtXRZOTUEAvFJP2BSDbTLXAkHBnUI3OQmSHIXRiB3ppg\nt0hzkdUfHu8Zpyvt+ZuRp58EiaisO5dFz8AKFNW4gOuCJXcM1HDodV8r+m3L\nmADzA7nG+VMBBzVpXq85p8vaKDwj7Dc5pVf95WJDhI06jlAc0iZQrX9IMkCC\nQ2uLGru10oRa3B5zN14KSKeYTNSsE0upKeG97TKaf0ALUWKmaKThCf4uwkBQ\nw2bxKDSR6YHjpOCitWX/b7+0uA5CgrNPQGXMTC28uDdwGDJ0YNr5W1/LLy5M\nOdfK7e0+wkTLR7smMGzVGe6y3ljMf6dsjIPJ6V+oEIfN5y4///aYhG7lgjaV\nezyTnGz3zKWrojl2jK7IKU7MUC2CvBQPR1h0dyGR55KyNTQLoBE8LJku6Qn/\ngrvG\r\n=lauq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.15","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f92e403-1610820648008_1610820694863_0.5730267004190985","host":"s3://npm-registry-packages"}},"1.0.0-canary-f92e403-1610820648277":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f92e403-1610820648277","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f92e403-1610820648277","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0cac217605f02bf8288f38331fa3b0922732fd63","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f92e403-1610820648277.tgz","fileCount":7,"integrity":"sha512-Wh+d2QD5RsDSDeNE+Cs4jtLgkHwzEsoDij8hXN5ma24itRZbJnXVItkNyyPqRgchKsql+8NajKVZIfDRI6EcfA==","signatures":[{"sig":"MEUCIAxre51c7YzX5/FUd0N4FDnpUyncOBivYuGf2Lp/tIgfAiEAjxamdfkQY22dBPdc/fHmhhSHor0x0NgrY0MDyYUWiww=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAyyDCRA9TVsSAnZWagAASvAP/ifH3p+xb6OMm7/X5xKH\netkhms3X7DagCbbEqhhwJA57X4NKfl9KDb0RcEJ6pyXVqorbszbYJtZiVyP1\n8B4/VuKS28aHWh3M0IMmKH8HnerWvZ65VVr5X4n2jkaL1Q4BfwswB+F6C9Eu\nyzlxtfbv9Sxd9nApwk2mSVHsZXZpVgp6ngJ8v4erG9NmHdSzndLmM6cLQrSh\nzyjEqVYqkClW2hh3nlyO++ZBoVYrAaOBpoC/jeDAd81mQv+fK1SDgIbW7dfF\nWT1HnzvuttxlYCJNrEIu14Ay/NQXJgV8gLFZsoV30Hlpw/0RWOwY+3WX4UPD\nNNsASth7OgSws7ru1EfNIx9NOj7kYqFRHIIgCr++OsgGRi67YvgFyIFpq+Bx\n3unzEtkiTFB+D90klYccYrMApiHcB3VdJ4XsDDat2jegtLPmHUHqpFk8xQhw\noJHVy+aCrnT/+HX1VJ6H76qFaS6XGKeAD7b9P97sf9Yr0X4l0teCRjAc/AKk\nLSF1W6/s4H6iyBA6WlU7B6HHyjZGNv/I9mUaim3AclK9T1y+ADYAPgyhHNZA\n3A80hYKwn8st8+NUey3k1NUDEMEqiHMCCXkUhh7+MmTgIbaTP9y80aroj67/\nlgQ8WWksoCNT2c6MewF1zOSNnu9MknAQZJk5hMVqguT4wH5Tq24GwAbe7hiH\nWXXN\r\n=K3Op\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.15","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f92e403-1610820648277_1610820738877_0.01694377737501318","host":"s3://npm-registry-packages"}},"1.0.0-canary-abc16c0-1610850970812":{"name":"@iadvize-oss/store","version":"1.0.0-canary-abc16c0-1610850970812","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-abc16c0-1610850970812","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ff1486dc6acd8ff739defd68be89f08b42c6ab8a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-abc16c0-1610850970812.tgz","fileCount":7,"integrity":"sha512-aDcre0GQ+OgvnvRh8lgUoQFTMQNxefScuuzS4u4t/RS5d64e0jLCLYDHd6sMR1e7xsiqV99AcE229d4k/rcQAw==","signatures":[{"sig":"MEYCIQCLPPefn+Q3y+MxOhghdA5wqAGsooXUcPZk+OKr/taMtAIhALmnWXQJsAWosZzlBjqKtjFW58nLD0XtBpFqMRcclBTP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgA6LKCRA9TVsSAnZWagAAodAQAKRJvgSjnB3PH8T2hG7t\nv2qG0Ff0zqlU+rEHOv9GvV/9W2U9aqbY/Gmmirv9F14tf4WYgalPH6E8mABz\npZcllrGgqhybN4K4UrS8BXNQDUzeXTzGYRVHWqgbYXKm7dlYXbUpnw0WD5TY\nR9YMd1FOYFZYLQqIH70Mw7n9AgKkAZuHcGNIRsI/R4sG9r5PQ4LH9TPu6Pj8\nWCRCFB4/SGyMP90gETRqNvKxEATnsEWdCPVRUooqVFaxKLvN9UekBjQs2syK\nRh2fDXET09CIS5UczI0j9QdE+YQWgKpwuAu48xB0qT95D7yYkAyoa3ieiTvI\nd6og3QHC9NNfwbx/ru8LvfJ6nSk/nuk+tLye1yQOIz3gsPMSmoSJwaNb0HTE\nsvEeYil550wOC6X8LGq0ZwsL3n9qEvoCaP57K9Gd5G/5xkA8pRgN2Fmvm+BM\nOyBhY/REPAxAKqo3a4UoISt5Op5lhzT3rp74kTJWNMCIUNM7Ru8qMleKVaAT\nbaQ/PkI8Ulskv2PB24BeaiAUfmAflwl8FqNoN60qpKifL8z35+mIyZNOe0FX\nBsYAgDWSYkfBpIMX1WvjlXffjGfWVMSRQ4RW7cAqHU30Hn7JBjy/HkncL9Pb\njcmDwx2N5oMM/Yp1kSrD2Ls1dqCqrciB4+oieUqRupBDD32czyCnUkSQoGZz\nU8c0\r\n=xk9M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-abc16c0-1610850970812_1610851017487_0.1366723238141847","host":"s3://npm-registry-packages"}},"1.0.0-canary-abc16c0-1610850978293":{"name":"@iadvize-oss/store","version":"1.0.0-canary-abc16c0-1610850978293","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-abc16c0-1610850978293","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e253f814484f8c4f4f93a4a45fe62a0a92833457","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-abc16c0-1610850978293.tgz","fileCount":7,"integrity":"sha512-S6EWL83br+Xq9osw6jaZIz+AIGv6FZqwylDq3+FcPrLdjS1aCAaQoGrx9QHOvQ3dVmqEtSdqhp5BsENmrtzz0g==","signatures":[{"sig":"MEYCIQCIdz/QhEp0JBCKOI+9U80D/yd/Ewkrfn/Kb6cV013KtwIhAN+IYVcdY3HOCtsQFthtMcu5VVu632IZ9YFmeaahYTqB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgA6LUCRA9TVsSAnZWagAAjsoP/R/vLgFOq35CWukLbTDI\ndrJPiYbdsPdqBPgT8oZx60vZYNN08di2WxJ7uhkKOa5IJScBOWrExgS0ud8T\nNzKm+WMTlVlVCw0ZrsZvjergLg7ks0UEeVGWnvCowo5vUsHYwWRoJ4R86ep+\nAgOI4UJBj31OYEIQBaun+A/pE+itqE2A9FmX6qVsLJKXkIaK390At7CTLqCI\n+xuwwWlE84vuKtH8/5HTVmta4/A/2+ig5rHWl+gBaybZxh4yMSfkAPcleXtg\n492zd8QdJcU0VFwG2+POAtCgAEYLTvWZuLH/U07A4ZLJvbs1vMNvjNy5Sj3o\n0thgFA/RmkxnLy2CyiheRGdPzBBktoKhkyXF6Dq11Cr5RFQIj9egcdytiVYy\nyzeX61e0c5cTVllqElKKSV5uhxRAyKfxknEzkrKr0kv3xPbsdPtiyJ2TBRuj\nihwW4pLLLnISQa+B4Ax7G6u+UIYMjnqoRYQNKyx46hBnLx02g89HlsEd68w9\ngOow2wMpr+Eo+8Rs7MbitTYiZeoN5a7dhtGcVu1Nuyt7gut09tIAI0G2+X1K\n+MuZxhEPBcZOIBwYo4UU1lRdtpuTNysVE3XxePduG27CokhOVb9znzTci7xs\nUkL82vxjszwSL13nJEAmw40WWq8jES805WtPR8AvpD2yk+5RTNApF+FxYJvc\nTHEE\r\n=yqzR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-abc16c0-1610850978293_1610851028205_0.5376976536620051","host":"s3://npm-registry-packages"}},"1.0.0-canary-b5aeaee-1610925992471":{"name":"@iadvize-oss/store","version":"1.0.0-canary-b5aeaee-1610925992471","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-b5aeaee-1610925992471","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4197d35a9493c91b32992726d7d3b0b5419495ce","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-b5aeaee-1610925992471.tgz","fileCount":7,"integrity":"sha512-1HFs4tCnsw2VZa3M0vRVMO1zwvIrMr1zR6//SCxON5xDBN2WL6D1iM9KZ5r0B+i3TRvrHa5uJjQm1tWVudMpbg==","signatures":[{"sig":"MEUCIQDSkjEetBGkJCUmrKfdTHl81GcQwQzVl36U1DPB5IK3dwIgFVofVHSYPcEtF+NOTlLaflnyuYGfyHB/LCOMx6kCWWQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBMfbCRA9TVsSAnZWagAAYKUP/27PtuhrjjeoCbHJywC4\n1iceocA6dzqyNeiL16+Fm3jko/E6c0BKplmea6ZP+PrG71ASa/fEYQmtRbUi\n4O4BKNaEQbt0NOmj/yY5CmNDMLWjMpb0fsldixwXjSj+6Onp6+yVVy4j7gAY\nMvnh6KKmpEn5WTRIcscN3J4dJpZEWEQTYel3kn173SCYD5v6/SaN7kEl66Tp\nCu40VEAls+2gM/ctYXGoLGQi18S/pRyB3uQMKTY9CvzQejJ7BPPHch3+d5IM\nf4FTjXiZJ3yqXawzC/QyDPkixIAo3DoLbOrVinN3dQnFt02oSWdSbbTOr9pe\nrTC0Slso3YrlbHW1xjQGjCpdVrjfr/ImaCp5C67JdSX+eiAXxOmGG4MgfCD7\nrslV3biGciey50pXzi+cNHKTxVPWx+jnl/TvaANrFXwQ7Z67kfY5Z7ToKC+J\n16n9NscJaSrTfAKSKXFfRdrWt0IEOBxQz72NVnXW1Vpi/qxzubh091O4Lddq\nJUvhriC++HCw9LAF4JA38XauNzY26wHgdz7xe3hHIrfSbeOABl2NncARkt3D\nIdDmqckYS0v/5+7pMfHA71ArPFIKc6qIZzDHEJvsLgaNNSRNF2UEcjzAbBGP\nh+gJpSTC4Q1/J/RN4bY+IDOpCkPchmvjVbx5QQP7WvtoNk8uScivxjI/iErr\nZFAP\r\n=8Bnb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.20.15","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-b5aeaee-1610925992471_1610926043299_0.9071656630634526","host":"s3://npm-registry-packages"}},"1.0.0-canary-007c5ca-1610926003333":{"name":"@iadvize-oss/store","version":"1.0.0-canary-007c5ca-1610926003333","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-007c5ca-1610926003333","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39db42205ddbe1fdc90b4aa91ea525c36b048ae2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-007c5ca-1610926003333.tgz","fileCount":7,"integrity":"sha512-YPwA3MwpO93LrfzgJrQ6QJuOHrWsTFrXZ7F5EVrooXe0ns/OpCYc9PaAiwQTQnJxJaJuw+tppzzDAdmWclvEWA==","signatures":[{"sig":"MEQCIBCB2t5yoFvw357BdbZ3YA3AJUbQzDyoK+lpYAeoLvR4AiA6QEoKXiUEZ3VY5BUvXzgBgJmbJjBWbRGKOn5J5KvN3g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBMflCRA9TVsSAnZWagAAjOMP/iNyC3L5Vmnst7Fm9xF6\nnPfJqQYLC5zi/B4vmfcis9/DL4qp7daddSgzMrjKCm9HCm8p9KXqH2kVpH1c\nSDAo8T7SA3/iDp3GSRqvWI8s0ZJS3H7cMvs6Eek5nmHAsqoaimfcOkQNsqdp\nNLewJGFwvBIgzO3HIFHENYLusr21mn245g3zJHjvN8+BEwDhW0qQ/ErK+phN\nRY1jtHcNd9XzAPGLW1WYqc995GDyq0iyH/ofPOF3OsPSl+J8kFivh/jZxuft\nVJDQ97SKrBkFgLfh7TYjnEViXFhQHzQ45w++0ZOaedjRZ0Qd+SP+GqykSdz8\nbuJbAS9zQ3nqCi1LesyJRNz8w8Ae32pkzo3VF7ld/aUo8GW4rVUHTsll3JKG\n/0S6N3MyfRfM3+4/jnl+PBptrWuKxa7r4Izp/qI6Xhi/nD33KKdr18ca4JTE\nd0maj80uDlRWWWLXAfg2HZ6HiQzRTTQse76BVYJABAVR2BQLDLm8iPrhLUKJ\nnlL/P1zzQX+MPtue7eSLoQkFaMojIXuedESYCs4oupvM2ZL6IZ8O4tIVZlbg\nNqnLdyrIc1cX0vZp9UZaNXwZmUS6+g677wafyvJ4LJFBP9LHcgyx5nj3GaMJ\nmmugMawFRlDHM4aNh/shKOY9alCx8aT5oH4nFd7P7skwNxK7dCSplDduJA2H\nk75e\r\n=wvQk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-007c5ca-1610926003333_1610926052743_0.8625983190864095","host":"s3://npm-registry-packages"}},"1.0.0-canary-429f445-1610962429004":{"name":"@iadvize-oss/store","version":"1.0.0-canary-429f445-1610962429004","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-429f445-1610962429004","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a5f1908f04e00fbd0633afe18a30e0ce27cc48b1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-429f445-1610962429004.tgz","fileCount":7,"integrity":"sha512-UbNy6UMhzfFr49F9wvsPxQU59ERs8hVcjK/0pkiXZCOfozOOP2ZX4RXRF7ypbvMm+nL7g2vqK0FcSwn1caPvhw==","signatures":[{"sig":"MEUCIQDOpPuf1/P8cQJ/tb75LRHsMm+PfnY9e5C/ygZvBwPl7gIgU3ZBJpMlO4DnuJHRiwRv7UGpIjfJOuhUrVjr/nXgoN0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBVYvCRA9TVsSAnZWagAAT9QQAIYLNQmnRC+qI1XO3RGO\nvndjqqnrvJkkkpp1iUIL9NodJS0nxBqnezNRCDC0ly9pOlwW7BU3eXEnhjZ9\n54MGOkPxjIGK6TZ2HWC3f+xJTpTJz4aDqq+M44sJUHVxh11c8UDpFkxSzQcB\nOcDcPcRK7gMBp8F/rLPrlKipPuyPlD028hY9anCGiXbRSqVjNjV7l8qgWGwk\nw+/CTWyMmOh304LR6nqX3JA7mH7m6BnbnElYSy11+Jm3z80qP5VyHlOb79G6\nxGU735nI8eXIIPmSnGFrrTuFPIFmos4EZeZuSuB6SuF4xAgoaNG0D2mLdV4c\nBDtfg+fcn0IATF5iHH1XNg9RsBNDVd5alABkZPGQHmg6cOPoeNKTCw8hFoYv\nxzypNxC3/sXAJtAFotB3GKAzA6ildHmz+KwJ9UjlzS4a+A5CMPpaJcfPGgM3\nkI+z0LCKwwUSpIe3+MG7ky9elD+dMr9Yi55vfnWc8o54eB78waOZJ9Z1AZlU\nKyIdeNiesQ8NXeDJdYGNPcyQ49YS/dYyOrWcALXJjyBQgbJ+MJvFEhXZHyny\n2++ZidjYp9HQHfWyKtNTt8bz+zDXXi4Q/d016HCZDuKE3Enbz3AsjUFTkey6\nLoaaspo1XwXMakywBQ8yym9Uq3Kf+pTyVPyfPIEvbGQhMO0ITI09GTYoJ5yX\n/J/k\r\n=n10y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-429f445-1610962429004_1610962479427_0.30141918292489867","host":"s3://npm-registry-packages"}},"1.0.0-canary-3caf2b2-1610963526855":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3caf2b2-1610963526855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3caf2b2-1610963526855","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f30f9e2153853d26cf93ec9deb560b7e63801c52","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3caf2b2-1610963526855.tgz","fileCount":7,"integrity":"sha512-O659Nw7/WStSZKnyT3hJtQLHdBWnSFf6dcHjFAGqUywpv+6j/XsPosFcIK3VJy9eF6dszmZHOu28KgDTVee+kg==","signatures":[{"sig":"MEYCIQCGwULxEqzMtXTaPXWh5Gp+mivi7vpprfKG5rZp7QAlywIhANPX1DH4iNBWpAVoae+KCX0B1I+5mYo1AAMbY/8nAKhQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBVp9CRA9TVsSAnZWagAAAEUP/ibrq60on1I13M4cKvDM\nJVSv/UUq/5nQu/c66jGrHB+Dm3BOhq5dxR0qquCf+Lmezo2pEJlApD4MdCdO\nNCARJSq4OMOlwBwCZ0zmsL067gGmyUY5t7mCuEx/AI4nsNS28AIZHrG1/RI8\nm3MlzViYeocqsTmI13jQFznr5uF8lxlNNcmwWNugP1ufmIgbkfPDsdZrie9L\n7AiJtiBaPHXoc2ppOnAlyLsivGJ7jw8PQbj19HRF5ClxZyspxrfRYCAm+LIQ\npMA2LDWr3MfrEAft163DhZkzr7LFypRkOgdFw+OESLzA38163c0fqSRk2G7o\nvI5myZJthxICSdd/K21stzrjh8LUjqSz63CvnADUoGJTa6rx4mdiKiZro+Fg\nvh6NPfBB3PIpbgyUu7pwOxd+Xwvtq5vspUDeT31MsM6/X2dRZXqyGYWZJ2EK\nT1i4rTAzvnciP843z5XpCZtF9Pw0haN49j64b23f6pWhti5ewF8JbPPk27Ln\nEw9PfbI55C6XyiLLlM12Aa1VPXzyAYATW0448JASjZME2uym5EdaR/ei0WKQ\nY5HGq+RPa1b9zoAQdDQvZgjoZedMeSoTxETlw8Npq3XeF6UNA/+Gps/E1Y9G\nCkE+pkJOmzAEIBXQ7eDg24WzZq7Sn58OOAAwxn7q+W6uGreiZbVBsQeI5Te/\nTyNe\r\n=pJce\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3caf2b2-1610963526855_1610963580254_0.7348138320952935","host":"s3://npm-registry-packages"}},"1.0.0-canary-a86cc65-1610964044685":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a86cc65-1610964044685","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a86cc65-1610964044685","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9251fdf076e34dda24e289181587e470ae0f91b2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a86cc65-1610964044685.tgz","fileCount":7,"integrity":"sha512-0WSEr7mPd0ziT/ebVBqaq7grxxap9AkbtcMJrMQl3m5x5GdinYy7wOza1TAJxzP5J64IFaZrkx2A9TRpD//eWw==","signatures":[{"sig":"MEUCIQCSAvNhfEv30gW4l5P07cUjCDgmr6joucSobsNTbIXSPwIgapiDyKB4SMTjnCw4MvC7sDUYRFdl26B7gK0mucbZPI8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBVx5CRA9TVsSAnZWagAA6o0P/3tCfp3QqMLvYsMkRtit\nhRq5yXXXQFDvGMVGF8rwXE27bP8N5TSuNXiUqJCWvzrlVel/bYIhZ8Z6CXq2\nkREc3bWXo0jKPS0Gl5I9hiOWZlMV3HSxQUJ2ldDg+1Vsv+cGsrj/BoDf2/ZC\nSHOjODJcEmfHcLlxZms6Hhamv2ryie0t2T5wzHgNIR7VAF4UrJUXhnaMj79Q\n8/qZfCYeyb5hIO/4uZqafzHfElSO2LjqYXa/cmFrl4u31ls6dixpmvWXq9oU\n5OvyaBpPv55Y3GJADfHYWFA5yTk0rmY42Z7nMmkDLiY8TyjJSsTSOaiDLIav\nU2sJSK0ulBpR57z3hLkxchNpLyW6k98OB8npZb3BEeFVgBbUrlDYk7VvXdj7\nqde3dZdctuby+oQRrjJzz/l0cB60xWKK2DLIhGZ91zNubINKGHTiJ5d7TRI/\nLbhjLpCiuUDNiWfMt77wf27FpGuXyUxMRQzRoeEykxH6ITTnqjod3wRxSGyA\nCndfZXQigcnJk8cSWzjc+s3jXN5ui7BNfyFJrGK4EKZKsE4BaxM/GZwDwtLx\nPyzbARmmKm2IWAQ1a1XWYNaZf+uG+T9oTXO0ZH9UsKzm1pBrCuxDLLa8KR0U\nleqSK3/6HveHpjXTbz3j4zD35+oQGzAEajf6H+LtK9gLuyaOGDXeybPeUJgW\npEZd\r\n=xXPn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a86cc65-1610964044685_1610964088819_0.8723408961575605","host":"s3://npm-registry-packages"}},"1.0.0-canary-d9b243f-1611045870922":{"name":"@iadvize-oss/store","version":"1.0.0-canary-d9b243f-1611045870922","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-d9b243f-1611045870922","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3cd1e79463e414083cbdbaa7ce21e4ce5e92058a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-d9b243f-1611045870922.tgz","fileCount":7,"integrity":"sha512-EnH75KeN8A+RPmzLktFHehFd39hY/fuv6f/TTU/i3SlcE3lNtVAxM/ymfxXJJbEOuPwO6kU/gR1BNtylS9Q7Hw==","signatures":[{"sig":"MEYCIQDh9IbWr3uhzNjy+t4ejbNmIb2Cp03IvLpGVWZHDvW7HQIhAIchk+4/TK/e3csdm5/sJt8zbXOquLn+v12DS7QYz8d4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBpwiCRA9TVsSAnZWagAA730P/iYW3xj39j6y90wDyGuY\nz+StG0bl2Rulq5f9nTdwkFkYq6pfWYC9pUX4Qcpiy9+jgwgc83g0jB7UmBEv\nl9haqh9mvqx4lfK0WSSUJsSOM8tZAo+iZ0brHRYIzGUIVWiamtOXQMt+wDJR\nxRavel024LJ8yJfnylN+7aIvW1i1j0WmKy140nCwq4beM6kdQxuypJ5tfAIK\nGZ4qE8YH2waGbQ9MsQqI5Emt9U8WZAKEdzsudB/Y+5KexJXmrfVxB+DQis06\n/1I/K992x9k7XqyB4b/G4akQnHnfdrjiYQVpvWUbcBbWfK2u99TKa0Ty4d0N\nrozwJkoMvBLqnNwqSpIkO1y6czBXkUd3wQUE5an1zB5KNVbbGkIc9yiTVQKF\nl6eIVegkX5vnnzJ7d9FoIslSuEBdlmmJ8i0XQmlG0UuqF6eha/5Asdt5HEG2\nnlhwY1VgrJMpr2i52HcoylBP+WXMRWjFxQoWC6AUZZ/zrCP8mrWldWqslUMR\nOmhBDwMovNGTgvDcrjW7Ijn1my9pNxBeb1zWzy1BO6pMBFi12vCEQDc9uJQO\nr7LxsEbdTUoE1UPD5kZ3o2v1zxqIy76mdbOeuGmjIs3lQelbdUHDg1Jep/aH\nI70aoli9UK0h1Ms4QFpsZGNOH4wFRFc3HKBSxOS3IzYr7Bzs4Mczb1sl54KF\nH4S+\r\n=rmjr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.0","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-d9b243f-1611045870922_1611045922088_0.33018992734879915","host":"s3://npm-registry-packages"}},"1.0.0-canary-d9b243f-1611045873380":{"name":"@iadvize-oss/store","version":"1.0.0-canary-d9b243f-1611045873380","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-d9b243f-1611045873380","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a7f2126bb2fc64ebb6397ea9b5a5188407e7746d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-d9b243f-1611045873380.tgz","fileCount":7,"integrity":"sha512-jScmyVmt4Hh9IkO8hO94JdGyGSC+1BmAPzBMswnhObh1JccanEENHc8q1PRFB2/DUqqeNyVGXgSgeCS9I5s34w==","signatures":[{"sig":"MEUCIQDWP+DRw4SRhyt3vYX08O/d2q0aQYYjslWMkmVqhBjnPAIgYhBCCDvJDNh2/VMRUwybzydf3h7CzBXLb1KSdF7VKh0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBpxBCRA9TVsSAnZWagAAuN0P/i+l4lCeZo2tlL5NiNbE\n3SkiiInIokpHYmAmRkb1E3/ytiSCUAVsd16KfEwt88mGJUxLEcMXSApS79V6\nnQb0RESgep4+dy42BYJc4l2XKRtf/6cJaCmUzSXoBvp0e9e/sYagMYXmnCHg\n76UxE7hEE9OpbaQvuqTe+Ev4l1S1/yJIeJGrj/vcZNf9famT7RHq/z01nlZs\n68p3UeEb8zvv0Jbslfe2hmK4X5vniJB4ytfle2rfHKXNb9WUyP5JT7MS7Avt\nu+Clr8vlow4r4sja0TYqAro9trfUDa+/ovvnid6Gr6xeyRdGCwPpF6u72dC5\nN4iDd1uo5DndjLh/FFqwOFtpliAJ1+kPhW4UZA8suTwXx5fHhbDF/7budebQ\nwuziqVBtExuz8KvE+8fKL3MN/xzbWu7qDuVWpzDx2XLJdsAedPyBGKFE/Hd4\nvM/YiIOeJV4UVizfeF4Gbf1ilTx2LepShuBS62RWmVxoEUMntSeWfp0CYscC\n3+Vm9X3gYcr7RoRtMhumoBV8jlJ1w/z6VorgJbNGnaavmQE2g1bfFk1+LK4h\nkmAQcDH7Hp3DyCSQbzkmi/F6ew2P11D42QALh0Ixo0Sg5ckmhvuoRMvFfMvT\nFoee6vvNUENbe9aXWl3y7xseuSrrfWyVuX9g06JovFik8GvDabD4QUpF6oBs\nKIsE\r\n=zL+6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.0","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-d9b243f-1611045873380_1611045952856_0.6344417145786663","host":"s3://npm-registry-packages"}},"1.0.0-canary-6c6b141-1611145527857":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6c6b141-1611145527857","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6c6b141-1611145527857","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4b6c4e1d5df2e0b99d4afa4ed7a5c179582d4bc0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6c6b141-1611145527857.tgz","fileCount":7,"integrity":"sha512-wsTA2vr2VioibqC75XTvdk3Dadvk9drH3FlzFmcD29s7n3qyeVHATehecjSWtqEnFTGF/V25nNSnVnT3724Crg==","signatures":[{"sig":"MEQCIGKAZZIqwcC6VTu7tDC5Q9CgL/hKiegDZvGL8AyYdzLnAiAFj7hX3TULXmNYCbtRZkX+Smjbg2FqhVSB6AcW+7+N5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCFmCRA9TVsSAnZWagAAD3kP/iVm1mWnPccZXZS6n2qv\nU8xNm5kDI0srxmwAUUr4vou2gbrZfrjOhoieZbRB23J/gDOCCEOlyOyzR1v+\n45945cd7K2SlkjoVOBIILLksODKXBCYxoYvfPjJtobRvWpXJzwkZykYZqzNq\nDwrUFTAMyonryM5bXd7hDib1a2tAyY6KdATHryAuO8o25LCPvJt3cbdb7ZRq\nXe5bdRc7JAh56v9b+l78MCe33YdrkHgPAKwwFzzABT6kHDyU6/oVPgUcrRBO\nGgONgeDq9z7iwijRtTkySApSzp5ouZEekMEboNsCtMN2UrBmhqxkatAqLZmu\n4HlrVuqOZs5BC2cXujZsqRtuN6FPnIu+bQtCFudNa8cihHmBf9YwwvtRFBdq\nw2+n47NlJBNhNt2UoL4vQ49y6ih6Y1zm+s5w++hGsKKvULklIl8xbEWiYRAg\nRyCCHznIi7WMsmdvf22CHzF19UUGSS8DwP986Ie8aPRVqCkNH3g9im/pUyoN\nHQxNM+ozqDFdDlaG0ONPdEBIUuPCE2ewOUnlaICXzpCaMBOmQhbf/Lcw3cVa\ntkt9ybhhc/xHrSDx0PSIQkLl5UjEj1FOgJtEjvoaxdBe0z695Vpdl2zPTb5N\n6acq2ZaSzSv41nDBFyPdevXEVd9XfcfI/4hhfhz682KFmAvrlTyzglaeUoWm\nzgKG\r\n=DeiI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6c6b141-1611145527857_1611145573674_0.4338316984883126","host":"s3://npm-registry-packages"}},"1.0.0-canary-6c6b141-1611145532260":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6c6b141-1611145532260","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6c6b141-1611145532260","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1b2dc5f2ff4659cc9e1f7e07dc2ba00d28129f14","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6c6b141-1611145532260.tgz","fileCount":7,"integrity":"sha512-Nl/NKFdADAYbqPpLUpdkyWKFD8LMtjidtnKPYIMcontbovEB003Vqj4aYunYpMxL5B6mmuoFhELI3UXZ4BDuIw==","signatures":[{"sig":"MEQCICHBE/1vm0pYAkzdzCk57bFC90+L9wSYyL3wC662CWxSAiB7zfZG/ZkxiQQrX1CLGbJDY2HGK04UHLm8AvSWNMutBw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCFwCRA9TVsSAnZWagAA1sYP/0O/wqT+UAEhl6b24kz8\nWKIQQnHmT3z0Agehiw1ZPaAOFIdFQAPFxHaDWrB7iRRYzzn6k9NZZEcUSO1p\n5eT4JcTCwMYMcHKT3NWCrR976BBgBiGhmTbWiaUGpYOTEGRPfkvehtaLOG3d\nfMyIGF/RUYGukATE2NBLaBErO6XvbcCAxjhsjt3kHTxGzDO42JCfqWLWx96u\n5/VhrV/UHMV4tMLGwdkyw6OYa6Vj6YkMlnn9oGsGydoU1dmcmMe+kzJYHd+O\nypyLs58wWefaIsu2OIFkSz2dtTEunvaVemb4gPTQLB/xwliFnhdMfsBFM2yE\nlmK00wft6bw1ZMIrw2ik7zjRP7wX16q38A6LYFmW5+USwejGpmTeXBR7bOcT\nkfLbcgTyvSjwV9vqBbig0zJtk56hweGYnX1gc+Q2ykliCwqyLjCc7TFpC+J7\nyC+QchqaJlhLr66OXjnaPKr66cal672IF/gbLyvp6MxDvDErCy6MxQ6g0wDO\n0hOwbecU3jOEoWP6/gJ5M8rysVDYdkotQYqkNYRpgTXlTxIXzh7wVKFVNirV\nwbD/xvAFTZNakr9JDzDC3mdQ8c8vYqfwEiaNYwLck3eVzKvy7PfLJaGN33rn\nzmlgLUm3nqxNQo7/ZXjpUwTBYZBio8yIyWSJYvSzcY9J8QwVNRrTpc0Bblnl\nKpgc\r\n=y18v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6c6b141-1611145532260_1611145583525_0.6436763782134465","host":"s3://npm-registry-packages"}},"1.0.0-canary-2ea8098-1611147839098":{"name":"@iadvize-oss/store","version":"1.0.0-canary-2ea8098-1611147839098","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-2ea8098-1611147839098","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a1a45b3b908a9f7bed83171632dfd5c046647247","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-2ea8098-1611147839098.tgz","fileCount":7,"integrity":"sha512-rWRVi8/M3JGlzdx8tl/xSvd2BIU39xoq4VZlJEMQbu0H7aD0OwWAHHff8htMILu3C8/OO75oh5Evma8ZraegoQ==","signatures":[{"sig":"MEUCIQDgXEH8Cf1G0W6hdmXShMfB7EcmpY2kYSYKJfc0T9foLQIgM3D4S7ph0HeElL+NNj8ODNZzTB5lfWlLg6KpuglHGOQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCpsCRA9TVsSAnZWagAAvhMP/2toV3a2OXocZg+g8h6A\noSRa2X6rIWmkG2CVEngpZrvP2mw9SDlAdxldaSzesiC2iB5CY0W9Z1KbchFp\nwSzqibZvn8bv39PD4ZCqviwQVpp7Rhjp/usxRBXQ9RVId7ACLQIx/2IcGBXJ\n+XvTwjv8M4YYUBznnfcH62G1KNuhKb28LpDzMuDTt5HR7KHafRvGxRuWQbto\nmpKt550o05FM4KeT5YYBzAc+AGj0A1wvv/YsALqvU7DOaBAZV7IIbyK+2Zis\nusu3wFQCi6nZg8cYiAAoE+QLdmbcU7sBAaMvbbDK6FkWf2KnGSPqU8ldtTA/\nyxh+nUBsT8WZCsfxuNuJeWogF+9y92gTuesdetbJncgo6hKNbh7NaVe1Pso+\nu1MpT2uEnx6/lvy0bZZAfIRNCQLfs989hNohsbqTaqFrFcO9YLeAVbGr7lTF\n0ToE4xK7FptPUWPQcNG1ihALZgYdk1NqwgpywB72+YGCA1a5kCvRk0N4fs2a\nYw9Mg/n6dXYmGCdBlrZ143kmWuEHL61H+pgu9TUQ+P+O7f0H/Ygwlxev8fEl\nUdJMRISv4igscdmkPHwMOQwh+g6FDmzMtjrW3+2u4eB9bPUw1ggP7xasxUzH\niThOKaT5MbqZ59gusR4UYstR9LsFtZFJFLJuJTgwdIlaplO7lISYCv2CBEF3\n7h/h\r\n=mDgD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-2ea8098-1611147839098_1611147884294_0.8902331873303742","host":"s3://npm-registry-packages"}},"1.0.0-canary-a7a4990-1611333154002":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a7a4990-1611333154002","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a7a4990-1611333154002","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"94a25f0eec74b946ab8177a9a4d04d851b5d418e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a7a4990-1611333154002.tgz","fileCount":7,"integrity":"sha512-O/ui51NLEpkvHvUwRs5T4Tuu7+x2BymFiNVOwIimppZ9VNG+Rl+GXijUrOwWecwG6maYgiAGM3cubBKgg9dOjg==","signatures":[{"sig":"MEQCICJTw5vRT0sy08UeB9uN0i1n1fv0PqKXf2ZCFVUqI8A9AiAseMuI0dsoEmnlwf/t/J89pFt/Tpj6W7gFkTIgQeYW9g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv5ZCRA9TVsSAnZWagAAqZwP/iIODWxO5EsgwpUllrG5\nMtWXdc8n3hPZRDSqHa9QRgbHIkmwNvi1YrwnwoYWzFjXrbz9q43QSc03Bwbn\nC4VrmVCkR/ALO4jN4WsL9TZIN8GcNaa1T1pPI2AXA/UWFIkNRG19KqyHmwe4\n7eG6ZHXMqiiloPy/QcN7WQ7Txzz/UZ42rmLXULrKGTpgADgPs4sNiNhhwOdo\nDq7o4Z59kNVXNaPWsgXjaToUrd56KjflzCkwnMPJ/v4x6MLDdPMR9dT7l9J4\nehaDcnwRpNdNQcBHOX/d4cqMumLV+ZkF/2nmYf7jT5e4yZKLBLw8SXnMTND5\n4rz0G0IFmTUCueT/GBwtt56K8jXqhGM6AokfJ8vqlr4fOV+hGyMXhuYFzbJ5\nBUa7Ltgm3SbftvLRkkkKjGtygj2l2OTpHr+HftplBOaE6l1jbqPCNIugmgHk\nRx3zcmVEUTLPZuhUx6Wi5y1qty8076NbmncLDRRYB2JYuaSayAlZwEa48Gvu\n2GV9NOuyeD9htETbyyitzwm9vAoTEIva8Cff8AudWROY3w4tQCWD2OwnnWBe\nLapa/WrEcLjXN48fGyKlyM5ALUGPHsxo8qMs6B7wLHPOKNZV5PCzmqow/nv/\nl8Tg/MI6rLc/pkcuPnE2Oc1jQyAuR5UohPoACLcpvhdFKhOzxcYK8ycHTYGU\n+mey\r\n=3w1P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a7a4990-1611333154002_1611333208826_0.8151596205496545","host":"s3://npm-registry-packages"}},"1.0.0-canary-a7a4990-1611333153009":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a7a4990-1611333153009","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a7a4990-1611333153009","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cff2bc3100445daf550c64c33486e0c9454f469a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a7a4990-1611333153009.tgz","fileCount":7,"integrity":"sha512-VjRmQdk5fwowFE7QdqfPTjY3HE6SEbvTbWABwQHcbiYrvhxhdIXanb8QHTxBQg1jCb57GHWuYYRY1+2haKDYpw==","signatures":[{"sig":"MEQCIBdPohLIgf66CGZq0UNib8DijfOalvKZPOK7AmNlTKbcAiAk1hzFpB4vOb6XnUN6EMOZ5chxjCNSklF0eb/geebS9A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv5eCRA9TVsSAnZWagAA60UP/j+3U3qipUkuzxVBMQ95\npdByHzRumI9xtwjMwLW/PWVit4489rhsZQCbqn5FDg6dV3o8f76VxoGICTWD\nNSdQgqKVxx7lh1cbC+KqOspjM7w0DxVgIVN0HKp3DBgUQbxk/2tu4iHMJOB4\nU+TgY+uBfV0l55zrCes8CdRgD5wwQYF1h07CyuexaUjKI6rFfsXoLr91OA23\n0NBLx2JMdeFi+0kQuh28V1lYtgAuLiZ8hQQKZcLw8VKkRFUcKUmNtgpQ966f\n9k0Rci9PwYn+oWiPMA8dwKeXlkElPO3gtbSmahvegkx/MuhH5aGX2DBfPoee\nrVVtMC815bL/RFWHnF9KBIuKnXpJFmFMh2LcyOgQ4kKKip4eN+tzbXQd2AVF\nzOM7M9iNBifeFygMZex/8I4NRKT0nNdVyKXiM+7ppgoaezsTV5dXYhdW+ocD\nueju1CLmoKK1FzvCu77HRNN0BAcZPgrbj9n+3uwFWp3CEEAdbejDSMyb1uUF\neOwPbGNLG8yW77O0nyrIfso8/Oxz+vzi9uVcOICLuLqvMCWI/ULIyQDFxlf1\npNagXuLZlLxh4htZVhdgH0eUr6jY+PWiE6XG26d1eZn0AOtHLyFzZpkK0u8c\np/jM0JMQtWES3qJA0mxEUwCdn6Fwu6OcZKkIPtAHJzty6Hswdy7KL/n0Ww3R\n0LMM\r\n=t2Ws\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.16","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a7a4990-1611333153009_1611333214470_0.6968172032515096","host":"s3://npm-registry-packages"}},"1.0.0-canary-1bdfdfe-1611433257912":{"name":"@iadvize-oss/store","version":"1.0.0-canary-1bdfdfe-1611433257912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-1bdfdfe-1611433257912","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a19c16635354ef1e9f8fac576c36cccefd710df7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-1bdfdfe-1611433257912.tgz","fileCount":7,"integrity":"sha512-7BhXWAXK62s7cSUS3uttXbv0INRlEUNpualAEkhiL1fEuSsAcJACl8GEZANRxuMPLocRuegeL24rdXYVmko3eQ==","signatures":[{"sig":"MEQCIFGmQv/FHZrLlUh8XzqqrYum5iUvTg1pyDc/DVZQcnQGAiBBLcgzGo0B673+5C/iMH2DYaOpOaZkJBClY3M4gjMwTg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDIVaCRA9TVsSAnZWagAAk3gP/0pTz6Dp519VBdAABu8U\nphgEUoZ7eXtrHOU7JFm1R/8x9goSmVX9JYUwvT9P32eqG69TNNl/u1Qcmtvs\nZTLLBsb6U7tlsPvowmdfhRl18ILXf0i+zYNA589PP2H0FIOmvZcVgJNXIpS4\nCoYPsBccQqibQT6qFFAMf2D+cEXBG0eKuwFmdXLQ1OZunaXEarunwD3SZ9xw\njjkuNH9Foc5vWUCah0Rmo4JdfgTD6jFCNOJ32aDNwfuFXSAG1VLgmPR0ZyH2\nEfNJwk15iVYMFzG+yyeU3X79xH/Axx3YayMWGb8MK3jjJSV8Qv2KzCh0wDqe\nJGjagGrIncQJTueCYYEjmEOo49haVc2WcZOv8u+vtKoaOXC0Ud8UtuVDpGDB\nwZ1PduW0isI3wAgvFXbYq59CW3c4uqoZ6OHgqns73uFrC4/iOEREFRJJZzXW\nAszQxsVBs6VA83K5htL/Y100va8S16IPsGwZt+hKX7axd1mwIq95MG2yLowe\nf4vNUxA2aVS+TpJ39Rb2xWBnwbTU7sGKUym4Q4YnChNYBVL1x6lOWJOi9LK3\nZ0yj8tt89zwmniqJlnhlA8bvsTvZ31vaI0dx/heafsFCr/6SOyhkG4/5s8nw\nFZNZZxigHwbBFhhfWygz+MuhRTZCcK64AiUK2PyfQ27mBK2+k/hEMwxgI7wi\ndUob\r\n=ZxdT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.17","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-1bdfdfe-1611433257912_1611433305642_0.18823802945831547","host":"s3://npm-registry-packages"}},"1.0.0-canary-d0600d1-1611517062925":{"name":"@iadvize-oss/store","version":"1.0.0-canary-d0600d1-1611517062925","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-d0600d1-1611517062925","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1a24f5ccc6646376d978c2f4fc6dcf4b09779c27","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-d0600d1-1611517062925.tgz","fileCount":7,"integrity":"sha512-G6SqlkMaqmIK0akdTc0bjj8KAp1UeTOcnUvLNljXNDsvEqKfB594yOUsR9mbvFEcT7CABLi49iujvCc8Ga6eIQ==","signatures":[{"sig":"MEQCIEDvPVhpE/gkZgNMNJFgz6Mqhz2uk57k/mWwJ6TihZm5AiACuRPiYoro2i5F98XycT2X2hhnQeft7k5sAigOIXeCaQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDcy6CRA9TVsSAnZWagAA4m4P/1iNc5OgfMh5oqbCCCto\nK3ipSaLf10gHB3YiYXfr6MQ/qa1+pZnneFqQvnx2LNfGXRMWXCpHOKlrm6vM\nbSU7Em4sIGRu/y/E4iXp5qkcCWTSbfRES+RCsGGci34bgX/WQ3ZL2S0J1QLl\nAFJwtxO9PO/fesPDxJ4H9SrCYBRwKYxB2vsR2hD1KS7MMII/sgX0fBe15sLe\n49a/04XzTehC3qV6jFPeSiUEHnW6HbKlmE71kf2NIikUu704S+It6a30j0gL\nlur2RJRGRUbEc6CHiM7WQHgCbsprEWgiqmO05BP4CHDFQUfIwlHcgxTQhYIK\nTmLNkSferHwMpAY/Oc/PSfoQe3kV7LXZTPjqj3m+guxZ8tfGqmXY4dAAud2D\nqPYFRxS99U9apJiroHxIGKy4WXE3bwSJz+vkt5J5KyE7jZiDvy5rlRIkOwm4\nne5Nsu+msQRr7+C5CxxB6alJqlqGHitDcu95cSge2FfnKEKPQIvMqqBjxsTM\nr2wRr9/nCDPL+g3D0K18Op3kOGxPrtl+dqMzYEwCVK/lSbR+zxF0x8C4XwX6\nNUX9yTyU6zGS+0Go/9YdDa8Rq3ZX8ztlRE265GefgSSw3lfESmDXmv4G5wtb\nVby0vU/QKZVQNjZaKx4bO36XvdqS5skx5IfnIa/dX0jGOqqxIB9JrqlTe1iM\nY15t\r\n=OrGm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.18","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-d0600d1-1611517062925_1611517114368_0.4787020014285328","host":"s3://npm-registry-packages"}},"1.0.0-canary-8954eab-1611530086839":{"name":"@iadvize-oss/store","version":"1.0.0-canary-8954eab-1611530086839","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-8954eab-1611530086839","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"51554e379f8e3669c9198ad3a79e28e04a5753ef","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-8954eab-1611530086839.tgz","fileCount":7,"integrity":"sha512-Ky37THiwkrTsIiG08zK11e2vpjWDsKVzPOz5eNSwGaLkiuCbrEGCsvynkao+ttX2W+h1J3jq0fML01/UFVYspA==","signatures":[{"sig":"MEQCIBSB3LCW8d01XL70CiWgd6xkUP6xdjefUWiP8FVTunGlAiBOxBhkx6/FL117lbKMPRg4NE9bzd9wSY52LlcQSTOd6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDf+0CRA9TVsSAnZWagAAyggP/00wwfdNrbriCoxl+8oX\nZakhaufUta0lDBQfTq+oiIgd2CqlexvNqTJQOtHadG4L2rHzS1/kMllv0qiz\nEVg7DRrZ5pxFvHU//PE7+CZE6cKenteKg7bagMpxiLFdtER3+Neh6PUT0IuW\nSrwYpD/iOWWR04batKLRa0wwcSnF2YWvjL9OoDnCAyO6XRdcTlMCBH9sB1kE\nefywcqp+HeCjXfr5eOrVYneGpWLZXg+jksF0Qlga51UnSnsnHHoQUdJMJQfp\np5ROtyWSfwoy0Gk1cq1jHzkW922z38Pyf45vdW/EuJz6sEM6JL3LSMnTp3nT\nTHf1tveGh3x8c3o9un93i5PuWdOKv9a0rfTbFSX/ps68GjZiBIFoKezbpv3P\n0F4RP2O3wIOAuTADcb8MrtFIlX7AiHzbkLylmWgl+5HHsOI9PiQQueH82ayA\nGc7NtfEGKvk1QOBk5oD4NHa+gDNGcTIMqSRM/ROpEtFTFX1pwSnDhUO+md65\nA7aZQD/2ouG2DkpZi/IOssvg7cDrefVWEVf4Rk2YXP40eDyoifi8JH+967h6\nxP/aeYApRFGdgfzqcbeezWGx9dk/27KRqf7eAgpuDZ6prLeVQAc251vbQI12\n4hnzf/bBCzkUTQbKWMHD/KJpVIy21R4WJtR8Oo94ROrj/TLfIVuw9qRtP+uK\n6gLu\r\n=5zrD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.20.18","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-8954eab-1611530086839_1611530163642_0.9871904471523634","host":"s3://npm-registry-packages"}},"1.0.0-canary-300cc04-1611565391346":{"name":"@iadvize-oss/store","version":"1.0.0-canary-300cc04-1611565391346","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-300cc04-1611565391346","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"08c757da5919581664201c726586d3b0f5ccfb60","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-300cc04-1611565391346.tgz","fileCount":7,"integrity":"sha512-z0/EPRgVj5Pb6rcA51oukW/89UChRDxqgtyu1kicjD0Nd8ON0fdX8JTijvX0PRUS8E2d/f9rpY9X42i6VW15bg==","signatures":[{"sig":"MEQCIAzkrzBxHkPrsnsm5RPxausCl0xiPcGKfaOUEQ9ctxbBAiB9YLt/cUcX73852i11IspppNEMQn3qKBUSMIXTT/CyJw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDol/CRA9TVsSAnZWagAAegoQAI4GWpc/m7DhnLhwKIAt\nEYxEcMveT5pTd3Hfy6e1TLz7w4gCOJhiIct1dxIkct69qisVdYSIjpkJDya9\nf1qvOY0oCQ+9E/u8tQx3PkhA1PX/zT/DLnhYaITMiurQWnCl/89r8UalBB8K\npkTbSFxRGjpObnkVjTU8y+O9k8KkqLbcPilpIRWEaomwZNU2HA+GSYnweL76\nV/YqnDw69XIrlMkIhgFXkZEzo+43iiqTFeRnZHShF1F6oXCLZc2M7DWwT4h1\nV6Lw5pwIum9BR1+syi9bBCkcwL2Rzmhv5qxBgKIZCj7gJTnznmUNUwKWFhXJ\nbQ6yYPqmUbi4dCyJEXwoTkhWUIsDxGtM10VOpOeNb9Ku2OhIwPfz/PChZUV9\noM434AG7Sl2BDrFFw2h9OrX5rgBG1WKRNGec6srDcdW6D/30rQ88bofJo8hc\nT1zHKY8aWjfAes/na/OtfgHZR2E2ozYkLHrWbFI555i9Fu1uTyIpzzS4JBZz\nkKnPrz2+HTmUVss7f9OkRHKHdDKx1cj6usuWFotTtdK03ovnHj2NLCKoz7E9\nF1ptDckOxoY6r84VsKU93bQJ5bpP7rtRQ/UF5qnc01WvFJ24Omx1W74BpJAK\nq+FzVXtlyGXMBbCuqD6aJHvLeoL4b/Rs2LSrVSzO2kMP5zUY9/HjXJn6/rCN\nmWGS\r\n=L85s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.18","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-300cc04-1611565391346_1611565438310_0.8578226516137486","host":"s3://npm-registry-packages"}},"1.0.0-canary-147e9ee-1611586330673":{"name":"@iadvize-oss/store","version":"1.0.0-canary-147e9ee-1611586330673","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-147e9ee-1611586330673","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4bf5519d1fb0065b656887d9e32e3481d4de2288","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-147e9ee-1611586330673.tgz","fileCount":7,"integrity":"sha512-04pLnFJNVcWjSuberSRDpiWLxym0nMtmmZTsp2PV3fsD3XUhnlt0Cybde7WcMJlVh46aSsPhfuDGBnAPh9R1Tw==","signatures":[{"sig":"MEUCIGMeeKi9/VmBNhINtegTAVbJ1R5uJaBnbEEhZb+cNNqlAiEA6YESsTJoezw7lSL7+36W5uS8oTj93PzWoEmsNEXFz2s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDttPCRA9TVsSAnZWagAAdnUP/iS8KWvOMaBl3wkS9pIY\n/Q53EZtxn37CXyCq2IjJ+JECJbjQVSMjyZQtTe51tprOvWjfRNr4cqrRnzlY\n9TIEz1nvrrr1K3y/S4J20DRikcUj8Tz+ClnldJDWuVwaD1TEFBR4LOgdbw4y\nfH9yxG2GcQ+uMoeziprX1wmeX+l/Yu7XtD/kYq3WnGfXn3/twMtH8weI/KWc\nwsd8Fr9lrLvnySUncJ8Gfd6+k4ydvZrLqFvjNjmXVJ+eWcIg1w9lEUZAQ/nY\ny8gFr/S1lCeGCatF94xjatyev1osK/yym4wevYE2n7ddxVI5ewynDth3gOlp\nGsaFFCVOd/LmmtTqPvTm6b7M7snG7t9u2+nmU1VtpFP/RvTD2z3bZ5XVnCs6\nC6yFSMGLJhQa8roKDMlmkmNlvyBSUbo/+jtTNrAwMJtKCXCWXNE6hEzkd+TY\nk+UlHfPSFjHGRhdo+Xi8m+mT6gkS/S8mFQ5xFIDAWyUDYqDgl64AygG6k2Th\nVL+3S56vnrIG9kK6gtdC8kbNgMS/tLQEHj51zWC+TD6x8hWhvVj19cWabqVs\nJh4NOGOvejyuM/qzrty6ZzS3/rzFvZriPhPwNULjJYqOW7pCgg4Wkalo1FWf\nV7iJxy6q5sCbdurC/wPKvfdn1v97iNrUPu3DN80KAu2YMrAjXC/q9GZ82cSC\nAUQN\r\n=2GP5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-147e9ee-1611586330673_1611586383089_0.6031578649365175","host":"s3://npm-registry-packages"}},"1.0.0-canary-147e9ee-1611586337970":{"name":"@iadvize-oss/store","version":"1.0.0-canary-147e9ee-1611586337970","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-147e9ee-1611586337970","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"85bfb115b84c77893f60c68e7e44040d0a197db2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-147e9ee-1611586337970.tgz","fileCount":7,"integrity":"sha512-SVjcMYwh/hfUTWBZWKS5Tk+lyFzYEUxi7A7j5OXY+0qGZkvPZuvqkCkZEp0Ja4owsJecL6muMH4cmlNOVTYrcg==","signatures":[{"sig":"MEUCIAwREZQcQlsCtkfGdvZrzfs8OX+uYfObUrlh/A5CcOkyAiEA2ifOTaCITJhbKv5Pd8H2S9QpBtC3DLFy+qqII8j/M3w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDtthCRA9TVsSAnZWagAAqYsP/3So5qwXBstTaNsaR3Z+\nDJ+O2KpK8o10jFBrXLwsFjK/CqvEUgfxC8x7YAaWDQR6bUeLrXBzjDT860Z6\nZplRfF+VxqzmcG1FHVWr5oQ1aSSXrtXrbqgMUpe5W0gcZdUyomhAQgkcTbLw\nwDC1OltD/Mw3TJB2adG6nMm/20R0WQmB63HR3c/ZdYpseOo8JnROpLnieXBe\nq82Li2sLBledCjhGfsnhajkPlv1aDElsmV+ddtDtb53dxn4Wk6oVabGyah2x\nm4Sfu4cVgSya2ofZpPpFXI3RulI7SnO/527nRh4zx26ieDXRZAE66kRFbIFl\nQWChM3rhgQulk/lFafIwbpRHW4QUxBS9fiDlZY70vY1XQq0K2jAmSxg5i1yb\ngZwYPKSARYJXu3CsOR8qfxjxD/oQrQ4BYODkcJjISI0zO61kxIdRvIfJUHCo\nrUmZ7UmRDHSr2JLR3uxKHiuZ21yJeD2n4GpDPwvz/79xTPnIOqPB/bCTjwJO\no/B+w3DAXWn9xjqUNTh94T4jvYFW9deZI21WvN3fdH0Thf6gLjXCjJlv9OvL\nasPxMcss9CP0tgsmjMtGxRN3fKU3EmLiodcd00qhITSHftc7TywpgscMA0sq\n6XVKWiNf9HPW5H0f8sLMmvcLath/3+8iaRnHb12wdZHO1XcsATTnQfSxvzcO\nd2HV\r\n=YYdE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-147e9ee-1611586337970_1611586401464_0.00018008213984543886","host":"s3://npm-registry-packages"}},"1.0.0-canary-49db81b-1611591150110":{"name":"@iadvize-oss/store","version":"1.0.0-canary-49db81b-1611591150110","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-49db81b-1611591150110","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b681863719f10db1d4ad7164bf29d45c8bec4e58","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-49db81b-1611591150110.tgz","fileCount":7,"integrity":"sha512-tjvAQMm5HnntjbGfIwRDfDUfgDGToajOvMJVSbbmGWk4PtN4b6BP3pp3ujGR/oVLGCks/dZtiDDjmbOsfF3bNA==","signatures":[{"sig":"MEUCIQDDlaGFPoecRmzsicHcyYgcKK9d/eR5n0bJUqamISBEtgIgPam5DTKgKzXgRNaMxzsF0LQlQENzdze1GItN9sSt1bg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDu4mCRA9TVsSAnZWagAAcU4P/jRaTyN4FzgUsNaYUIH8\njWn6xq2KvVtip3SUfmmV1+QSkNcdFwS5nG2Lm7dbPasR0F+tmbUOqOSYXxod\nk1k51awUW4AefZS8OduBwgTAs3N/cw0zhJUZvMc0HLMB/tBe/5j4W4OlprLX\nnCxC6hP++kJIh2wlYbBqNnJBrytvXdGun0uIkpEQ4hVWiiqzafr4xWbDgp3X\nlTlRiidDC2aeqaHLiwHx5W9v7W8heVXzag5yLC6fUZsBITScOa5fKR8xu6fp\nx03yMkeZezxEQvZDYM7oGDBtMtuL4CSHofQVg5CWQBQaghMNdmObv6qDMU2L\nvfUDCJHbai8Q9g0W7CeDjOs2b9LNuxnxDpfVOgZLy+wwb/3S9s1EItx5nH5J\nXqG3VG5W19Vd0oPtuC+o9Bf1VS7rIx1ZM+QNy5aId89BRQ4v+t+OZyyOMs6R\n6NRoZYw6TvY9fTVZ/hGtuKs39eQnp6c7xTC5qvZ+mbnSDuiTdCQX1ZpizU7v\nxq/dQDg01LHv7XC94nbi2mFeH7H7XzeF+TZFQZybxZoYRqUSwijq6NMMXXC3\nGuGmxzBPea0DETmvVelMKLJpEg+YHP4f500QveZutCAiuooVdpuRkdZaGfvW\nQAEOZMpaBFs6PLuIVm9udIR9NBsOLtFaVJeTwJB5/vSBj/XalBTkcGqpZB8u\nQ0Zg\r\n=JGIY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-49db81b-1611591150110_1611591205822_0.20095000052132495","host":"s3://npm-registry-packages"}},"1.0.0-canary-49db81b-1611591147293":{"name":"@iadvize-oss/store","version":"1.0.0-canary-49db81b-1611591147293","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-49db81b-1611591147293","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"69c5fdbea14a17f3ef00045e6ddb3cfafc550a5c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-49db81b-1611591147293.tgz","fileCount":7,"integrity":"sha512-wsCZyz9bN/ql3AZhrTb6cgcqr+q4f30nxHPahlVARNMLfg1857302NpGFKsFGg9RNrJzam0Pf8XTTK4uKutgNA==","signatures":[{"sig":"MEYCIQDHudXcVs20y8PdFI+XZNR9gtgDimIjRxDO1nCv5r1LxgIhAPEPoSPSW0S5dMYLm9R21mxXDYA3WQH312MGfH6ZeDpA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDu4uCRA9TVsSAnZWagAA1NwP/ip7iQYivtni1c4u25PS\nOrtBgxOPjLwl1aIeLPWrxBr0tud0tZEqEwV4zOdlRgN46M26G8ntjugvdMEK\n7oh//rHx1bBA6nly85NjavyUc2x396AePxPjDHpZhC5pUWlT3ch5rec0aUNY\n/svqTIpiIdpPrAnJvSdqxc2ahOhQsFByEYujjDSZKo/dZdz0ssuczf/9/Gon\nGhguAy4rCKB8a/wGTV+xg8dwi9PoKky2MmZYrFpq1bt9IEkHaVCMgrhz+Bfu\nwWcRXg5KMVsLU6aOFKzf3pdSMv+gwXVFV1+0aPI9LpeNwLz55Q44lxiDWtJP\n367dPKQVoVzob4Gptp8uTtHsdWaxsjBLospl1Oblo7FlWBCUKrGFYeM0nTVM\nURY7k1agwpEfaO9U9Z11a0D6l+hWvuXXcT6ckXHhepUxJ/sBFgjH78zObr6C\ncCyk4JIkphycElSNZ8Nn4XYJiYgakh3qeTmETViZI6RGcx9cPFHx+cxJ1dTa\nNrhzHNo7f3T0zzYuFomD7i3vZw4LnEenSabsV+U0XZachx3xeFMsrDYQFECV\nhKL46QJLF9+BPiNcrouSDCHJRt2AMi8ftl8/9XJ8YkamR3/HkMDn3lcPd55k\nXHXUBG/CvIQC5HmNquj2QWGkD8PpbP/z1wENt8/SUdTjhVCicSthhJc2jnCi\napL3\r\n=aCDa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-49db81b-1611591147293_1611591213759_0.21455567728760028","host":"s3://npm-registry-packages"}},"1.0.0-canary-3a8e373-1611616541373":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3a8e373-1611616541373","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3a8e373-1611616541373","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1b735e995c73b337050c3257b6033193db5a4438","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3a8e373-1611616541373.tgz","fileCount":7,"integrity":"sha512-LuevqX7dVxyWJ3v45xuUHcfQCq2nSUBAlIwJTqK1ZhTGW999zTBwFRy+RG1CbLnScZxjUvc7PBGG6ZH8BuWiaw==","signatures":[{"sig":"MEUCIQDZgcZdoTX6Qzuso5vPx1Dpzu6UGbRz/u2J5WYKTMeYEgIgRhtMIPhRNSXeZ0R3QR5IZk2GOyFD6LSAEFVeOP2ffRc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgD1FNCRA9TVsSAnZWagAAVJUP/08D1HosEzc3Md7/Jo2+\n6Ge4jLLhk+Wsy6MwSUzmOZveNe+TcsBZJvxsOvDvEgSM/A2pJ7Br/+c25lx1\ng/aFKE+66qfmMQUK0ZhEVghNVD+upczWFSjKQzedDKHUOaGWpq2/7cRT2vES\nrLd7jMOvyuUkBbj5V+ymi7Ro8Lhev+bN7+12X+s0ry9DH8t4feiuGIMU9pbN\nbhnjiNE5cwv1nP4uhXh2h218ATFqx3JSTMUM1N/n9uobkhPcAaJzULP9Y09g\nONjgj+JqIOgQ9lxwA7sTE8uGj5VVey/54F/CPJb4HV0KrPx/9EscOCxrmY72\nrplr5PyqTh44o8bplw9vWm/AI0PJjm0jQPHI04YlWW7icR/O/fnnlEHCdaDv\nfyrwaJDjMAUBuXL74xxcIIT/cBZplT1m4MPdRkkWVzM8lkHtw2saxvQXTfaA\nNKCmSuihHvITyvs3Lxs7XRveBOZdZ9GzwuRqftgDKhZrThZfeYtK2KR7uOj+\nTq9tYZJ7wirSzKXJPM3fSfaKGSL028n1Ps4PqSHayaP9DKJ5bcLWtPv5TfVw\nt1dE+/788PQ90oCqM+iAd4uupO7qspDo6uDqhPCJwxwDHl9c3JuTl0opiuC0\nXEejGYFVJxxjREXRlCErI3ZJ9lgw16pwvNjZjsv+3PcuUGNamH1zkLhD3X16\nC1zY\r\n=Qp/x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3a8e373-1611616541373_1611616588749_0.35482934220617035","host":"s3://npm-registry-packages"}},"1.0.0-canary-3ae21d5-1611843818150":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3ae21d5-1611843818150","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3ae21d5-1611843818150","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ad014f89f48353130a6f4287397fd92f69fa62d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3ae21d5-1611843818150.tgz","fileCount":7,"integrity":"sha512-OTsw1PioMaxyxvb3zl5P3/33jg2/ZlRm7DyAa9VcFkbHIn6BiTp+ZfSRf0saR4BIvwcUIhGerY8lHnxV5amZ6Q==","signatures":[{"sig":"MEQCIAQY3u8jL1fCyWOJFhn9aVrkzg+/FzoPfFbuktJHPTrbAiAsWl6/g3cxLEGMwYK0rDeMBZBqrJ6dpKUnH5U4Vq/XYg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgEsklCRA9TVsSAnZWagAAge0QAJiCkj2mGlXIrO8H+kyl\nP0HbRsuSL3tP5e6JCR7/5kEWDxGjmfDnLTOwlKkwDmfaGiUyzqz2iEpxCwqw\n3mpvYOf3DbL/FT/ykWLm74e1yX6kiXf8zfp7Uq7qs+PSHhi7oibS1A9dv3uY\ntsZlBwCIDVUPLXdWic8SqRU5fkrRMuIKIm1I14pMidmu7xgnY/YwY6msG6tK\nj2QMB0qJ6ionzeKPRHPPGnkPml0AoHXdfZKUFw5EwLZDexiaiUO/4xMeYT3T\nlR6vUMXdBSd5ME3EhrrDdLHffJsOaJx537y6x35s4ApBDiC50u5DQrhcpDyj\nTHC6iYM7aY4zJSomNQww/7TEIO7CMrn7Zc/tXA0jQIOQ+wrVERW5/TKxnmmF\nDXqKbDNNyX4SvvoMYpLGFKwr3zOKj2QusZptk5eML8HaX64KQxDkyDvzDvcu\n4A0Mcw4gNyDXsFJT+5pp9P5YO8s05Z4EBG0WOaTbqqi5czHdEvju+rbRrrTw\nuh4itvyFK29LgX2JAJsD7pBXo3UX5bIwLPYbG5MhnNFXDUrxfDHMSNfbF/sp\n8r/z8Pv6nFEQHMRbDEJZVs1cd07prUyh8YJ+GTqrlRc5z76P+3Pq8k+zM/fJ\nQn8b3Ys0n855Sd7YUrl6AOkppU4jv653p9Tb3yJkxRbXTDMhF/Eu9PUYNEVw\nZom+\r\n=F7QL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.1","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3ae21d5-1611843818150_1611843876531_0.8155379716561495","host":"s3://npm-registry-packages"}},"1.0.0-canary-3ae21d5-1611843821490":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3ae21d5-1611843821490","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3ae21d5-1611843821490","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5e61a15417726ad1d33d44ec9b85af3e506ca4a7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3ae21d5-1611843821490.tgz","fileCount":7,"integrity":"sha512-wbXJUsX1EUOOjXWt2RgO1ZG59d6GIln44xQroE7hyyUuD+6gXxLs4NRqBvSY9P0vy/FZdOP9f6do3lF2fHgX4A==","signatures":[{"sig":"MEYCIQCLdf1466ffUZMVPbIjEiFWAp3T+aGu0kbe+u3/QWVxsQIhANXw9MX4v5QuI+1YkiH68D0ic9Ax+9HiP7IVsEz30DNH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgEskqCRA9TVsSAnZWagAAsVgP/0Fa0dfWalAcIcubHLkW\nB21+tTsK/PaCZKATlFRviE9iGj+MH5TC/tOvCYXBnTDqHEeNbjjnRkL8snQ4\n3k1409z4z5F52LJJfol4kAA2e7oIgUmGWVYCn9HL36xRckTUdgn6NDUyvu2h\nDVV10B22MnlTHJse1/+w9E9mfZmBc5R8Gfx/qlhEMY8a3xTVP4LthWagdbdi\nZXEMdeaQjFGS5VhmbysJLftz6/R8Bgf1NpGUHfLuILcmR6mF4CG11nac1lGG\nymFceGW9J/inL04mQ3mufHQ2O3X6wX7K8MoyWaZ2h4D95sObRsn//WoQSozl\n/4bNT8WxEaoNP9/x8GDBXeFeDEX5e4Igx0mkJLhLBqnVkR8HOwjUkjXM8SiK\n0sPVtnTr6wuMsQTMBFPUbhOm+xB5rcneFePlgDs40KhOmu684d7T5PF4tNu0\ntW8zZqRYXWzhZYzaViQyhN+HhaDJnSYYaVsnCd28UPBxh1g1moZJQdRG4Z44\nQMTgvK2QEohY/1sbHQNGlh7DwfDW4OpBJT/4vL+iYVTGIiZpk52IDVf8Qwuz\nPRuo6XO3lGdlKvqpaXgUZK/F50W4Jw6E6HGhdtMybPioD4vT3yT0OakgBTf+\nBTOKlerezGlSHXNsJHWec/sismiglTWUh5Nm1bOe+SZWdRAL/vHPb/Dmqb1s\nuS3w\r\n=O5xa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.1","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3ae21d5-1611843821490_1611843882363_0.05377381357558919","host":"s3://npm-registry-packages"}},"1.0.0-canary-9f0b868-1611928476205":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9f0b868-1611928476205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9f0b868-1611928476205","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a3f65e5a494c5502894927d5610d9aaafbbb5dc7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9f0b868-1611928476205.tgz","fileCount":7,"integrity":"sha512-zVNq5qgdRJ+SwrObAG6hXiy7/TT64s8Lyhj/zaFm9Q/2uSpu6/81cV7AVkSuiPAmqStwitfGYmkHX9wok/JVrA==","signatures":[{"sig":"MEQCIHf3PcOvV1vc5JP4ZEn/nq08VeccgsDLZJSNT6ajoOu8AiAhCpa/NTsY6cWXW32rQvKwMt0WBB3urkqlURp3SL4OLA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFBPPCRA9TVsSAnZWagAA8RkP/1MV8CVXRJh2BfAixUie\nX/QBRMiGnVumGjuZkvrm55VZLcKnnZ3z9Q1XO+18QHNI9zDIctWjmw1Ng/d0\nKYeZcdRchWVNchkZCpSxomNhbge+OV08y5GY31CplVemoAatyndmR5mER4rj\ngaB/yDJ1OI4V3HfSNDRA3BeNyEtUZ29kShsR/xdJ92rX5807jsYNR0z3J/S8\nuC9mmV3oLA2CRnyBho7abSFmMPbYVTnEqDQ7jGIRPxpJTmn2VW2y9QzK1xBn\nWCAPNzQ8FVy/UW/odJRbsjlnlT+Q4QN7hjdN5cQ2PEkr0/50JRBZG0BkaSuS\nlVr4+qD7g998fOU2fZJ9vSqb4/ZSCXXiDzQkYR9jqhhGLPZv1hduM70MzD5s\npqcq8jXJyXBlkn14W5PHB1z1VEgskLk718oSa2Z86SfbKoBbueWFUEmx25FW\nqko8BaNckhmAtTuNuMTs2UzMlC+JS38ZS5dBTowKU8JgiYRapie+zxvYworm\nYeGHDPE3r23LXALz3YsPsAU7+xRfRefbeT9x/C27hp1QWLoj0JEW73JpGq+Y\nhkIDPqYo3QkLFjDem6Kg5evxWyNjT1o8SrHqjnHRHEbaDgW4dcJtcxWV8vsU\nOVam3lK+1A7dmL81dWncaMXmRmLLY+TG/NklZ0kHvDqCie72/kbMT6afJjRZ\nFLhf\r\n=zaRb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.1","ts-jest":"^26.5.0","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9f0b868-1611928476205_1611928527276_0.6602870285420277","host":"s3://npm-registry-packages"}},"1.0.0-canary-9f0b868-1611928478437":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9f0b868-1611928478437","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9f0b868-1611928478437","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"124d10cc2ae520c2239ff0964b8f80b1e8c3e365","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9f0b868-1611928478437.tgz","fileCount":7,"integrity":"sha512-rrP2xZ9T/i5GHbnIFLv6s+G0aYmJagiP38L0sauUpXX0kk9yjz920avhwdG/CNpINmy14pq7b2HgXH1DsFw7/Q==","signatures":[{"sig":"MEQCIC7hGltPLIuYFQ+7566AtWJVFj8SykHUI6N+c2ql5xqFAiA14iN0fQOEutV9282+iL3vdLJlNXOrul/G0BmOzZagtA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFBPVCRA9TVsSAnZWagAApJ8QAJecGXgVPw33imaTccXo\nPpkO590ikj6iCYXrG7k9GyEfhFEmRlE5eyKWUdc6xgD3WuTpegkVXeMPTB2D\n9c47w8iBFr9iUB7NOKGDnt0A43/pGUm2cnqL79QL7wu4+xDEr1XWDOxxHjIV\nG1PhC0NffFZX54CEE6+s2UzWpx3N4g00zhUSEehun2vuE81UlxOi+m+79tan\ncGh84LVdcU3mNTA8Px1b2lkVNXpXJnWKWdBuHYvyfxe0T6fHxQdhuLwtFiSR\nh48EtjXXu0bLu+xVDCycQzEBDO8XUhMpoVaIlTDeb5ar1rnmLA5GZ4UmHwrc\nRUT62RhI8jnLwSxonyyCK7+ctX0PVgoc+DNo5GaUdTxtm3uW0XLgRq0ry6WM\nqgt+Leibl4QkVy0GQwIP/8EX1Ry94CBc6mCwb6Yk1tZMpf4cFOYLdSpCgW10\nh1/7JQ4y7ZHC3ZlwHQSdpCRQqhkhgS1WMF/CW+nNnoPMfb/9Jfa61uM3YmKh\nqTQbFcyrhCymIz74Uo6zjDfwi4eIRuUiTK3ZDpOGgSpWtzVsgrqvMScIiow3\n7lZsh9ovFuujWku76c0iB22YFlJMStBF5UJbDL1tPaJH8atLjxgl3zoJRivD\nIAs2enVPwB5s9NbpFr6WPPwGecszsdg4xkMVu6Ae/FkJyxeMx0N/gcp913/s\nT9nF\r\n=iVnx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.1","ts-jest":"^26.5.0","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9f0b868-1611928478437_1611928533037_0.9331118255591311","host":"s3://npm-registry-packages"}},"1.0.0-canary-4a02239-1611930851108":{"name":"@iadvize-oss/store","version":"1.0.0-canary-4a02239-1611930851108","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-4a02239-1611930851108","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c8443102a992d7bddea238ef17cbe1b7f0d4fb9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-4a02239-1611930851108.tgz","fileCount":7,"integrity":"sha512-eoKtmTuWYTGm9msHzzO4R9pL0+amLttNuqODAeHFFCk5hAXgH1fPeLMFqdserPiHgPm25Ic5onNuf0IKc0EAxA==","signatures":[{"sig":"MEUCIFdcrZtbfoG2iS3RHGHBXBaeNNsfLPvDdrxh2nZFDYbfAiEA1SDWFipbQQRxNOLC9f9RqN62QTlINzzqhIoCZa1CjwQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFB0XCRA9TVsSAnZWagAAPRMP/0HrFyCmoSI4zwr2Xw0B\nPCLiUcD4ZHRDI9of6e0BH1vqqKBtcd7tSJ1+y8UU82DzHNzL9xyRAkEizKtE\nD+9xFXx3evRS03nEZGGwzdjBkRtxGuDtz301phABfSZySkOjs1+i9YkQTXvE\n34f+QsTqFd0p87anrTUpxqI24DuVd/wY+yNsmQiBKnfgeOn8vxJ/ien3Is1D\n54B+0wT1O68UZASRNGZgWuKEhXVdNBuuSf3k9IarrqxWU0wYz/cV7/mQv26p\na+oOz38krkD2JY1WtV0qvSBnL21YKX3s2WPVWlgeECbQ77TzZ9VEwdkxqG+Q\n362KKa1HnQ0Hweip0Un4wwF5MA+dX+FKIgArl4ijuopmasdrJgFpf/QlQANn\nZv2sxZBfs1B5bAcDhfbepfS+xsj/0HgcAJED+A1jbLXLGFgseCNIzv1rUt+k\ne6SMd0CwRv2T4p2TohsxdDdWu8uy4YVVFn1pYDVRmD2ysPQJUDfQc1+ZJqjL\nEcLyzaJYvwXDlxoPwfWtY5F8JEmBzfT/IDRGs6ycCM0XZQncvsF5fwvUrGm2\nCxIIBi7hTtsN0i8QEKg/sn+k4qHjunN4SrswjAhcILCV62DgpEy5wPQklOqT\nEpFR/Gme4weZ5Z8xbK75o7qamYom6/9H/I1WNVrH6OgctteI8aMEiLiuo4rh\nEW0+\r\n=NMf1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.1","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-4a02239-1611930851108_1611930903046_0.7691216040076245","host":"s3://npm-registry-packages"}},"1.0.0-canary-9a48105-1612069266512":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9a48105-1612069266512","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9a48105-1612069266512","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"482a3703f9e650e724ab1d6e6da621b36750aaf7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9a48105-1612069266512.tgz","fileCount":7,"integrity":"sha512-MQBeWN0BBA9AS9I+AF6B9yKp3vj8BqVmJdvSiW8eSPEN4dYRIm64dzf1zNGwQMdHnrRVB/u2ZnAuIgbOSE2nXg==","signatures":[{"sig":"MEUCIFsn0fMtL6evizhHqfaOmfzqxFM37K/+ZbWrbv0naqSZAiEA2lIle8YbdFlo0+2nYW0Y7+p/zzrG6mPaWveTV5ls0wQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFjnFCRA9TVsSAnZWagAA5woP/jv6cDMkUNRB2SiVZm3g\nz0MubmVIDYucY97lq86AUK9bZlu2PQPEK9sCw/LsgjghIxxFkaOGopn7l8wI\nC0xx8rh1UorJ7kx9LhZujBrDufA0gd2dQ4iAtr+G2RYUzUOzVMU2SSGVfqB/\nzfip4k56mgYkErpA67eVmEn/0Q4ab3PL10nxAfmH9QUq6IKp10VfgpYattUw\nHV6o2FqaUc2OH9ZY8rbINtq1szv6dMDcp0/GuM9g6SOg1E+l79eSmLdmuWAQ\n+CJ4OjaTQhTqGOKAqDNMNTqnC2vqWlJxXRXJM/yBLYxyn82talb13nlm9dT6\n0E5a5edouOcz24kuFlELAKpLEsLD0YiekJIuTTIcrqyNho6FbHofGT81mAjH\nk2SPASfzoHfem4NVDSnU8cs1+uF0DnDbVrc4EKRVrKiDkfav7QUFOAzpK3YH\nJxtb8hvbhSXesM36ECiQ0d814CecpeUGL4W1cOYAzSXkjQFm0v9BrqhP6+7y\n6nS5ahV3GAPyq/+s5a+wR3RcKO2p3rbBpE0Rh3MsuhFpogQAtk76jTGVW+GY\ngCAKw9PU0YVF6lTmkfS2KQmgbJPP8Bol+Qrg4RvKDr4prCrnwb2z2IA4GuoW\nEj486cq74MQQ5iGNPLkiTcr8ZhfItqw5pm3D7U3fUKK0kG9QjdUkHmPsA4c2\nwuSm\r\n=i3xE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.1","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9a48105-1612069266512_1612069316503_0.5211586256878049","host":"s3://npm-registry-packages"}},"1.0.0-canary-9a48105-1612069270179":{"name":"@iadvize-oss/store","version":"1.0.0-canary-9a48105-1612069270179","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-9a48105-1612069270179","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"030458713cbf6f23aa6953edb89e21d02fc78f0d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-9a48105-1612069270179.tgz","fileCount":7,"integrity":"sha512-3qI0Kq0xnPlM3CzpQqLQud9WNCCOqQhBnHSsc6awCU438lIiL9N2dp7LDoEyGMXnI3WhudtADQLkCOZX7kPtjA==","signatures":[{"sig":"MEUCIQDfH6saqcMN5pcUG0/6yNo2uonbcaIQI6o3cjpcHGlqNQIgFz6bJVS2qSmqxjl9T+9R05rOFIyEScR10d933fohue4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFjnMCRA9TVsSAnZWagAA6PkP/0DmyxtH/RQox2EXfZBE\nFMokOmaiakhSBH+yRxHCjkRPq5OR7tRzq2vDC+YkFBWlHWPsKIOUIS3suaPl\nDNYuTT/9taGUh7IxUvr6wycGIGCnE1pVjP30tWpVYY0ktdbev1P+BhU96Zh5\n7uZto4fwCwctR2SDeIVUvu5DLo6P8sVHBZA1F48EMU0Q4LuSA+GFtRnI388T\nSvFy7Yhxbe568p2/tEYXJhR0he1tuBjhYsI2pIwyDHkdRKJfhQp3HcJSbsEO\ngz4OMrVu17g6NgwRYJMVrWZn0AyuY42MlRyNq/WCoAIAX7iLa5aCXxUnoC2m\nxQpN/6TygWiLKvixeCkhaApv9NYoxXs9qYAZ+uWGAQfZV8QcETyc6+fL5a3y\nLliwaN22dr9Yobb7MXEZiyb3VD4X85UYQrYDSZG6F++ASejurS2PSUMuLxGu\nELqRGtYIO71mBs9endjjSxD2MgmQLJ9MkBR5e5rug/pmjdFQTwvCdZINA916\nrXt6nteozx4ySHytdiTsknlrtCfYZbNL21R/Se8r/yYSK7JcS4fvUUoS7gqV\nCF64hbf4p3bTQ5GrgSPLsICOBtA9MMg3KBgftbTOWVBc2vV2JPNFGtVQc76q\nP8VakWwuRO/lPCD3Eq9e5ocg4wt+KUTIVuU2PeGKmqXqWQxJVShLJBJUMTvW\n0Tnv\r\n=qa86\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.1","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-9a48105-1612069270179_1612069323582_0.44562870312894254","host":"s3://npm-registry-packages"}},"1.0.0-canary-5ac5dc3-1612079844964":{"name":"@iadvize-oss/store","version":"1.0.0-canary-5ac5dc3-1612079844964","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-5ac5dc3-1612079844964","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"96ea28c04a6ef0ed5674a2a743045c06d6377b5f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-5ac5dc3-1612079844964.tgz","fileCount":7,"integrity":"sha512-cfB1MfAlsvyMxi/iEUeEqXiPzSTyr1+ezlwADRe1NLlkVoZRDaVjE1ltssjE3zggH+hvsP8G4fMWxY6hRl5DEA==","signatures":[{"sig":"MEUCICso87PHaGXCMBirCbpKjUOzpK8Do/4t3PKxlkV3PUvCAiEAni9itBvn9r2b9ACZ6KYh24rT5CoeFe5pKvxfa4Kj/9w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFmMQCRA9TVsSAnZWagAAUREP/jHUlDb+1sBVAfKG/dB5\nNur+TWH7E8AYJVLXR/QLw2w4mEpdH1aCMnxrpO7P5vpZAavvE4rxy05RC0Yr\n9znqsGzssPyib6h4rB/ldcpIAvlBpUzCRTIBO6G9XYa1S3WdvGYNUXGi6M6C\nhbjCpFnm2B5a0NPqCbFMEggv1jyxnFXJIjyglDgoOH/xDZkrFUwHO4zleLuS\nSg3USKWvp3aE+6b73BSZhH6FZPe2t3z6mbrZYz7XAw+868Om4vNsi+vDS4jc\nuae6An6NatBy9KDnr0Y9Yoco8+zb5JEym3LGV+OXii63ct88Hzc91pC51uHN\nTw6jCQ1V150dnMqPa/BduMJnB2unQywCxz1lV+G5RkPmSGQnWOhMzxLoVTtK\ne4SuiBO7WRlOl6P97/iGMTjskZhpYTgOdPul6HyyBjefhfbLwUF5aUPfupb5\navg58aqPZ6A6YAsxK9prWtFCtNOkLl8oUUxPocO31t0Bj+6Tw/P4u715/3uN\nFcniE9CbkitGamjRh86YceR7tY6gafUy8PpdpVuYEl3KnFCvVygBgRHMVqE8\nR9wcvE2i1OYt58DFYV7QnAknuHadDK7XeAIpn0hYxWTYMoRR/JedP1BieMOm\nNc6gDDFq6eoh2sfbaWNgr77ALsdQhV/rAiWXQz3GPkA9J9eIfYOXhkO/20ch\n6s97\r\n=sRlw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-5ac5dc3-1612079844964_1612079888143_0.6877569797991503","host":"s3://npm-registry-packages"}},"1.0.0-canary-5ac5dc3-1612079845273":{"name":"@iadvize-oss/store","version":"1.0.0-canary-5ac5dc3-1612079845273","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-5ac5dc3-1612079845273","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d3c1f753691c0a442272cc9aae2c3235f96c7c4d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-5ac5dc3-1612079845273.tgz","fileCount":7,"integrity":"sha512-jiPDs9e7hawCTb2BOlalqLn4XNX85og8ZMOe/nEygO2E831V7Jr5Gw5wd9aLIQn50wGxuSvyvQpApLaLdcK2hQ==","signatures":[{"sig":"MEUCIQDbCwhLlD3bgsdp3cZM2u92CQT3rp+TLMcn74ZCA+kR5QIgezKmow3ece45lCdavtVcGRzyqutODY2mHWVhz2cjuXI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFmMXCRA9TVsSAnZWagAAQvQP/jSFtGwByw2oiEIbaL0s\njlBNWQX1aimFcRzFc2RIdbOYMbvgpaeYJSD4d5mHHo2Hdz9yiRUqOrgX243H\nBNlyHFSQz5cDl3iF6MEUKL7MIqkwV5ZRw8+A8XmuG8QwhHG0WXKHRgVDw9c0\nksyr5Sfx+PnecSl2dDXFYnexuNRrrJPjPBIBHBldQaZgrFnZR8V0rQIoHXXJ\ntGs0cz7qjCkf+EzXE77Uy8k868WU+oB4ZmaSeciTwZoGlLXJbxao2lBMO97F\ntKgmd7IG7A0B6NmS7wqHFKkVNdQ6C3DCjl+Z1o08XXBxR+j+Fput2EdFPeDK\nygYHWp78Cvxk6FgBtQI4kT8f4xQDWmJez5XCvoqzUpnJKK6QP4XwdRfEjO29\nvMhUXEaQN0uMEquTAbyIPxK0NjzM5XdDEILRj5I2nnduIVuvYBu53Ya9+A4s\nYzTQwU5fXYeoR+2JhtPjgDoQpl7MT4/N3f5MDrx2bmdgsf+3Of4/ZcE75soI\nnlZUlFWhGTNyXRbOedBpK213fiWuI4mf9dFFDmi53zOZ9uRYzQiqKnm8LCaD\naKsZNlfmn4qSHEiU5llZWfydhSr2CY0H6ekr4lli/z2raQFb4h7Ba4ZLIbLV\nxYfSt7VsY1XFOVTJbZe6Zo7PVEpswEKq7XMBLyS1Kx/No4t27vRMejIZMLB7\nKnk4\r\n=PV2c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.4.4","typedoc":"^0.20.19","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-5ac5dc3-1612079845273_1612079895343_0.9735811496337243","host":"s3://npm-registry-packages"}},"1.0.0-canary-c8b34bd-1612125377174":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c8b34bd-1612125377174","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c8b34bd-1612125377174","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"65d359b5ab423ec06a622f552a3c7435d6693d0a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c8b34bd-1612125377174.tgz","fileCount":7,"integrity":"sha512-UDU5hxPanEGZqw440urCNCQy0K6G3HlU2bfIIEAnWTtV0CiicRzCgwPsYjN7iWoQAK/V1lh355LWDgd3zND6ZQ==","signatures":[{"sig":"MEUCIQCwVCbOJqLqdeldVuuFI3qms+U2ZNra42HK3ao7ZeWI0AIgFe8v9uAzDSTdsWLAgOHYLIFgqfyXdsZbR41CQ3CWD9c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFxTxCRA9TVsSAnZWagAANGQP/2/P+TLpMH/8CaKFj8WY\noEeS9qVojM12XlVnqAp4trIh2rrAfBfgPmymVkpK4zpBkP7LV97ltgx0WdTu\nEm4GU3GN5kV/5fl4afLkweiTNXFO+sBAoEygQD6/znMweiKiByElwgFRdLhl\nhH07grOVq2nV5wEw98mwP5Rjd8wkrqCbXg8SotwLHATrK+1Va/Bw+6cyidzM\nh3YoPWqB83Efo6Ni8SD4XhISoUB5UqDZs2mOAzBAgOHWSRRRrhyk3kTWWAd2\nlTPGzz6FpJHJheU+T2/HkYdAoBs2Ji/HlEuCz7aJm4Jsq/ywuZmbu3yLg6Kd\nZMYqMUZipg5mnXWfdLw/can0yYi1AtLCwONJoJW6AGLltMcegZcWVa9PMtWF\nXHopc9YAxQfmYoFZHvgEDxtNWqYt+Mr8ZpmnXaRy99ppkTjlHxPTJshC5g2B\n1kmulu5CxYKW7fZUd6qkHqznnPpMX+lUyrMw0Q2iXK5Ls3xgotizMwTllLQw\nfe4esAvpF6xA6lyFDIUK8DSSxz3yRYI9KqBoZKibj24SDJJq0+J/u+NQgVAc\nrSPR4KBzjd+oe7bpJCa6BHdr4dZ91KYgtQJPj7/oDj956gl50IqfWlxNiQiM\nG+xpidyEAdt53WhkmORKsiliS5tMDhkrvBqVOXja0aTcVR7chD/EzHCIPdII\n06Ft\r\n=sLBx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.4.4","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c8b34bd-1612125377174_1612125425026_0.686629260163943","host":"s3://npm-registry-packages"}},"1.0.0-canary-c8b34bd-1612125375058":{"name":"@iadvize-oss/store","version":"1.0.0-canary-c8b34bd-1612125375058","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-c8b34bd-1612125375058","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"63d642398668022b82ab8ebef14497ee2233fe30","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-c8b34bd-1612125375058.tgz","fileCount":7,"integrity":"sha512-XijBR4++Vvy7gflrJ23VcM8A7rZ/csMi6qSgarv0oTmJPcQm62sHVU6NqKmfSy7ZZd718++P8iEyJbtDOdv2BQ==","signatures":[{"sig":"MEUCIG1FjCeaP5ZzXfAO5H2/3WA8Lr7OtoPOZNvD+mpXb+GxAiEA70LVizYbtrXNOxNLj+GBARykXlkGd6mA2WP/GumSvs0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFxT7CRA9TVsSAnZWagAAvUYQAJN45g9mdsqkTTMTFaQT\n/gy9SdV9p7UbPh39HP5w5PkdVIkI64GwNA8/mH6QWQdamJ9y8bnqOCBi4toZ\nlMuGoq+wFjF39dqbXvYp9ahsfwgODX+x+XuT9Q2VS8MorjxFBZoYQMIsoWZK\n/9qF63sI/AeAfJ/Uafqm5PpwEHgXUcWLe4ZdlH7iRk7mBzKB177rVVT13SaE\nlUyITXvIPiGfHY9kJSkfJC2cwgpA6Z0mknlDjWTWpjsDN0rhvirTsOPqGkEr\nAb9y0iOMIdm1RQ/ajV+RLejXbcHzpADGUvMUg3nS/Nno5dyn2yweZoBG+Avg\nhoJAbPL3CMiYgsPjWyTU5z98kom6bMzYojmFKmpp+7UIwl3fJCexBVWwPCSe\n3k1+57WpWHkpnBapdeDnijGsft5GecVU2gEJmTq6nOfYRqYBMgXUIqAYCtMN\nllbjTHe0IRNogvFB0HrQpm6ZipNWLmAcYFHuENOfv2cgvcmlXC94EVCbtE4o\nfu7JQ1QM9Ww6zeXrDYrwPMSme1VDlc91e1wymRN+QeuH+eQJafc+RAWovkYP\nKyW1j4EBbtLhwYWUDDepwcHOXo5GK1n8BmV+ot67qWZObgbZtDXDt2xm404I\n5mGD0PyezFjn1U/luiTSf1tZlI1jgN4m0BVE4GWJCuU4n13iRtCE63DS4Fae\npHes\r\n=Ajjs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.4.4","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-c8b34bd-1612125375058_1612125435028_0.911459084254675","host":"s3://npm-registry-packages"}},"1.0.0-canary-15c5be1-1612171126259":{"name":"@iadvize-oss/store","version":"1.0.0-canary-15c5be1-1612171126259","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-15c5be1-1612171126259","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9c12b77a83a57938ddcfb29e1cd82bb4b5f4f509","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-15c5be1-1612171126259.tgz","fileCount":7,"integrity":"sha512-qgQX9FBSCVrKdHj2cqNHqF4lM/3jvO+nl+i+t90QKgV3K+tTjQFS8RndHsbnCn3L3Rq22lNrnnS5L9HQjQE4uQ==","signatures":[{"sig":"MEYCIQDLiZ9AZ+CGGp7WkF74pC+Az6EbPLGNM9+rJw64a5cZ+gIhAIvksEQTn/uKCMVbuTyAklCOJ5WIrU+IkOxXT2fne+3I","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgF8exCRA9TVsSAnZWagAA5asQAJCj0Y4ldwsYwHTwLrwt\n7L2iGQquCy4j4sZUyYP58U1c6Y3ojNLqyANiuYvjssmOzw/EzaWEbcnszEuC\n9N1TNAZFbe8RJmro+q5zNSzUHTtq+dZK9pObNSGoxLBoK5+U7/+/YftSCPri\nRBkRDd4Z6+ae9BM+lVdssZMLzdyfxFnqOq/I6b+MCnHgKkDl02ZYHCYH7X8e\nmZCr7q80trYcT0Hz3Skxc/nmkkGbn+n09dhKc3lU5rxhual9W8aixzN4xZsZ\nq44zny394mrhC5fLV4aRSDJsE0tIfmIfa5Qf0XgIb9b/AgwI27OrFuw3nhx0\n7F5LyoWTYXcJOSEWZ+t/OhEYKxIH1KTR9yBYVef2wiUZo3RbeeFoy4SRXlHD\nHnR/HixGOY5RWmckn9519b7OwDnaKKvrMx1GBMddxyBfRqgOef79qJ9eh+AK\nAhSJXueceGpyiUHzo6bWUQS2UoAd9Dn/CsT2crPM7wxo9dNa3dyw0zIrJT6k\nZEMypf6BHP70h+NFsKbnI0PXpDVLWdiwhb0GAyVQcCUA+xvsUxhfBpK+Dqdc\nkahpe/E6vhzMhZA/lidEyLweChrYUTWtJQovvfwMzWG6KXxqfMn3HqaETidq\nS/CLQzz1lh01kQtigQbZ+Z59YSGiU1mlpSlakNHtLGzV05RPGz3xUUDLg/+h\nC6SZ\r\n=/10u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-15c5be1-1612171126259_1612171185437_0.9591955454588548","host":"s3://npm-registry-packages"}},"1.0.0-canary-72faca4-1612178121674":{"name":"@iadvize-oss/store","version":"1.0.0-canary-72faca4-1612178121674","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-72faca4-1612178121674","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7396f45535e80726b60c4218ad31bbe9a37946b2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-72faca4-1612178121674.tgz","fileCount":7,"integrity":"sha512-Q54DxRlpPTgAjHBbJjI9BiuXsOZU2vZavrly4Ng5siiQAH4TCLmNUuxBe7APWSyLNSvvaSEfleyyfLJojs3ONw==","signatures":[{"sig":"MEUCIQCBzrXzzc6dFiGC1kxGeiLBdg8VXOACZGRdqffiSCnTkQIgK5/BiGTymjuXkcpawbEjD8O2qnU5wOL3kWSS4v7qixA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgF+L8CRA9TVsSAnZWagAAkEAP/j/VxqtO3QDZaMSz1+4u\n3oVnSF911rA/35CNhzyWoMUY4Zn3GAPan2/CGcWOsrCX2XfTceIieXDM+5QN\njzHFFG2dZJ+u6LadBCvi8F125fDDG+jSmyiycEkLkYyJCAzeramGU8FM72xa\nVH+aQ2Omx1e5oVrtDxG5s2Jkrk8EuwPGsSMdyPaWZ957ABAyYr8cZlP3AKHy\nllfGDdsR5qqKPgTEa3uXJzkio3wq3BVSkBlRSZKbh2mpTLXzZdP5ll/lwiBL\nErDtWOb2hLcxIN75mqHUB9iGjUBxOewmcuna91r3pAMiS6urq+iqcLv0pztn\nG2sc5Pfifq3p4z5myMq2fS4CaAWM5zLbrGSebGASru88EUbogU7ayZ1/CvSG\n9bh8jYV2RUggIlnxqEYOWXnh4oaDXakL8dvhPA89adtXXeCv1o3XxlmMb7vb\ngfEbaUwt/bU/WmkBjecITc8Hhl0a+whBCrgTClZh+XOgWN6RLMXNYdKoqQRd\nuuyHg4aIdVDVl/8IBdMbHz8bivvbqwwrutBmdJDeor2zbKZUyCC6kuWpEY6d\nyJxvHfKI54UTXD+Dm5GEyU7GPYxRAhDFYN/K7iWr79Fol3485zHcA/qmGWJd\nNVau8XSkIYax+yXc6fkAQk+w5nJUn1sbtwXdx0E5I4Rptbc2LLvXR+51HWxS\nRdsu\r\n=eUwv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.3","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-72faca4-1612178121674_1612178171637_0.9188222809696616","host":"s3://npm-registry-packages"}},"1.0.0-canary-58a302d-1612221376598":{"name":"@iadvize-oss/store","version":"1.0.0-canary-58a302d-1612221376598","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-58a302d-1612221376598","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3360bf03b2ce960b9a30ec7c860aeb91dded5672","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-58a302d-1612221376598.tgz","fileCount":7,"integrity":"sha512-poNPLZ2KIr+sNgvtJwQUGXsogbOW88FcAQxM/s1q3m7mvilHQDJH1NRVjY4HJ5xykq36GXV7ydag9wNlk6I1pw==","signatures":[{"sig":"MEUCIDH16vvsNrawzk5ESwFRfU18L5i12SWldAhhxvxyWn0SAiEAsfbYIchjHl1JpEeZ1xUJLfGCJavglIq7nFDk+faZ4IE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGIvyCRA9TVsSAnZWagAA5/8P/0OjmKvGJnX61G31MRlr\nE6jOJ6wlu5TMfr4ArS2Lt0TYBoglVzt2f+kRDOeOsEoTQsjxzdoNRS6g34Go\nat1cBPkGL2A7b4Av1aaDcW1opmf0UtHqAcaOZHW0yXTPfIwnCMIdBWEfMNCv\ni7IFWekLhDANGlf2jS6vQy+mkldFTz0X2i/30NbkKYdJy3cI+eMS1du0ueGD\ncchd7Uflhi+t7JwermJzqbTtjAf4x5JDe4FtBd4Ub6/kBTZwV+1KJZEOMhJi\nKdv3uVn9P2L86ujFTEkMd1/rSVtUlwp9OD7YX8k7+iSdgC2qrNkl6vva9zIc\nBd9ERs1ILL2yGTc5Q2b4knQMXwHMiygBIzanBvRuFPD+klCJdAMlKCOY07nt\n7VSyTuwC3vP/LgCLwep90sX9UGBFXOO8QOxGvvCIs2l2+ueVnCObdM88s355\nJ5Vp7u+5i701W+X2HUE2LTqIZF6awE+o7ZwIio1HF0d9NSLaCC3J9o17a9Fa\nCkZ4oh9yYU6spNTQoTPSs2etFeSkrcieOgpwPQq2dHwTEyjHU/u4tV3D+8pi\nT3bdLZeW50rhazzW6Y+vEzh/xX7kXYniHebZDl0xQM6sGAhdeQfEfvvkT9KY\nG9SjLcB4Pnp5QtXWok094C30NBTeamPBE/UvvHRwMMMHIOigTN3L1LMtdQa7\nZiyK\r\n=rrUP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.3","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-58a302d-1612221376598_1612221425513_0.6047612774715294","host":"s3://npm-registry-packages"}},"1.0.0-canary-7bd79dc-1612254583379":{"name":"@iadvize-oss/store","version":"1.0.0-canary-7bd79dc-1612254583379","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-7bd79dc-1612254583379","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9dd82e50394abfadb00d0226fa27b4670aff6977","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-7bd79dc-1612254583379.tgz","fileCount":7,"integrity":"sha512-Vo+q1hTZ60DvtY+bkB41RKCX14TjvYNh6eoOVD1Sy7zieozJbjXLicYT6m9KrcZDtsOC0haOjrzOzB9UQvOp3A==","signatures":[{"sig":"MEQCIBK9834FQ3GTUHUz7E+PYuC9JYIcmiuJyTXj4X4wAydKAiAYpwc64sE4kA/mf2GfUMe7Gr8A+g8StzYZrwFPS3RxSA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGQ2oCRA9TVsSAnZWagAARgYP+wTMjDPzxp4ndm8S4SDa\nzthMBYprXrbp+yysYcgegHd7A808GAjFcaVtjOULZEJnMz8LkdOfF71U9I8W\n/cTNKXd1gZsXPITrv2ZtahqykkeCpis0+0zmpx5oIr0jfmZzheJVG+PAPgKs\nyaJsIQy5JYQM4EFG6iwFR+wCciCXJUmCis/qZsVdWMWADDgcg6caOWPSgvol\n4U+li8WfK8heblf9OsmbnDj2sQxUT9AmWunYWQDfwIad8NnogJokRK1cmYLR\ndbFLWgeHqrqX1OvAVrjGkgV4Cx37iUq3LAttluqi0H8nXmxzbkbePuuzT+yF\nczJTcOBAatSVIJhIxXx6D4XSzRMltxEKaw27NjCpofmT1BjvKBfgidn+49rv\nRVGvafTGDz6JH4CHAcvBuPyMB5Mnw0oqtHSkFBLz3k49NLfM6zthaO7rmaaS\nKbUrhTZJr7kR/RbnmJetBhsVdwWF//rex6bXNCvYeo1Yqz1574e2DWasw/fJ\nJEpqielatfY0iBSgxQBYFw7jnrQMN4fAnbiukSJHKl4KIAw8uMfdJIKZjCvn\nFirCoiEuArgHna7LyAmAhStNEVens7XpVxXTGLaGYSAq+bOQVLTSj86pZQHv\ny2zkMG3dBAFss3j1OGrua2x91DAvYCdp3mtWzMW/yIfsBXjuEuc+iKR9r9Th\n6RpL\r\n=EpiR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.4","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-7bd79dc-1612254583379_1612254631708_0.6808564683373628","host":"s3://npm-registry-packages"}},"1.0.0-canary-0caef8f-1612271125996":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0caef8f-1612271125996","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0caef8f-1612271125996","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"63c70fb59c19c494e3bd27efdf6e6222a07bb6ef","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0caef8f-1612271125996.tgz","fileCount":7,"integrity":"sha512-cl/kbmnA93hvcfmgOeFu/VYOIfzkhrHP6SU+C070Zl9g6xJhtGiAhVwDyArIvfSQf4wVpIKa57Lg6youv0IxeQ==","signatures":[{"sig":"MEUCIQC6bbN/RNcJifgvQeTg24wZ6b/oRkfuaNu7nZY6LATABAIgZaYv1+5AhheyUga6jvVUy9O/TfdxzHGVdQTWfRhlr/8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGU5ICRA9TVsSAnZWagAAWAUP+gK6hIZzUZ1/EWAk1OCS\ncJYS23sh26EZxdJPRBc0JLCKfkCW6GT9WSGWY+L6meB3pt9mSqe56Z+qQEMi\nnRyUguYssEG1dq8wDHtaISnZGO0jcaxcX6ZixsOHTrQdM3g4ze7ousdDXfc8\nphHEDJZJO6OYILVTSb7QvOxLx9NbYjmLuRDbfNe/SnAWt962xzvFNYuoT+nq\n64+kjUNmtOFuChWvdHojG44hy74d+LQ1HVCy4NRQxFTgYvLUH0OoCjOJ0aX/\ngpgYsajbz9QqpOxXQ1AugmiNn7q3GBE5D27JcU6r7rflVxMFZGyg1UNkAOV0\nBr3CcjtKLo4WKmuZpr3yix65PO30ThGJuNyBV+9+unFa8/PS90DtCWHG5c3m\n8uQEqWQMMpzsEVc2WN4p8WPUSa5zjsl7Zeivn8et5lzA1v8BJ53/D4sMacET\nQvTaiSshYT4HSb5jBhuRGu9qBqCTavRji7x9O8wM2PeZbYlnxnpnOezikULk\nt9/ZAXk0HP86ESWaUOcQTWeEcXFG8qmmqU/Rul3oHHK6sG7a6OKphmCe966s\noIA6urjEAsJ+0n1b298qt31LbFFO4DmJ4g1o/KSSTdqzWXSGUGtuJZgYX4Yb\nXzeZ7jMUjGMJ3hkbcXL59aclg2qyCLoI11eoG40rZ5FpIK21oPYpK098QkHl\nMwqt\r\n=Ok0x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.3","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0caef8f-1612271125996_1612271176309_0.025845748692158388","host":"s3://npm-registry-packages"}},"1.0.0-canary-15f8d3b-1612281582369":{"name":"@iadvize-oss/store","version":"1.0.0-canary-15f8d3b-1612281582369","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-15f8d3b-1612281582369","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7de33f3367cbb04470b7700bd615465cfd9a1a2a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-15f8d3b-1612281582369.tgz","fileCount":7,"integrity":"sha512-3P89TRvAPmjueFpQBztVFb4ii20WI4H64okqYvEd+4IKknFy3OD+rFDt8sobMJl8+YsKnYIHA3COc8NRAjSIog==","signatures":[{"sig":"MEQCIDJTnhX+4Kz0e7TUKPr8FdOKrx0nmL3DRDRPJCCD6dAXAiBmYehpMvugZKOZMeh7fTUBC3epv027rsEpKsblTUJcHQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGXcoCRA9TVsSAnZWagAA+iMP+wQ6H6QMm37C1MnSeAoj\nKYmIveijYmeliEstA0w2v8363Vhlsw/b+HvSsKfKEJk7wkPi/YdAb1TzQtth\niA7+E6CTOqA9lIbF37KGELEUi3Jl0YiZ/cwsPc1Ndc2mB4XMoxtYZ2wUX/1J\neg/0j+AIZiGKjG8THEfXuvj5r/J61nagfr3qtL/9F4iARVRrFm9akwWKQmFL\n1fI/v+uFEHzqiKe5bn0MfyRCeKqVYpZF+1XCsa7PhUBaZVCIBGFxZEFWioXg\n5nzG9z34jXSv3qqQG27i4eThI9VNyyjYfE5KsOUwjzgPQeMOCgYF3t4T5mR8\n1lDb0rk6eYYhQ9q9ldhjUXqceuF0O0nGJx83Yuy1SwWNfDbjPxAeqhpHLji/\n10AX8dpgK/m8OMLkJsxkq4oPYqRLagQ08LFnDi0ODV6LrRSQAjtn411Ie+BR\nyYMfBXHp9U8R6gRe/NSBTjyKMvIzwpwx+E/Og5IlL/0RnXC9eurjqBE+b8Ba\n8+svHRYupqMJOqamvDs0yAqoj25Ze26ofsP4GxqP76tesKkl8Hffz3+e7NvO\nNiCDthvf0kpBl3icu5X4nW8y0JkaLxZ1pH4xKsGeYxnIUNc2L87brL30BDSI\n32RsxthHt244cToAm23Ij4AtTmZZU0j78MmzFbWp01Zs1A8ifC3/oxgS6ETQ\n5CPm\r\n=szEI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.4","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-15f8d3b-1612281582369_1612281640064_0.9431623347887506","host":"s3://npm-registry-packages"}},"1.0.0-canary-92374fa-1612514189682":{"name":"@iadvize-oss/store","version":"1.0.0-canary-92374fa-1612514189682","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-92374fa-1612514189682","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6ef36edf04cf088719f9058d6afa345870d11e55","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-92374fa-1612514189682.tgz","fileCount":7,"integrity":"sha512-YPXTSyIR/7oh66PVi8L0SthGp0iTscj4Evzf9xOS6zy5eshJl2emxJK02fF4RgrUtVUzFeYAdWlZjunDnktZSg==","signatures":[{"sig":"MEQCIGKJ3w4CR5W0XM6YjEmUapx8qNLNDWlVFc5GIz4o0Y6lAiBhwOP2BQhF9qIdI4C5MpvwUIARiLKI8AMsSO6gUKNDzA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHQPECRA9TVsSAnZWagAAi2IP+wbyX21BdDZT9xGTN91F\nuuzM+LxtjZ2lSESP7mD4EnJeKL+DYNbAVO6yI2r5vYonqASoMD4u58xiwSvf\nyTgM4BpnA3fhycc3bjrlS1QG/ybAD0mXPojNJTVhVbWV5fqOkL0d4tcHcg60\nFIW9764GV6HwmSaeMIemUSDdQ+srhCZT1BcGOc3b42A/ZO9hQtld7auwXSXA\nb/FdLc4qXiXVlG/b7Uv5SV3nJujorvS1gBk860cDTAJr/1EgEDsL9YB2J3m4\nJ3EsbtYOLduh+7tJrLFpwLw9beuH98Q6fKBHQJOEfo2IXYn4tMIEHKJ0ak6v\nFFivIsqaTyrkKjUOrTwg5deiBMeOvp12Dwt+RFGHRxkI0iikusz/Mbtfc1Ot\nefMxeP+G9GI8RTo7HBV7X+RV3CQ3iyl7tnqf07aRaXmmlKXeOzy0Ez+IijG4\nuNU3PeXKcqpNxqWJalTve2+nGGgYqbS3CchrSBSoKFKO8bCDT4emom/Kexi8\nLPvGoUMwbohm3uD8d1BnZvUhhVvXhOGsg7xNnrQV2Av4HqPHu2for9aPdNv3\nmxz3+4HG7TLLDK3yCPG3s0ADuoJfNUa9U85wrFSVBwB56avU6JOblMZ7w3Q4\nZsTyaitxu++xYAjO+jJDFLqkOSfOg2RK1GOlRUn8S0rN/+yrQ1VOQFziCq9i\nQyhw\r\n=5S53\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-92374fa-1612514189682_1612514244169_0.7366097420942821","host":"s3://npm-registry-packages"}},"1.0.0-canary-1313a5d-1612531250097":{"name":"@iadvize-oss/store","version":"1.0.0-canary-1313a5d-1612531250097","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-1313a5d-1612531250097","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"91dde981360be75ea37c63330df1d369f104ad78","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-1313a5d-1612531250097.tgz","fileCount":7,"integrity":"sha512-aXGwECzZVS2Mdhu/uqisfddCVxId1Wu4uc5yeolFufL2+SGS2OsTEJMeIGK/1opNldhCf75LeLKdDBhZMEjAoQ==","signatures":[{"sig":"MEQCIH/GUPxAGNAz8pRuJ9+OO/V/TnPO9KA8SrV4oG6QVXf+AiAHCJ8RZJhFLjWJ7iNBtTK4qhw9V4buC0hOfwsywjS62w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHUZiCRA9TVsSAnZWagAAu1sP/0iAyPMUERCnTu/YT8iz\nwMUbtZQC+YGe0U4ZxYD8+rb+RuPRNujQ9pZF2qLowX5ayx5Wy2xzgbi9IG0u\n0ona6FTLcHu2cDuxRrbheFuM0zfHUjjgF+fpI1mJSQzBpuQ5ovwnHiAgZqnb\nKWEH4WJM7ZeCX3hi3dkyZcj+2oeX4jYn6v1d+Pl/YrcU4XhFqSCZJCgCp8q6\nyln3T1ZfqCQ5MOhJ7Bpeu/hpnaEAxBnJkZsPGBdrCsRhbPdeCKuy6BE94ynn\nI7in6vF6QqHM2ff4Du7u6FkPTFLTBy9XQ6oSpnjGLONSMXNAlew1Nd62swe1\nFwh/TC4BV1ylTXvDhF/AeBZrbZXz10k5q/hMyNmM87CCwe4LBOf59XkK+I1q\n7U1fNr46v6bCZP3spz4HTB0LPI1c8h2szGCgu5HjiiPjz1e+0PD3/+EpXKCY\nmqZof+N+2G0XyGj4hMmaVoYmCmMXnVRSz6sDRz4XeXtLiF1gVAq4Og3JjWlo\nCYUuX5kdNcc0bZv7ezjFII5juJ+BMEUiryrCmJVn3xBOsb4DHEX1Ij27otef\n0lqkxIG4p8RTM5twRmLOkiYPWbIZZ/YXDykC0WZ/5dIMgG9579cyM00X2f5t\nrtgHiAN9PzKrEviJpT3lZNG5NmOCGavPLeas/nNGkWL2MzPJJ08g+XM/ba//\nuJgx\r\n=APgH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-1313a5d-1612531250097_1612531298105_0.021968596255491413","host":"s3://npm-registry-packages"}},"1.0.0-canary-a3b401a-1612548394970":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a3b401a-1612548394970","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a3b401a-1612548394970","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fe476187f8d0bab413cee5409900a2017161e67e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a3b401a-1612548394970.tgz","fileCount":7,"integrity":"sha512-u3i5+AUtNa9J3GJzq+X1GAs0s92xeYhiTPmMQ1m9dcfqr0FWkXH9sa/IyLCUoomNrYsPkrfyCmED1+GfD377tw==","signatures":[{"sig":"MEQCIH2Fp9u4H6oxVJqP1a2Ng7m9XJaO35IzLaEoaGNUr++mAiAlB53iSqV1Z2gUeODK3DMfboqidpjKH4KYzQpZlMqjDg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHYldCRA9TVsSAnZWagAAThQP/3sfZMsu2swnRDgMAoCx\nUgFBbUaNXxp5mPGtXmeWy4sx6sLt/8dZsva7axWWFBW1gIHzzESerpLo87PE\nciO73h6GYLFur23Y8UD1Gbf3yBOGOHVh4VK0ZlrcbngsOsGo84O5hr/vK+K5\n2l5PqlVAZ/Ljk+CsmsG7ErHPW1JQTHIbZQr0M9OKNPK/CIGQ+PqQ8XTXE93y\nXnhdpT5rn+nJFI6Z3jdTyufsQHdqRPDoY4g7PzM+DXjLN2IQxAHAhEtbrV86\nUCWZJf38W/hmXR37NMPkKl7/Q7l6mNT2b/5c4ZOzf/xDH8bY19s4skZfbLsF\nN4ynjgUzawYwXVDggPi3+9T1MVwdOU4zQ0s8GnYn1tIz/HF8ze/UpKVJlmJt\n0iVYDKWsiHIgrpoQGCqifTr6VJU/jENeRJnV+BD+15QR03zbef0p0JuPOU+D\nl6wqK9GHMyvEXYpLbNFKecHdjuQUPNC7X4OhQggoUHWE1ucL9jj3624+bTat\n9I3qbl3QpC9JXgUNZw83wvCG5Z0sOX76qrUv2Ww73vhqFZJMZEILPfg2k+Co\nMFOW3Yjm8pq6pXBWIL+wyA9U0pAE1OmDGb324UsnxOXMRDHddnXCNfIc3rhe\nxpIE1jCos2Duiyji5W0QQCwWABxdJ2QrROe9cY+iuUpdC5hujna+6K5HVePM\n3tzw\r\n=Nfla\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.21","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a3b401a-1612548394970_1612548445454_0.9991153889612676","host":"s3://npm-registry-packages"}},"1.0.0-canary-a3b401a-1612548395102":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a3b401a-1612548395102","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a3b401a-1612548395102","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e038487ab0775bf9a8a33d7c67df65b86ca12bd6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a3b401a-1612548395102.tgz","fileCount":7,"integrity":"sha512-8OXjsAH+X6uLAGnuekgxEIPScKrHEgs2U2TtIlLxKoPktd7CtcKCB7uu5oGBGstwmp4VQqvsBrzVixkPX8c1UQ==","signatures":[{"sig":"MEYCIQCBfhgdaOLeZ6wgyRc8lGxkLTrZ+E97qor9r2k3UqH4twIhAIWuqzfYrbOLq2I3lckhj9DUteHUDN7/mAm8RAGvibdu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHYloCRA9TVsSAnZWagAAgVQP+gPNQM7gp8At4nIuL1wA\nC0yDyjzyKSLs9CfwQEJICwdRukksB0te7gSau719ys7OjNA3PfIHnJugENof\ndPMxXawRqvZD0JQlZYdJhnv0QmD0wucBptt+6ALrVOLEUK121pFWK5LBLxvY\nHI4aGeRp7tIiCHYgzLcVYnRqpMX6ZEpuhcH20WcuibZLmO2nwYKgoGRY4GLd\nNdcDntvOzOarg1/EdVG4onTxsOSuvvtPPX+HW+mipkRHVr+RQq6sskAFp90t\nrvK08MP7w5HrSC0uPEEOcK1bWZAVsOAhAGWRLBgDjS5MIqCvSd3q9qs5P77R\nJZz/SaMdpbj5DGR3tyziHCh1GIJURxprNpTK+dwIuXNmnAhZcUWimSn1+VeU\nDMVdDZ94zbuQQuyQHhj0a6DFcLkBSlT+HbMom9jMM7D0Dncf0VH4Su08dcvW\nv3E3RerTKkTHi8+pyCM8uNDv2YqyHvlepXgyShejN19D8Zwz7zhhcNKd5w86\nNo25YKP9H2UQ1GihpCLDd72em2oi99HUDM2chUJNKYQ2tQi2S0TCfEcU+W+h\nTDHkDomH5TmLMLGx/1eF9p55oyEykfF8tDk3jN+gGSEukZeAYC7fIz2V2dye\n1dq8feY2xgD6hd49KPQkN0tQL7wcY8uqyHnFuHJSavkSiB+8LlLEc4LO5AkX\n/oZt\r\n=/TQl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.21","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a3b401a-1612548395102_1612548455609_0.12547757067224197","host":"s3://npm-registry-packages"}},"1.0.0-canary-f427017-1612628821731":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f427017-1612628821731","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f427017-1612628821731","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5dee79f3873e408440dfbbd0e72c27fbead3fe68","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f427017-1612628821731.tgz","fileCount":7,"integrity":"sha512-gNX/s090wWVc3EGBiN/RHtOva1FmsjR1wYzSVYcUP8hrvLY5gBSdCs8vs/B+xU86tv0lCnDjNQHo0zuNXmK/FQ==","signatures":[{"sig":"MEQCIFfT/HOHdG4eENw6cBHJYLwJDO4tQYL+BpCdOO0aoYsHAiB8BvE431idPa320i/sXR3NA7XhqF/28LIfVx991vUuAQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHsOHCRA9TVsSAnZWagAAg2QP/iKaLsgUUJRux5Prbnj6\nyWCz2h2J7Slt+ryi+OuHImF55wiL/AQNZ1gB6ArNwatbvuMzSp7KqbqAj7Z6\nX9oBf30Ot/wbakxZlMeJF3wEwb82bivZ6W6aaADulD0VQbtSWBRtlNwEXkyU\nbEfNL72Vb1oCYdbaI3yGxHitE9j6HKkIfbYiel2Z1gqS3HOUjkvOi2dfyhAP\nkbwREYjURZaOU1ukouaWX7KhksJG+YOpQnhCeG42s2r6TWWJCuFYH1UZb8yr\nahZBKXJP/ZLFdwcQr31dWCjeOP3J8Z2vmi8fl0yaSFk0mG6OwlFUgo5SL9hu\nwgyTxwgEBauXGdk5IIGHKP9Jf9hs4r6XsZL0jHqgYMZG4Lla4krzacEYIeUJ\nPibIbPpZTTPA3mQ0HwkmQp7c3ePiuj6XHmtJccA2FLvwjPI5jHNKa63NVam3\nOdo1yYOnNjkus9fzyfCWSvp7k83yh+6QbjXmuzTaMasaFXo7PtcWMD3FiCkY\nfbI5gFqI40fznDFaKHrVgrFRJIXzK4vFu3Yse6c0liVldxH5DiDeJW7cU2So\nkuOeeqhoF7N/BLEWuv7C2Nj0s0oz2g5bRlT0aykwprN4iPfLhJmfC2WDQEkX\nBH7QKw8VWlLeA7+8QOgcws104k07JI5KJPXL6hepZk4+7RAA6LE5j+96knA0\nSJvU\r\n=kw0t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.22","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f427017-1612628821731_1612628870500_0.7325980411719815","host":"s3://npm-registry-packages"}},"1.0.0-canary-f427017-1612628824209":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f427017-1612628824209","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f427017-1612628824209","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3a245b6fabfc5ece25c28c57d317f0e352615d52","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f427017-1612628824209.tgz","fileCount":7,"integrity":"sha512-UX9/2MdhkooFAqI2B1sEeVLOVNI3A1w7uhis3zFqmcpEVHuYTNweO4SiEr2tgucwSHRHhyPi6cLDZ1FumRpmJw==","signatures":[{"sig":"MEUCIH4tRMt9gjUdvkhnnuLgvB/w7IGUKgUwToJ0XdMZDMiuAiEA5KEikBchx3DckUdLkUdbgCu54JcWgaewQLPhH1Qce88=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHsONCRA9TVsSAnZWagAAJvEP/RRNShBT1FlQ40yEBWas\nKnoYfSN4Z+lctZ3hXbj83MREKVuy63PuZ6mGb+3fS8j31HwJn4A8FRHuHLg6\nrpwOLo9XqyrdVktp2D/bVbqhoWKFVt5ckUe0wkWpTrSYTfUt3aOSqcFxEG0Y\nJuAOhz8m37XBTJw9wHDcL3/AdFI/Cpsli3wKr4T67iKHN+s2+5Phfz+Na4gy\nR3WslIiHlzc1eEPF2GbF4hd4mHhJFRtAm4EESUDtDGVwJB5yQUO0SrB6pVLV\n1fXzp59PEyJjrNKUqbXy1KXpn5ZiDD2VmFpcljVvdKK8ZSkjcsAU2R6Qy91R\nowGTpJ1HZpy9yigBCnilML3bOblwxa9Ro2MXwh8g8SoH6OLEXYqAVgjxyUE1\nQa47eqiqzXOgnkOrOWs1z1v1Yt0dqkidIyQXw9AUF1RZI3tlPwosqjDCmFFZ\nJOBwGaWAr7yDW5hznokiX04jBu8QBy69Bt1iyIRNN+IzC0FkI3lmzkvyjiUd\nVjcGR/9MLl8mjWpppNpxE3ymoUw7eBsI3jxF6EiYX5olmCuLvPAQJFLGxRS5\nHNOAHkvYaWmgSk4lm0GqYc9Y9s+3/kmrATz30TWDAKzhcdO4gOJDtpnHv4d2\niXA1dlAohlG6OLg8cy5EGPXGnxVAmAOllhoarCEfPL1QnSaQwOIFQMZXjsM4\nJRD0\r\n=pQN4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.22","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f427017-1612628824209_1612628876628_0.6895069277167163","host":"s3://npm-registry-packages"}},"1.0.0-canary-56ed5bd-1612652117025":{"name":"@iadvize-oss/store","version":"1.0.0-canary-56ed5bd-1612652117025","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-56ed5bd-1612652117025","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"79c63c58e50ae61f4e1e74134baf3af0c02fc6d5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-56ed5bd-1612652117025.tgz","fileCount":7,"integrity":"sha512-NChwVmZnO44lGUtioQMv6LI7xICpiERhlYrlVt2uzKVz+UM3DshYokmPrtiDa1S9YUV4S5BSBGZ/YOugvfqaZA==","signatures":[{"sig":"MEQCIHma2JdTMUNXH2OKgCMQdf46En0jlUsh6USzh4d6+TYCAiAgvLt5w/B73Hq0h934FowJqJDJjtOOsrXpkjrbzp7ZQQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHx6JCRA9TVsSAnZWagAAjCUQAJkSSV1XnmBNrdGrp2Hf\ncpOMsE8H1kCV9P9Dc/heEsym/2Emh2kpUTi4XusFNDSreG9CAr9Nnoi8r6ex\nshTL7Zuel/4WA87FQGmx89aE97M8KS11POGIukQd2si52m5naeNFRknDl8YZ\nE/V4JAQ/mP2YUbgo14c2cF/HaH42rgcsoFZ11iWYN5GEcmhdddK7qAWfs2iG\n9w/tKJnvpOHbCKM9pBDsG35YzwwzqVTeMmGS37uwiJzG5HOgnQMQKshbOOsW\nopgXvRyoTWDWVjtHUeySMnxLVFSI477w+bZpQfIvUT4u4MuK64/Fvw81DVzh\nNK2OrQok4OJB2usigC4nEViNMXFTaeeuVXa9VP5kUDtiYq8zQjRA9xrhDLwG\nyZAdzJlDdEQ0tar++MjThtrQG7fjhMiPcPbw1K8c/4zADtlMe2xAne9q1pO2\nD9WvUmtxElOpZsHJ3ImcCV1OrIIsJbOea44C2jON8VpkHEUM2wsRntylHbTV\nAhTGnhnP2gBKjcNb975wDibMZQgTAS6umPzyoe++25BmqdLT2uxYWPq69S3v\nif7NuRpTiekr5MJYKv9jo35s4ChhkEp3vRyXJibEkI9IvdUhCEbGj8QuIRQw\n8fWTysvENGIgkezYGevAe0A1iSPmDLKCjYijzzM3KQaDnlakEzDHMo6Hwf4X\nrg10\r\n=D0Ed\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-56ed5bd-1612652117025_1612652168874_0.34596567820117086","host":"s3://npm-registry-packages"}},"1.0.0-canary-56ed5bd-1612652117783":{"name":"@iadvize-oss/store","version":"1.0.0-canary-56ed5bd-1612652117783","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-56ed5bd-1612652117783","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"450d8edddc9dfcb9119186d0a63a9b6aceb6712e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-56ed5bd-1612652117783.tgz","fileCount":7,"integrity":"sha512-XnFiFsfgP6xmRdtSo8184utfC+ZgvV3S8cYIGb4CxVotA2vg6UWpdgygJIfbKth7DN7bdFkI6zHLC5xjvPUK1g==","signatures":[{"sig":"MEUCIAjuVqkazrBD1BBUaBmtpjveCRfykR2gwkTWMktwOzdfAiEApZj2gN4IyloijoxQJ7vclTrgpj+e1wYhhN3U27hkIdQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHx6+CRA9TVsSAnZWagAAbTQP/3al9HHsleQ0ArCb0nXy\nvVxtk5RCFDeg+AyiJNDhT84iomXiqRQeza5tvkhil2kOzVIt0HHK9sg9JTeY\nsPkq+Ne8dZ+C8y5bAPQ6MpV3BvTTA2da4mRWjYYqMV00GdhS0rmpbThPA8mc\nBUrUITsPThDhFJGNgKt13Sbc8wYFmC+7RiQ1/yNpi+EffdCB9zMzLLkEq4tb\nxYin6rszndNoNpMGUaxMFeoDnhvA1ar+LNf7St2lkDFAR3+jWDyF/4AXDscI\n4DlgKpuifJSVQM8inbPWb+8vzM9pn679bw0InXhYNhKWcydPsvuX7drIO8ae\nXT1Xo/d/gYBjPcP2rujet7U5QvWp9uyZbWX4mjZNgrm/N281s0Hz1MNkeLMc\nk2kD0X5myQqqxFMk01INI8HfEeUuUZF00j8BroSsS/k4jBWFakp854afT9Q7\njcDrkKPRgvuEiviLqoNVu9o5rMvzRRcxlbLhFq6/inljUVkW5RlS7n5trLYo\nnoOizeSoJ3CH6pNcva4+fGqIyyKwjeg3l+KUgaEcENgKPid5X9E9AqD9DuEJ\nQtXIVpZ+SlfUeqeqis0rm3lO3MxlL0SphZZYLl7UmhEDM0tH6Jfz1Bjenn9g\nSmrhTVt5P3KkiPOJsoXiCQWnhQiQIY+HtjH2q5fkhjxdqMSkbTUVABnMUKER\nTf3r\r\n=vgSe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-56ed5bd-1612652117783_1612652221448_0.0587133746047519","host":"s3://npm-registry-packages"}},"1.0.0-canary-67c63f9-1612739860467":{"name":"@iadvize-oss/store","version":"1.0.0-canary-67c63f9-1612739860467","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-67c63f9-1612739860467","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"192aab5e2b95b3fe4430b476728a5b57f6361025","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-67c63f9-1612739860467.tgz","fileCount":7,"integrity":"sha512-Z5JLZWoMjVBDX8W2bN8s8I6DPhyklc5hIqrl+DJ4psqLTWCtoBcYJu0c+XiOtY2CVkIbAjzAQjP/T+KXSo9glw==","signatures":[{"sig":"MEUCIEqXW99DI8a1Ra/S8M9/gzuE+VyQCcHM9wN185oz3XD6AiEA3vNYcu6ZB+jxuQkNlE0JMdEkGTO9fZSf+sMSI9UZmiI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIHVICRA9TVsSAnZWagAAMAEP/jnlJUERIW3vynU6vSGV\nmK67syTFCAP85/wUWqUze4amxe6pCa8pcDBUWik18tUiXqdvjLztY5AJMD7F\nlfwwDru4lScaABiaEZ9CnaYT4CFzH/uw9KDMO5DDim0pWvFaX53Ul4OpLdcE\ntYz64wMuf6qbrXc2HjUxwPLETTW4UPHQJFH8Td2+iCEAJyFmknAngH1pxeZq\nQkoRqI8LWTymXg+5gEKreVYGLBU0s6aKVeG+3SDKFRhaAoMBj6Pm03Z+OACy\noaDo0pYhCvgWhjrn+qYai1FJc9AA/xIS2LPg9mBV5Qd4QCUJfEO+wGzxo4nq\nZoYe/pChF5H186u+TlcRoHE+QczPSoURlHEIrtcauddjiIcX0sYVn8WbbZrH\nmUm+vQrbIgmxJmEZu+/8mS8MP4Q4i6PnHTgKXIA+MDrpLGKMPSB+Wg3jhW2i\nGVVKOsZ2ccSiQ1gcNM/EIBcpxyqPFUsVs0ar68frTzB22eaCZOWm10GKIDRn\n4mjIIFGYz9FvAjQqLOxyLBKfoO0WCjk/+Q3zJUC/3A9kEtjlhS/+6sAsO4OZ\nXEZMUZPZ7TvoNma8ln2n/GCqZjcQ69lnDXnNJTXgyEvIvHxai5XqkZrz89JJ\nOhw8XLT2+FKF0RwCictiABIIsfUjszDy9c+GWstOUits4kHGRI2caUTG7Xk+\nEsuo\r\n=ep+w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-67c63f9-1612739860467_1612739912156_0.6880628570646321","host":"s3://npm-registry-packages"}},"1.0.0-canary-0dc4175-1612775142842":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0dc4175-1612775142842","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0dc4175-1612775142842","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0ce76940cedc5d98a3a7bfb11e596756fe3138df","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0dc4175-1612775142842.tgz","fileCount":7,"integrity":"sha512-9nwvEgpDsLTIkE8I2QW3iPrMPtYqc7QhLLUmqhwCKiyFYQBLdUfXtHDkcaZp91lSQNyk6y6bmv+7/2W5gvYWcQ==","signatures":[{"sig":"MEYCIQDOBIGAU7ShncCDuFEez2Wre9pHwp+gBGZJX5cm/1UpowIhALGJaO0D6o5yH2iAkazIql+vTahDmgfa4F8LmjeouTMy","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIP8iCRA9TVsSAnZWagAAA0sP/3pbjQnAT88m2f0q1MhV\njD1Rl+lG44R4WqAkohobEbezzh+6gZzllInVEhqoG+3OWcEVQzM5jQj0YiaF\nkNgjGap/DYttbYI3iYpWg7+AtuOUf6e3suWn6ZO+f8EwR8qvGlXc2JHTkkFK\nbcGQBfa1+nei+uLinjQ3g+NH1oGzuDxLHfEgCravuNqQKx8CqVAVDvLqw9Jz\n8P6DL4rpKUIlZEfyb7e3UrpAyQmzRanmw9XUsDg2d0we7ZST/A+bldtr9SPk\njjoKsEWgExZRHlegvLUpmakvf3SG687zmIwstVha91btRM8s49Rp6ZPagUMF\n+P/rO5GCC6M+1XJX8incRXNqg+LbjcTnIvDo/Auc0Fm91D4nIGeFG/rLngU2\nhiltsrd4NSHT7tyUNIPyUzW4RQGwr3smt2KmiZiywmvbLubFsqlxxwJx/IS0\npN5n94x7+c2edSJ+2HpQk3mIuX7rMS+tHSJ2BG3BI/el0/I184v0mXhXBjCE\ngf6UvbbOUgJXv0KVR4s+OYJ6vQsJTJPLr6L6uyOv9XJVolz3xw7Tt4fmdjmk\nHL8vqP4pxagklYmkOkGzil1AwSBIkaEmPcQwOXp/oeMgMghFT+9aFdsLbD6i\nLqUblvoL8kDAkyYwzOmdoxPiOBrmwb/6wk8E9taNUsS8vVmGDxBFlsccUpii\nS+iq\r\n=2uEA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0dc4175-1612775142842_1612775202319_0.6836523032176247","host":"s3://npm-registry-packages"}},"1.0.0-canary-10abdd0-1612873602913":{"name":"@iadvize-oss/store","version":"1.0.0-canary-10abdd0-1612873602913","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-10abdd0-1612873602913","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4357cf251aa4bac76118e7ae56b2028c4fbfdcea","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-10abdd0-1612873602913.tgz","fileCount":7,"integrity":"sha512-21ZBnjW4RuUZIBxyByvoDGzrWU+/GMbFVtaEUQRa6iA3vG3Q61PaQQkuyCHOf7dTkRewJYx7qFMTIevwAAb50w==","signatures":[{"sig":"MEQCIFuKcIfQIfYh76Yj40/sZoNBw+x6fjSV64sI2ypsrVD5AiAw1m/f0xX6Ljazd4045mD35D5k0r8mCx3CCXpVXw8M8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIn+1CRA9TVsSAnZWagAAzhcP/3hPIfSscSqiNLI9VtWu\nZfW6dc92yQsGyepR9XnW7lB0Oo5cA05KWQlksTthVmav79tjS3NyOa0hGjbm\nrydSJTSIoq2N2nBJrfczKxT/y7l4yxtf8A0JfS8pwXu4wQBj8sxvsbzykSId\nroDmU758y4UxqeWV/GBvZSZC9Zpo2SjKPGgw7ShHqo5sXmkaCDGSXSXfu6rD\nPl1e/9mvx621MSinqUMWR7dwEfKMKGCrvi8vk/dkjnY9SIxyn2yp94V+EDTw\n7GQY3lkpu5s9oX3aTJGazMdEKpjK31OjWucN/IHCDSrQR5nTwE6doRPUIcpV\nLwEqUijFTCVSWOTknHRu+e/XdCTZYXsGDhd4uzh7/DRp/RN4JYjynsOYVgUn\npAXLJp01ozyXZk7bYleI59EgC+Vg5j0I5Zh0783SxH0VyhjaBD/nuaYZGkxG\nISq/hBQTMoE/W8YipO4uCZiaJNFCYNLFCtVlaQAOYoLIqcf4zaK/biCsK/ne\nJQVzc6JF30Mp+9TkF0v5X4sNpVktaEbWYQ4pe99nnzisO8ldB/RDf6EZWjUf\nhQcJ+XvR6N4beNWEIfowCfhVlro9VRUR4ZZYajcuMtsdIOXAfMY7Hexe5+fU\nKlf2VY7Z7JfCpOQqGKQZoLxpUdnyM33bRFA/K0ZUbUDknx2YqOt7moO2WO4S\nJiEp\r\n=eIJ6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-10abdd0-1612873602913_1612873652943_0.5285667931194475","host":"s3://npm-registry-packages"}},"1.0.0-canary-10abdd0-1612873602980":{"name":"@iadvize-oss/store","version":"1.0.0-canary-10abdd0-1612873602980","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-10abdd0-1612873602980","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"77e45b28682879daf67085302db02e09d1d24e89","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-10abdd0-1612873602980.tgz","fileCount":7,"integrity":"sha512-lz/4BI58TFMtPEg2w1yr6GunK+sJXDAg4NJgHa44o7pDnU8aaNFbgJTrr5UHVNDAFQPEWrnTVR22HTqX+ihO+Q==","signatures":[{"sig":"MEUCIQCE/28/PtGCxi5vfP8EeaCJlwRX1q1W2mlVhgsqz4OMpQIgZwkwsz61mA1szk9pmV4Pv4SOPPlYhRLGuXnkiAarM6E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIn+8CRA9TVsSAnZWagAAkqEP/0Hvr9JLrBddOYuWqd3m\nQezTFu81/WhXyOY9YSkqpcuGEZGFFyqaf28w+u6llH8Y/mZuu/aV2V8LlgP0\nqQ/U70LIRXljmcK4c0fBYUgeg+rTxpBTKnMHCE3XbNiK/te5ZhhuaLqfg8KI\nj3oKiIXTEXMl2BdQ9L+xwj/GLOQOpybaW39gH86bSd08ezbzQE6kZa2ouRJM\nL+ijPXi5pFP5UiB2SoWh4nrBsItJtFsJChDOzHnHesVgBiv9AaPIBU6dJUN7\niMFJtqCbDDwdFn8v2SsoyMlUCcngxHBF+JBP73KQPCr0B9dxJ8P5qRdlSy3Q\nldXK76FWbLir6eR1rqzSr+cRQ1dIdUyczNX82VzJrKbPXtijocN/XVqCF6FU\nEil359BBAUd+UUc2XItBfaepRYE2rr++nVMU4Ag3wS2zjOjy3cdIQvJQXRqx\n4EaXoInP0Y240M6HQ2IY3kLoE+vVUK6EDoPqE1XXMokuuIlBFHiOo5puIwb1\n65szXRD8vTHNp9A1yce8R2nhC03nSOnxvC8aMnibkU40kFS9WXgKwbmQKzn0\nkdGO3SF6CJXOxuu+8MpWMQmGLBjODBvxIp1r/xnUVnjp9sJCGnigCyC3iH1F\n0D7Btnwgj2wb6Y6uo8+dYsnEoliL60kGey6wuSGVWXgEEsljHj7iG4S+XfTW\nc9Gl\r\n=kfal\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.3","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-10abdd0-1612873602980_1612873659849_0.13701298009699392","host":"s3://npm-registry-packages"}},"1.0.0-canary-4ac427f-1612897579191":{"name":"@iadvize-oss/store","version":"1.0.0-canary-4ac427f-1612897579191","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-4ac427f-1612897579191","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"812f6a8644cdff772f65d60f3e76357ff2571a60","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-4ac427f-1612897579191.tgz","fileCount":7,"integrity":"sha512-1/sZJ0pOokzrmdZ1dukI2nrPGX9twtAJ349Fw/Yz5FrvOURNQQztC1vij0jUbCpRg/aELw5M69qn5OO7DCeoyg==","signatures":[{"sig":"MEUCIFKai62cVxqEEkU0zxSO+XmxkktMQkkBn/m8Ygsc3tazAiEAnECEKy4FOdP3XYL2PS1deVO2mNWsglCc8jZJyrU8PCM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIt1jCRA9TVsSAnZWagAAfcEQAJ5HEB+O0uuvRk7H7dLQ\nTjHk+aQ5hr+NmRwK/edXZG/5T/I/rtG6aSvU+98Y0zEPtfd6ATWNQb9ZZsnJ\ndhdMIfnnlCvxlAZwDqh7QyStx5IsOB0sJ2OXWav1xO58yDYPfJKcje046zVJ\nZGjMiqcQ9dXBQwonbDS7UY4D2+V/rdomrjKNS1zQMw+DrPYHW0mr5BkBgXb4\n9BWzCEoTws0hULoFHpw4QjfenvNwJr5WVk4lAn7Nu7JvlU6eCFeuoQ7yJ2mf\nvpQyQ+Q+AMmw4UEc04866WqF6XhAIGwFzZRplPlEGk8uGTa1/xEmFpW/smfD\n98ycUVeTtxPngbKfZ9lMAdn6hBgXZ9EU8tqxQJSh9rpenF9Rd1Mv4odv/sNR\nbhBz3WE1NfCBAqnjNiUWTBl1oHBQsHdHO7W6lAqvL8hRXAxwQyh9SV5hV/Ay\nlCJenmvtw3a8y6ldF5Mhx9A5DQ8W6XNE9/RYr+gZfhjkzcFgVRFmBrU+Lkmw\nze1PE1c6yjk1E5209UiPQEzAsEptQEkfcUmkfEwAMoEkjTZeEj7OXw4wTVly\nAQgQhjXOsG8x8t8EjxcEQ+4F2mBzBxMrIEmE1XUnrcEY+N35UDX9X2Yr2RyA\nTFxEpeSarUXQDgT3QaMx4qEEy5NiWKU75Z8Pi2YGyJJ9AJ5rKFCHr7MTLu0G\npLYr\r\n=1W95\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.4","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-4ac427f-1612897579191_1612897634487_0.4698468343862199","host":"s3://npm-registry-packages"}},"1.0.0-canary-dfbda9e-1612912591368":{"name":"@iadvize-oss/store","version":"1.0.0-canary-dfbda9e-1612912591368","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-dfbda9e-1612912591368","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"04d73e1a52e7a41f67e5a3ad2142fdfc6c925bc1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-dfbda9e-1612912591368.tgz","fileCount":7,"integrity":"sha512-qF56zDTPPkG9KWREoz8o70LYCB4r16H3hxFCXYZQdPXDKbxg+bTDtZH2UBNZr69sgtUD64jMEG5qARQC5MfM7g==","signatures":[{"sig":"MEQCICz/Pc2qs30/7NdGucdExivBzzdfooR7E9I0AouWK8KUAiAvY6xGKM1l5AImq2UfYpn2jQpqarD+v1XZ4Xwc49nnKw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIxgOCRA9TVsSAnZWagAAheIP/0BUhuvh7xhe2tiEVWxb\nuas+/GTKIQpDvujK46150Jpn8vQlOGrmkcVJkytk4IDpZg45OcyvCGZsIoj5\nAuYLtb9OBXMmDnwpW0w0q4LNuv+2F6SFMQ2yyhYeO6ssPbTLwW2cXFL5c+oi\njwg+sGCsxzm0j4lAtvcf0MPJCAbJpXV/3qLsZLjEh+yjcs7YZO0p/FdhBkf1\n+JYRo80pfgQObAdrhcC6uliTE7weYwFHt9miKRdIhK7qUiCoQCG6xdQj2hVC\nUA3UbSs+NVvjoMgKYJr2tAXB/+SQpE88W1/dAqcRKf5P62S8+REVbdi3CMvy\n4xVisu+FobIdt17BwVEeojtV2TB8b8xzXPPQ99cs1AVvT1KBUx9veYKiaDkh\n7NdiW9yjgQiWmFCAY8z1w/I3lvoGxKFNt5J6A/NFDO3uZFPmzZdbwlHeYbkB\nfcP1vUmEr01qCfGrcx1Fe1NKJSNV3p44uGkYVzJ3Dk6WrkKfPjjCzE2Tddop\nHYtExjWZWozNNeB+YIoeClS+TuOzNA0Y6Ld2hscRaQqD5yYQYwM78QyrmKl2\nHJ1WyExUXODfIZoT+7/AT0DkPqYbN00lAGv421Vfi+1ehIPbhHxQGYG2bU64\nc1D0iXrRYP05QKF1t5p5JklBdjHDFxQ13DRg7wCZzhFa1B00QCUOrsVCfM+n\nkCkR\r\n=K5Ic\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.4","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-dfbda9e-1612912591368_1612912653544_0.8401676796121647","host":"s3://npm-registry-packages"}},"1.0.0-canary-dc2c177-1612990668784":{"name":"@iadvize-oss/store","version":"1.0.0-canary-dc2c177-1612990668784","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-dc2c177-1612990668784","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c6b8182c20b545c3836f54641d0813c811f43d29","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-dc2c177-1612990668784.tgz","fileCount":7,"integrity":"sha512-GlRurlOKDma0MM0kZllyXP/j8IVBYiBPsebF4P4FKBY+Z/k7MwsNZN8QU0RVtGRUIzc5YYGsMVWDooOX5RUhQw==","signatures":[{"sig":"MEQCIFMJyRw7Q5Ciacbqp04bIWjD6Xassar6qhbMb8y9gLT9AiAezfTOwlmU0iJw/j0DO45IM6HbZ2Hm89/8FS8IHxz60w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJEj8CRA9TVsSAnZWagAAmgEP/3MQQ4dG7scf6RkFSqbc\n3Bwk/M5JIQwbZSowF01JDhQ6NrC5coGnAweAQt8JzFFJq6rZVXybimgjSD9U\nDM7J4UST0YvfssB/Xt1BEHR1nkS70ao6798NbBUtU3sBCo8mJAde5m6oVciZ\nl+ZBFGkx+7FGdO9fezupqm1P4yHRtq88hYz/P4gPz5u+HnwrfxRZ0QGyRPGt\nfH+EE0tDFWv7WXjWTboyRJdASeWMflFmoJSyPtKm6dJaa1uqFQF898uWRxha\nfHPcOzTYIP7SWvS+aXw6MpyT4CeI+Tnfj3FR3uHNAGE36+U4yXSM4w8B7My3\nf4viMR/Ujy/QJx1nyxCaENPSIjUzofiyjtq2VMtdzhTGxlUHX32twIrhemtY\ncIMrVLeyFqB+4mIEffzdmHa7mF5zCzWl536pMxUK8aAYKPaz0OJsGbayWENa\nlTglNMuTkiv7ohu7Q94zuw5Vtk1wbEnFepexCafUKoQ/Lo+PZkaA93KiHa5I\njpee+RHglSuW4W7MA2+pMaSkwyINULgyiGfUGaUTtyz5l58XN6RQMB9iS6k2\n0mEllcaWZXq1iQBFZ/99xrKdtKGVcnbYnEJydJz07wTX1RYQQZNL2SqrvJCf\nVG+ldlU5+7dK5i7r0nButL5U17I0z78A2lkmNSLp+ONDrZgNIW4716vr2tka\nddGd\r\n=4eI2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-dc2c177-1612990668784_1612990716216_0.7446712517455814","host":"s3://npm-registry-packages"}},"1.0.0-canary-ea3a500-1612998945824":{"name":"@iadvize-oss/store","version":"1.0.0-canary-ea3a500-1612998945824","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-ea3a500-1612998945824","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d025b6ff59ab37ba3c0ed56544f168217af747b7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-ea3a500-1612998945824.tgz","fileCount":7,"integrity":"sha512-OV4HMfEvSK+rAbbAxCL/OdOzHt0ArQB0JBJEW+np7VvKeuFipTs5VE51z/6jH1qvVfdjmzooAVv6FGo9VvLHtw==","signatures":[{"sig":"MEYCIQDkOVZ1gPJBoSYexHhpoBdSZZ8gp5rN593tGkRbIEPCFgIhAM1ZhfRvX2badTaEhmlmFg4koGN9I0FXa/bUVYlkl66m","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJGlRCRA9TVsSAnZWagAAz+sP/1kamTzlDlU1BJNAT5Yn\n8xUbAA4PifgNkZBCOY0l5L988GFvu0l57vhp3014kHfUsb+R05Adn7R5EakV\nQMjK8jkDNy0bIdZexAs24XPffTXZq7YXEda5nfnDMxqdp8sxeUTmFo9uUWCf\nChdiBgaEnDFuwt8P2oCa+yjxE1SjCisYyjpZ4lYujefxV53PA3OQXm/9xyyI\naPloWNBFWgUbJAwA9e7WTojv64I0To757TkZDi4fLpKB3TD5N/I/6jJXJ6e/\nDaK8HMOwBrUZNLPYGOU9OwDs7AEGCe+HbdjzUQFUN4fu6//Wt/rM8udckwOJ\nN0Nst8Av2JvnlvTexApnDqaHEUCb0u8PmxWPv8g98dxUO3fNYYmr1v8FGB9u\nmbMbEl/0Mw3S8YnUHwNdVB/wARZVsd2Gwc1kx03JJe32dBw5UKx/YS/inCeU\njdw+bNHM9YKMd7/AufuvjtjM3A1sMgY4LPf3vYjFMDASgyhufxe9xQdZbFmk\nkX/DhlFAchQOm02RX9a7z76ry8qm8Gqw3niKOY0Rx9Ubkz/ANS8EsfmgahpL\n0zWI4WqXk9tg1CcTobFXv/gAxI4VwzP9rYGH0xq6S8oI7lttU4/X2p5UW6JT\n2Dk4PgSPHuYAoISZGsJ7FewKWpPboczdsb/5H6Tq1eshYoEK5eO5U58VZrjX\nL7sI\r\n=NtSr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.23","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-ea3a500-1612998945824_1612998993207_0.8350635968301019","host":"s3://npm-registry-packages"}},"1.0.0-canary-07b6c65-1613014639213":{"name":"@iadvize-oss/store","version":"1.0.0-canary-07b6c65-1613014639213","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-07b6c65-1613014639213","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39f6501fb13a740283de3de73628bcf02655f6af","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-07b6c65-1613014639213.tgz","fileCount":7,"integrity":"sha512-xT03+zRRX5/Z7D5BwpsVZ3a7z8i1+KSaOlqB3poD/5jrJtd2arhLhcIbcQVdhBgl4qwUP0tMcL1coSGfaWKvkg==","signatures":[{"sig":"MEUCIHWXn0mx32Pf9ZejZnUodWK35OeBzH2ZPJSrraGtpHdSAiEA8xy0svwmMP695jKgH9Cnn00SLkQNflfSaqFVVqOSO0I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJKakCRA9TVsSAnZWagAAtXAP+QCFtY8nfsi7kNu/9dbu\nJtyA4zQ39tI+NHm6rxeoMTmyMdbWIwSdpahOO/Y0Ojv2X8M+INbB0HlqUT5Y\nlPwKGyastM7HmGvbMqOgO1NYdPMW97ikRYFJOPw0QdfeyTtkxQ6cbOPGKcId\nSi7I7kfsR76vvJiN0Q2Nmx2wqfVgs0VvJUN6CKAW5mbnytOv4ZysJo78K5LH\nDWGLM+mYa4hoX6oU/xw5IYgz3f6pwXQ7r6KAX7IqmFCioKs7S/WlN3g9B2to\n90i6WL4EIyZ1FYoM81y6exUoNbBOUdgstRSy08bfJFl9gYTlwEt3CVN+DF9E\n0yT0Mp7W9Sdj+Ol+3cw2w6PQhx0EImO2h6Wgl9LwmEmY0nkRYwkFUhuGhcTl\nZAfK63oEtr8XPi+Msm3wLAMAYV47z/uSKQKmSuDQmwCHQ6rv2NfFOU7DaXJY\n8+CERQpjttU99Vi+SwXm9jsJydQIRH0iuuRliC3ZG7TAtPZn3ISUBcyda1+x\nNaNGZtGtzw5birZevyQzRst7yXGhczR4GUdJk67bTZMF4Db18COK4ZfPN/bE\nZFnyctcKIfp+A5b3e6f85L7PQwBUlfiXEIPGL1RNu4jkdMF4Bnzvt0isRVlj\n5EAWdpXHkOb41AxHqEVpWHkyycdaSrP7lBTiLwAVmNOqGFvRZHsX1Dcx3rQC\nYVVw\r\n=Wg5f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-07b6c65-1613014639213_1613014691694_0.6794871141550272","host":"s3://npm-registry-packages"}},"1.0.0-canary-6ac1ae3-1613057570212":{"name":"@iadvize-oss/store","version":"1.0.0-canary-6ac1ae3-1613057570212","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-6ac1ae3-1613057570212","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8e71611c17fbbdba1d9bc4455e77ea5f734b4d62","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-6ac1ae3-1613057570212.tgz","fileCount":7,"integrity":"sha512-XSHr9lDBqTLCshqOciVbnDSnjoj/3Vo8SLEwn7cuCdTvqvPs3txTgIcutWwN4ij4POXnP4e1Ys2WSq9iVfHIdg==","signatures":[{"sig":"MEUCIQCV+o0/ezWXItIvZ65E73ppfogWE3XcVJQv+D/ycO3tYQIgYuL3w9hfVrnaigJUWMxwHMSAyNFuuSs4dRvWz7XrmqI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJU5VCRA9TVsSAnZWagAAZDMP/1W0m2P7xIYKtTxwEG6W\ngBfikXQCGs5z8J+0Q8BKr87vMvK6BKctguYLkb3QIWZ9Uw2qAXpNMfeFY6x5\nKkbqzcTZzGaXoeX7KAiKT1tG6nhSS2oUoqplIVnMZ+XOCFYOYyEFxG1yTNJa\nB4PjRS3+RcNVFIWkSsUoKSt4ymYovggmyqYgzoWpdgdJUv8VJRIBvmkHUvh/\nOIcI3bTLf+plkaEyQlHjqiebhvpF5Ag8MK+ff2ClDXzkCFSQoMtbLpwiEH0t\n94cAMjFI7DDm6HnglUg2/jlvqHkOM5CYOajxvKfrBjQB6lrzNCNKnd1fYGab\nayGBEoxu+gWWZ+Bq3QhMl2oqermxoSV55cF9lJ1w6iaaEEpAyRMY98Pl3Su6\n2ic/Xrxt8Zs2iUbDxDR6bClqOxvVmCpvaHWrqW0v4vK8B/YAGFovuq2Zbd66\nrzzkULq7zE0QMh0uj9BML2ZFbMFYntdAt2Om87fCh7d0OsQq9YoNtwox8uMz\nVmChMmrZKaxj50ynaFI7XaUhUIqSRLmblPUUx432bZ31RIb/XabH/Lw/5txF\nLY3r+nYh/RwmepgM4bPAsaQ52kkdDPJ4dvEkSHuQII2RDE3wVoAsLoIbj5YE\nyQqdn0j7+40GuIPoSSMnHBDwe0ak3zhvpbH7OpA0XnWHxnNDqY0Zes1PjGD0\n0d52\r\n=IvPV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-6ac1ae3-1613057570212_1613057621056_0.6488336570073434","host":"s3://npm-registry-packages"}},"1.0.0-canary-af3cb0e-1613146050211":{"name":"@iadvize-oss/store","version":"1.0.0-canary-af3cb0e-1613146050211","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-af3cb0e-1613146050211","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"eb1c1f0ba4a49568ccd98307c845be8f71df5d60","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-af3cb0e-1613146050211.tgz","fileCount":7,"integrity":"sha512-RGvH5FP1xAYps6ucYKfWOKpBQe95kXB+S7xP7Gdb0fti2CsGqm0KCXiV2H4EXgDwcNZa58CgxmdxIHkBUE2SVg==","signatures":[{"sig":"MEQCIFv997Tw6tEpOvUf8DU/rg8SZe9UUBRTHLacjVTJEIyAAiAGqCLzwdak1QM469QowYxG2aAzovilUyMPonBFlLKWVw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJqf8CRA9TVsSAnZWagAAiccP/1ZtyLR9Y7L7gefo4pvk\nIrGd47P2FdZPTXgv4dADsb3523pVCKRJ1oAAispCDC3qTFJkvfniUZW9td1o\nfn1gn1Z8jRMGuCj2zwrRMOmZOioSrLKE5w79WG5KMGSp5lWk04G6JJNjwU3D\nAPWYMWMqhJ37mJktisP3HmAIJP4X8P/ogkpBXHl+Ln2VE+6sxXx8qiXcPry4\n2zopnmCGT8EW79JdT6cfA/W4vsY6dUi7LlVb6bJYNKzrnIzd6q34Hf9zBlTF\nkJQpOWNWVhj7Sf0Go/dcW+f0NPvTuQ4vlElFmeg2ZKLtU0Fi7H+F1ReoRyun\nmZ6Hw7t96j8eeVneH/7u/EBsXOkYH3eEuxDjOGuVes8S0Ceby1OuQ5KULviy\nQ6EHafM9t2NJqQHLXozhieY9SBVtLbLNaqJnyhxfPTlvFaOIvUCOkmn1Yj4K\nJ5OV4uDwycLaWfC7km2vJPOLjllXN/l6EfUW0yosOvxLEUzmHPEs6NcH6Tlv\noiZxez9Lr8QKcN8jEgQxaaZGVNX1iPOnouNMgbhZh7JuXl/7LlvvZtexUIeF\nB14psB3kYZQrya1jMhCqWAoDi0fmQl/G4mui9806p5lLf+Z1979/vqzC5CnL\nqLxoGjf9UEv92uG7KabyEygk60FRIMY+7KLVIqkT3fTcfGszzTzIsVyzXB8h\n7yw1\r\n=+rqy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-af3cb0e-1613146050211_1613146107520_0.4172620051816369","host":"s3://npm-registry-packages"}},"1.0.0-canary-fe416f5-1613169986329":{"name":"@iadvize-oss/store","version":"1.0.0-canary-fe416f5-1613169986329","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-fe416f5-1613169986329","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7fbb56133acaf8b9a4d4435d2482efe91644f2ac","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-fe416f5-1613169986329.tgz","fileCount":7,"integrity":"sha512-yF4XsQIQZVyDLUcJKrYxjbMJ25/DTxqDvM+8SWxaPYjOlLnLUj5QG2zVxhHJU5R9puvX70d0WT1CedP2sfNxPQ==","signatures":[{"sig":"MEQCIFKg0Cape66I+gH52kmCD8pbkyxVki+7ttKB4+KYy9YlAiBvGUV/NWOKbM6bI/OLTMP8xChxYQIJxLONzJPL4CQjxg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJwV2CRA9TVsSAnZWagAAIIgP/2wmyOoxws5MNeZ7Rtrk\nWSeuiEQuRzHLVExhs1jWM5+AuXbu5k7fdvuqLRfh3FgMNLDNHTFJ5q+N59YU\nonpksd5Nvr4wHBLLelJt9zk5ZM0kzSB63cSQelClJr7u0NK8z4cOIp7UqtW1\nzijwWFZAlFOX8E1ST9YLwdbQGooM/RTOzeIwwzzBqndkQkWiASOln2eExno/\nfHYpvOnPqVRaBRtPr0rIU7V/FIbIC6h8MXYzk/3/g/xqf79y6YJ4ph/81Qmh\nGAM1QQq+nYSG0xMJ6FUOuNz5eAPVpLYBZD/h3UgfVIpH8t06H6jlRvrfGmWf\n7TDd8ch3IE68z0rRK/7W6A9mXShB2DhxmEDZRYzYLPfVxL7akP5zY+2sy++N\nv3hVQ/eX2Crwp/lKo0eImJfDtmRm90A2Zbtl4k1xaQnPrai9JccJXNUZ42ND\ntamMm9RZFf2JEP+bHBzROH9xCsbtRLvx1bYwOChofAxo0c7vBxtR+q3dJCsu\nCIIFlu56kLYPjc+4fCRKbqI8Koou+q8/MOVaouFQNGbYpNFWnCTMifK10onV\nyd0tMQSQ4lxJAb5fZJ49W7DuVPsdnippx+z5IEycZ8k67hPBXv01ZZVfg6T/\nRz1dnSORp9SgdidTUpogZsfIuJ5Q9J7tYUmuwqThPxx/MdvTKnMoiXL90OoH\nfIM0\r\n=ZCAo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-fe416f5-1613169986329_1613170037500_0.6883267090224297","host":"s3://npm-registry-packages"}},"1.0.0-canary-34d7388-1613344475382":{"name":"@iadvize-oss/store","version":"1.0.0-canary-34d7388-1613344475382","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-34d7388-1613344475382","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"607cae4b095e5fcb95588b82bb91fe026706a94d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-34d7388-1613344475382.tgz","fileCount":7,"integrity":"sha512-p6EVhVayNxVi1L8VhHE5DGrJydH5sXqM4gWqrydYAWBzCCX1p0xAHyijrU+76gZr9X8Yk7/Pnsm6KE03pJuykg==","signatures":[{"sig":"MEQCID5E5QFlASYiRHSbvsRHhXP6TcaJmkPuERKHIHrV5g9EAiB5hpwUzSae6bnsNt9HTRUaaxFriZ+xmC3+UTtHj9oHRw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKa8aCRA9TVsSAnZWagAAlbcP/A+CIxEoSOBo/317orNi\nVo6BnbQE/m9wuohwu6lPZCz/+nyp0g+D0omofmS715YKclwne4FcpDu5/Bco\nkJGE5RjgfUVORQq2UDGV3NgK02LuKXWbOQATuLfzbhHlerqpPFIQ7BJmLRmT\n5dfQRpDLySEc7PBOc6klUdXqg3HOt0GFksiBZBX3TT08VAJEvQHpei+rYTYB\nFkTxWqhJ5hUta8rVnr5SibgrTqXgwBCxPjjyjwSu24w1zNZHUDAEz/AtP1ke\nBlqP6qqKLLuWAHshy76nhk8N2QkoXu2lVyH4AOnOZ41KlpNxhQQ0JaBa9mQy\ncD2zAYx0A5sa0WH/q/hdqfGItIUtrxM77rLYopSEN9tY3suV7IfLS4yzSD2z\ndybzCZFLXAKpgCR4GSYplNtpvBDectohFb88lqYv4+VBr713rfgzPFDPqjzq\nlUJ/7cGjdhkbvX5PucrD4ZGozOglP/wjcoolQ2k/Zk3Nxcx+rQ6qMTKj+RfM\n3UQhpU9To6K1xYHE51h7m63AZqnCeLj8l1zzle3u+3PI0WDOz2N+FFn1Kl3a\n5INJ/qtHQXRuECL9VvJOz1N86hZ7aV05FOcRPoHwYwLDGj0hLJnLyaZ7eAk0\nP9NJJziQTjxJ9kouE+u2pVI3fzUOQnlr1RRly42PlFNpbUTWtgpBgrBGmEU8\nQx0i\r\n=15SZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-34d7388-1613344475382_1613344537538_0.3241504678197529","host":"s3://npm-registry-packages"}},"1.0.0-canary-1597986-1613361013069":{"name":"@iadvize-oss/store","version":"1.0.0-canary-1597986-1613361013069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-1597986-1613361013069","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce110d99d1a5275d000258e9a56abdfbd379e1ff","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-1597986-1613361013069.tgz","fileCount":7,"integrity":"sha512-3Kmmi3Or9XQDNqluBPOJazy7F+ooEw4hnxwsCHqK03YK3oHxI3nLX+O5zMkByEOMB4yubZuWF85cr4/Y7y1asw==","signatures":[{"sig":"MEYCIQDezZHULmO1JA8qmMGfRAQR3oTWz8fpNDFfCPwwCFp2nwIhAM87DD6L63l+NGUfv+cWfZHsgu3XsdFS4F829Pm11fgC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKe+qCRA9TVsSAnZWagAAkKcQAJUKYqFGYX/AX7sDoGP9\nEGiFJjnBfQOA7gcx7A6K8zDry0WHCk1YAqU7VGreWg3aeBARcQ/kEyAznfBK\nTmzkkb+eKzvLRrc2tIhpJbaw0pHBT8P4KRRm/1Q9Ufg4SPuPySjlRvgiUI3b\nvNUZP9rHBZpDV5fAT4x54BWcdVZdgLVMPrlBHTv2cUjS9PdkMGuVlSLF+UEf\n3xmYtSbqhvxRNGSGB8XlUG2/wnn6tOadGErwXPi/e+nIcZH+g9yKvoeV47yS\nWSsSFnDRLJoqLHaEn8NefEJJA/4abY26SfzDhVN1//kfLSupFhd1iV1NpjkE\nKR/nmKpfYvNzf1764CL3EVs2JX7scdYrRYTlStanrS4CzwlUIOsyMCNp45yC\ncBN8PPjrh+5mBhzQOwDBFHh2JhBR96LuAxyC6oDDqKsD/2K7HNZAl/5AwtBz\n6NDQa2hjbDp8J62ThewzDkB9JjFsdnVPkKv2ooeROReXWbIf3oozflSuhQXX\nOkieKk/z5Iberjrfqwli0JW0Ooayz46wgfqSl+Ke1k1R0T1u3K3oW1/nphKf\nIgFPe2rSkOKAcSPLwwNxI8CmErsfLYYXfKkV4JLs1UbgbmSHIwrnl0cLT2va\nClLrxvozMy4dPTN4JQ3loyXywVvLe8R0lo38y51Z1MMd2Z+XXzsaBRzY/7wc\nqUIU\r\n=TjLm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-1597986-1613361013069_1613361065776_0.5179025778020261","host":"s3://npm-registry-packages"}},"1.0.0-canary-793c4ae-1613378779278":{"name":"@iadvize-oss/store","version":"1.0.0-canary-793c4ae-1613378779278","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-793c4ae-1613378779278","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"40c6604baf1841f3f7b2baedd8505d065a64777f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-793c4ae-1613378779278.tgz","fileCount":7,"integrity":"sha512-2MZu8+uyFtBfUTXhEQVeT6B6r2PxGCFayKgg1wHMBmIKBEUjr9lJME7B4KOL+uTxDfNmxSVtJaDVHgvw7TLl0Q==","signatures":[{"sig":"MEUCIQCPY3YUAZ4AeEqSkm45VI0A9WHA7eINTE6rpQooVYpTzAIgG7WRo9RQrvSTJ6cZVV4Uuwlcb4STqsd9LtYGIH8uZVc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKjUQCRA9TVsSAnZWagAACs4P/1A8ruAKWTNzXKfSkKA0\nd64XoDRGtTm/C0ytPNfwdCjhERI5fbl50mq0mSSE0GVhV+HnGf7Ckcjhgpo0\nVTrJYAifCiD9X3LQasbGgWbAnmCgmzjYf/ZIznNCulNbmc2oa8aZVab+pN2N\n14BgTCG2W6kjGxhNgVmD6UOjxTzetsrMERqrVWwDoJBK3Ia/W8f/6VzJxN9C\nzgSNp+MN3NpdpB/34+4fat5MOTIJ9vg8jR7S3HPjlOOZcgB6QxXEFg5j+jIF\n61iJdskF+UclLFoBTLjYzqB9Lvf2AH+TtbbBhwjdgNpyjzWks1xqONoK6pxK\n2ZlWYn+KgI3JJZUpCnQ5CqyOpSuXGnn9hRHZMIrdEsTWcLJn6ofdXFlIIYaX\ndJaZvdHvGLBdnwnGs3KxLv/vOqrwjX3tJOv+OF1F+PR1f9uf41UQ7Mpqn6AF\nl/CUvFLUcnlkRE79VUCAhETRGOcmZdigeWtgqvoCTRKmwJwwvK47whnhKZC8\nXGuGZ30Y6hwEmC3GUMYfeUzpS+gvOG33ZqJy7kprh7jbgID5/bdcHNAjRfn4\nQKyuQ4BZDUltajnsuOYt2AVR+dMCXKtk0sxl9wATdjH0JXfUFihp6PT4qVAq\n3iW1b6nbGswzgZ2/H8zBe892GGKmYuTGaDTERj6TZ/73ebo9DZCh++RNOEK4\nWtXf\r\n=Y2ii\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-793c4ae-1613378779278_1613378832098_0.02290344297033764","host":"s3://npm-registry-packages"}},"1.0.0-canary-22dc271-1613385657345":{"name":"@iadvize-oss/store","version":"1.0.0-canary-22dc271-1613385657345","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-22dc271-1613385657345","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a873449c7e8bdf2dfeb1ca2776b941660b6778c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-22dc271-1613385657345.tgz","fileCount":7,"integrity":"sha512-+a0booXIvuj+MPYDSl6IaCTZudRNE2K67SDJGDTQi/1epHobL04lrEsYocu23KaB/Qxh98I3APw/D4kIuVgspg==","signatures":[{"sig":"MEUCIQClOwSAxRyQ5sqKR3d21/VSKAGbo3vz9PEr1LKou0OxmwIgHD6bXzGdNyjEljKDIdAhiUf/PD2t3AaUny1W2JMirOg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKk/sCRA9TVsSAnZWagAAK6sP/3jHhbQ7rQfRZQql34Dc\nzLsB6i1ObbEHnYo/bdDDYo2/g/tkJT8VHJqdKhVUto8Vb74y3O2q3fIeELLS\n2edD7MC1Lej1a8qqLO75Nvsnwfw3/YyNVywV8iCtIJyiachexbF4T2r8YKu/\ntcFoirLJrMoOSBkkQvS3B5P9/4uLwLxeEWj42Cp0Byk/KNRNJEwjUGJbKPtD\nRT/xWzFVMiXZlSPqGjWt0NFu8GJszOzCdbexQa5ggCH4F+G2/rUMD7ykISsi\nMQEHjbZw3aBlgPNBb6Mw9cx6gzmjPyQwrIUyGMj4gNyOJB3ZmEXiYQXnlc+G\nr5VNWWZk/b26NPMZg9r9AUQQ+i0t80CAlpRl7J0z8Bkx7a8+/WVa6pUfyLOM\n4shxspyRNpboD+3Tw8GJ76VSLVZ7ure6GB9gZze6o6bmt/zdsc9nMMkNTkdr\n4LIFZqf2Ffzg6TgvA91delJHIHe1I7Ky1E43ldGwQxfsO40oGy6Xf35sHGZU\ngG1jDmtZ2IlV/5546m4Xk53puXgZPR9aW4sLHgkp3uZCLvNVAVp2+6A325+A\nSQENeDr9ut4hgLm9WnuBbZH9NDpo1GVbB7htsJUn5A27bjcTgxkPXK/HqQSh\nCDNMwVrPBNfBFYCDUfFixFMzB2jvH1/fMKxGPzZPcURtIZekapVUcibsEdOI\nDTer\r\n=XGoF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-22dc271-1613385657345_1613385707604_0.5051649108648089","host":"s3://npm-registry-packages"}},"1.0.0-canary-3f9f1ac-1613391751158":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3f9f1ac-1613391751158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3f9f1ac-1613391751158","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce2eacb6394217a8ff5dc494dc5e53f49bde2301","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3f9f1ac-1613391751158.tgz","fileCount":7,"integrity":"sha512-7KNZdQrceUeCWhD69s6U7+KYU9mncIT0rNTauCpmv+qrG1FQWo7zdbo50hVacFeortzScBOLqQ+c6qndcTo07g==","signatures":[{"sig":"MEUCIC16oKQlAH8LF0KM9d6HPVBYJhgwzhU3Xj3Yvsu7P3buAiEAoGbs04Elkc3pVdBcivqMfPTL7rdSNUs3YrOfqU5QUg0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKme4CRA9TVsSAnZWagAAp04P/iReRBHn058SJHoa9dDp\nckRK87lZpGN4lEkOgIUx6gseFHIhH3MgVQ7vBSA1G7OGPDcvIbIWNvE6eMrO\nzJrb0ve1pqGrJDq6YorWGWblCv+skLNOhueI5Q6ZV5J7vNDdUjMEq8DlPbGw\nqUuHSXPGnJrgncaVYyjWTYLamJCMwxFJVSq1t9I6B0lByCCZTO+gNv7u9+qO\nJGXkxjVaJZkjDy3OaPL/HSKYUX7dRpP8d+b7cZxjhxCz9jiA/famKJVTOs+H\nbjWz4o9TSllsWXIhhvuq5gN3KLMcpMrn45qVUNEMnNYaRhTKhCMoLxjrzXYA\nKdWg0Mo3hdPDjrzYSVuO+/MSEyp17p7ohs13ztuEq2YcRy/PdC5KB1bszk6y\nSjiH1J7N4EF+JSklh1Ok53RuBcrfpWKr3m4r4SgDobui0G2VYPz0nH2U/nVA\nH2lZeHRH3lS7bhN2P1N0CwPVfkHBynGW2mgQO9L5u7FBq9f5296mECHamE/K\nEGAL2nJlrawtni43mm+WXfS0BGV4dUDJziDj+l6isj0Wh98QplOn4Vnncrsg\nAqoUSnsfHkMeljXIQoNQKZpCnuJCXPjPVygRKuvTSJSmce6qKF7tvh/BjyhK\nKyaZTGeBlit2gApxmmavDTHK4nntDyuiYUCES92HMHUFe9zAokjsTXw3jbpK\nTdw8\r\n=/N69\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.19","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3f9f1ac-1613391751158_1613391799834_0.26249356391614587","host":"s3://npm-registry-packages"}},"1.0.0-canary-892730b-1613395699386":{"name":"@iadvize-oss/store","version":"1.0.0-canary-892730b-1613395699386","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-892730b-1613395699386","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5241cd8f3ddb8758023cc00e1460c99ab2344168","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-892730b-1613395699386.tgz","fileCount":7,"integrity":"sha512-ax2Xyrh8MYoHGpji9r/e2jyrPKvwWyRqW0lEaHcRIPBoDD2xQbYMiQB5FA7x9y4Jfp0K61ZCASdHWQqMi1iyPA==","signatures":[{"sig":"MEQCIBl/chWHLXjRZcfS271ZziKDjJ2mIm2YzM91o088i23JAiAZy5cNIPOYJWJ4/Yptw9tsUhwFTXYl7Zn5HkAKyrptQA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKncsCRA9TVsSAnZWagAAnd0P/Rf9MXWZ+tI/Oe81fuhT\nwUE/3MBu9G5zva0NVRGCdzQqER+SYRXwkLY0+W/R+Fn6XF/ZDZf/VJqknphU\nwKr2zamPRoS7imIbvRe5ZBVhRWOMSfZq8HENAfu/uTwzuX1b6R7+Eh/4zjk0\nr8ynV8OGk6FjKUbkjq+IYHm2QRWb9Cgw2rXY7MUEVEDxMwVmlw6Xa/0s7L/k\nrTtW5qdsKBqx1JOJlr4RuxFaxW5KnNFbki6VKpJWYsCHEm1CL07lEomuSwR4\npD+B8eYJ8RYvtY7DOi8705xXRp4dGjfdwOegyt/JvNZoD4bDHGV+P4yxeCy/\nMR/swxRVf/xClx00waF7pxKi+d94tNrxfhhEMLoxtdK1Cx3L9gJIBmJJzgr0\nsmXLXlGZbK3OAxtydS3qCk7k5H/Gh8vznmt3vGjdxVyUCxwh1bepWFAERvTK\n+82B6kp0umGyT8sQEgZAY0dtAMRdWTnCmBDjiOMrexWb1yy6i5TctunoV1Lc\n/9Bueq6QrJD9sSCgb9vX+10ksw6shVtfN7XRuhvTMeDkg20vHcaOiuRnv+BP\nEw/ykMs51m8ihTfhIuDaz5V0ljS1SUipCcpYsdJlXa+cSAL1qsQY12dH+nYp\ntqZVTDsHBJntVLbMrpcYtyyTuMFRKUPGewp/60U+USbTJxEVf8ltmXCpmi+2\nfpQp\r\n=YKWf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-892730b-1613395699386_1613395756278_0.17654301771182412","host":"s3://npm-registry-packages"}},"1.0.0-canary-04adfd7-1613666330276":{"name":"@iadvize-oss/store","version":"1.0.0-canary-04adfd7-1613666330276","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-04adfd7-1613666330276","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fcf80a51b8b41486b8d18c31b0b2892db686122d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-04adfd7-1613666330276.tgz","fileCount":7,"integrity":"sha512-ly9dHpwB2A90WwPmtBgZnPY1Uym4xwiy4Jw/WZa2Yi87DsOILyq02ALn1UBdI1QSaFgVaEN5dFkW8kWc4ESmRw==","signatures":[{"sig":"MEYCIQCL5KwjpSOgach9FCdIa79/adpjwcQy6QyqtHxy6gvjfwIhAJQy0JE+LqdIjo2gJzHNOhVLhNazMZULskyUheIOgokc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgLphSCRA9TVsSAnZWagAAIrEP/1SCn0Z7jfL6QLyWrqGR\necZ5DmZHL752MKOgT0D/xvgEj/WfbRPSFBhOX4gDmN6807rfdFjbaYb4olEE\n0fvbJ3Z7v8XBmOjEl3aKBo71Rd3Aa91damGc0aZu70N/X2Z0z59WQG1z0bpt\nuDqkAj6pGPm1eBAQIMdkQYcdssA9ETLgMG1xXIBnIROsxzDa4jJbecNFwFRT\n2SsKOwQPt3a6yXSkrk04ZfuZMNtlAH2eqfLCu3WskYECp2eD3m18hbVwEHfU\njStYUDqRpOsG24WESrfvBdid2n6fwNzCWWn2xVMMcGR0PXbd7B0BLbiZAix3\ngYQHV95aDcLg6tFrVImlXKqXRmryMDtLa7hhBdLXHFrQe0Ag82trwoCQZYno\nbOLmfe6dLtDKK3uueYzHMW07Hoj4OrpIow+MtaWsax0RW3q1drK7vsQB6y75\n+/BhzZ6ww25IiYWV1dg6d6SQpxRy6LBdc+JZ5i1Wi6+oaMRnbm13EnM0sBu0\nFwbpprzHneex5iv1qsqA/7Ku3m82CIqTxRFNBmJrI2EjXKw6vpOQSLZ8+MEl\n44C8nQyzuqDmBatKAq5aRELunmXvWjoxW4+jIhl0odV+duKx0MBvMaAiFAds\nw+m1BrbHZB5ctA4NRe4+2+mle7Y/MsEgXOfJ4yzmA0LHogzuGYZZpyci/cln\nc/Xf\r\n=gGOD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-04adfd7-1613666330276_1613666386401_0.5956146660745749","host":"s3://npm-registry-packages"}},"1.0.0-canary-04adfd7-1613666329426":{"name":"@iadvize-oss/store","version":"1.0.0-canary-04adfd7-1613666329426","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-04adfd7-1613666329426","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"50713dc5f0ce2fc22679bae28af8146856fa8a21","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-04adfd7-1613666329426.tgz","fileCount":7,"integrity":"sha512-WSCsMBTH3fXUvYNaVGKe9zolC0zoxXsRX8FFCfXySNTriDIlnUNjtm7/ywG5gesrHjtR6ol0lP/cMHqTE2Wqjw==","signatures":[{"sig":"MEUCIQDWEDM3BxdzduI18cZfaWG3MrKcIbwBisW6Fp1UyD8PSgIgNCxQiV0RT1nOZnRLHMuOQcFBZCNbkw5Sut/CBslLK1c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgLphYCRA9TVsSAnZWagAAxqQP/R7pihSu6cZgMM8XXJjA\nUgmEh3qrgtHOiajkjGDLVLsQe102Wn2ytQTwd+b4uLnCYjYaCOxMXU05p7Zr\nHZLEwEDw0HGaRP89Wiz8F1Fpc2m8XtcQhUEqyQ2OTfRy3zzhbVPqnBj3f8vU\njQWbFVzbMEJbYWszUckzm1nXWFjn/4unIHiHbZ2zTqCuobkaUynll1SjivJ4\nKe5/C8u4ob/keCcOzJ9Np978cv62BJFMEzTsJ+IaaWVUw82gwRMCHzCtgAr3\nngEBYmrF4hcXEETlWmWTZg2itLKBftNf5aWA0TNqSjHdm4hnqQkN5jXZTBUZ\nUBuO/WZgRWyLZzFWWDMCc64zBNzUS3C/0mFD3FjyPFF9b6ax4RD6HEY2Bl8C\nkBUgNb+og2mZmKhBU/fMPUPoCOY84hOFKM12CZYEOp9r38jXUgsrddhmeJR0\nXHxoZolLWsDImhqse7htTn+3LueUgyEk3sanGKkXYq9oX4cBd7GYBpEKJ8pB\nvl+fsV/fZqIVKpLxdjw/NvnnILm2vmQQjvqDh+CnfkFmv47Ov3bcJ4aelwUO\nAA9MoRnGx4ntV3Y/VaryCxVZqW48VMhbjWVxCgFAHDLq6wjSOWg8bXld8YSa\nDWXMDEDGaEeXYb5aRaU8tErEJqU4qebmzpE3wX0m1y8oySVUdsjJ24XtuwQJ\nYNQ7\r\n=G0OI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-04adfd7-1613666329426_1613666391828_0.2158013882444061","host":"s3://npm-registry-packages"}},"1.0.0-canary-481c081-1613791337573":{"name":"@iadvize-oss/store","version":"1.0.0-canary-481c081-1613791337573","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-481c081-1613791337573","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"182fe381488b3960fa7f8a5afe498e4942e36001","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-481c081-1613791337573.tgz","fileCount":7,"integrity":"sha512-nDWkfLXcn/Y8LvP9GC+ye3ttyc2kEjwjpLL5MJOk9ODasF7hxObVygyiXwjswKZOddoeTG8Tc/UCRXegtoyGug==","signatures":[{"sig":"MEQCIFoKkmx080/eo/lknsTiyuJnRZIRIqQQ2qiA5vNfr5PyAiB3a8UwMIYDddr92DI2nJc9wXtzTCR3YG/09p6hpcPTow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMICcCRA9TVsSAnZWagAAAEUP/0/i/dEa0hJyhb2RCnnY\nwdjypSHfM5wPo6l6bYIfqNn0liXEH6zsQtHRky7ygEW3khkaRRNIcybkBC5V\nmILdWc0fjvWo64vp2+M1OMDuPn/DGmGxDY5Xy0qyeKogQ+nF1nvuzoBgRd0C\nzuADeResU257OEal3vFau/i2qdxQOGgOPACFnRgZO3Cb7dyY+gbFS3L4LKD2\nymTkvD/vF+K7/eUhvnAIyL1f+UuZ+Tdf+p/SmbwlYXb68qioAxnnRIaU6jU5\nWSPovpOMu7cn5lzjIvw91DK2z8EHUKOGahFqxjjNgsfeTe+gFMTjFDM6P2Pv\nMoG2EgFNMgKS7hDKXG1zkbTrihfc6Vzdo6mHirrYJzynvBqbGAkxJf5MNtyf\nSNjfZw/qoUru8I9k/xKuT0Dx+JCwMlcbbso8a783gqG6MQqvZLk6Z5S85OdZ\nhzpUmSWNQRcU1LBOeuDgr5+GTFGIPbB6yiUmbHmytDCu69cPj4+EWazobbVF\nveoQujWxxihL/c6Ns+EKFC0TaaUbPuZQZ5WFS8RuXy4eT1bvMWfg1v8b37KA\no2rV8sBxCRZKLSueAOw6Zx2L2fVzJ86aV50T28KCwzCbF9rAV74D6UtB8vqq\nzEffgQbZsz9UyyO0NWlPcTuXT0SCDjTI1ng2pGtR2HQsLX1NNpFUgO8TgF8G\nybWT\r\n=rpC4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.26","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-481c081-1613791337573_1613791387993_0.9438410546396823","host":"s3://npm-registry-packages"}},"1.0.0-canary-0fd1a82-1613865686127":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0fd1a82-1613865686127","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0fd1a82-1613865686127","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0f2131124da56f786153cf3f2d3e9b12440b054f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0fd1a82-1613865686127.tgz","fileCount":7,"integrity":"sha512-Z/tjcz4eonyzQVypcfEYxyYHhcCv68NXV50oRBoDZh1oGXUbP3LB1zwPvQVa9fbYA7Hqxu8SQ5/6f/H3NZKpVQ==","signatures":[{"sig":"MEQCIDUpiUMVda5/ellXOoC6yzZY9plkFGb9LTRydq2zj15EAiBlnk3IR4ZTzH5sHjBl0D1Sma4aKB5npSTFVnDfj8RKGA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMaMJCRA9TVsSAnZWagAA3RUP/1YrHr2eVbjcSZ0+A6WJ\ninDTqCC7F+2jLiNIW4ODqq4jbXOVrLZP8woHAdFZomqYiqHKxV+f8N+XDX70\nONd3ix1/xbxty8ivqaprRfjNJgqbZOSlBdqFfOxaC8Oh3HWjnHT1WXzmlUjb\nYPNWxzq4qflmqR8c/8HKHt5CteURMKOxoAcaUNmF6VPe8WRWJ55UJg1io5uV\nU4j29tYq+ELegy0RI1f0xi8I3gSyvwYwM9ck/ETizDdnUzlHZckcf6Svq/T0\nEjguifHU03TraVOHwwASIaVkEfPP6PbgdXDot3Ho57art5mUn4gemd3fKpAY\nVVxLsOqBwtgBfxZjSA3snGvTIc8CzwrdeLQkbkiOg2i5DYHDMbUHGrsP5VPx\nLWJqWROgBicZeso2nc9mIb4mk1dwdL4gkQ1fRLgrE2F8lLwYf4EMEn+d7l9y\nwD/WoaH12O2o5eLVhkoWPEWtnJsBfDlkDGZHHMnrUK+qWxpc+qWLaE7PTCFU\nZj1/DSZYT/rq1P8gz77BKT56n4P6Vgk3mUQwekua31J+Sg9Mju6baCjNDZwB\ngJAqnhcsO0Stbv/9aJZ/lxgf3nsBPzTdBrb/3RvI4htohTlrSKwvEeL7OaN9\nQ9rE8S6YzjSgY7MvQTqMREHd3sFVWAHrKnUj4sLDlXuy/2nYXM2eHccx6hXx\nGcbs\r\n=n8EF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0fd1a82-1613865686127_1613865737345_0.5547334789661662","host":"s3://npm-registry-packages"}},"1.0.0-canary-0fd1a82-1613865690349":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0fd1a82-1613865690349","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0fd1a82-1613865690349","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"adfce8c127ecee7ef19e7163490601a8e614bb53","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0fd1a82-1613865690349.tgz","fileCount":7,"integrity":"sha512-AXMnEzg+1WYSqw8g3vypOd2S9KWiR7J0FamwHTMxrwhXIWvsIJlXACIOp/lotaU7HAonbD0cvi0TB9ZF740FTg==","signatures":[{"sig":"MEUCIQCrZjiFfWonZ9F+C8Vxo3J28f1BOGvP6GLOmf6eVnDd1wIgRlzIA832zks4teGBiWsMRcAlmEuEDTS37gSH3Qegpt0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMaNICRA9TVsSAnZWagAAvVkQAKIMPMgVSQ0AJs73rA6S\nBaLTTehzY6E4QatgaQ9QrrWyA3CnrQazbsHhTdJYidXVhgHstQcG+s4Dcb0q\neEFzprCBX+U9Zbyxks0HBXw1qJwXOlK644qLFmjIHcCAvMy2jHjwRLxmAWCR\njTvG1APxF/m/pVIuxr4DcWekT4QwA767EgiOkH982L7fBlNyHULFjK80WY5w\nl2jcStewsQ9kbkgWWGQrPqIZssQD1LhFImd4ood2zxWaMtqhmxufR0OpG6NM\nQr1ufGg+O+ZNQZLcgUoNFk7rNaySRLBSInTbsUkzURSTiR/8SKuy3FXKuKk7\niETo6Ra7lkI/02+H27pdu3Vr+H2inZlYdWF9kyFt4Gu6JCQtu01+BLSzlX/0\ncarcHx1ZwzZUYPMAtq+dTDKhQh+edzmQqST+OOqONn+UexkBLfHeqSfQZFE/\n9bVAOwMqy60gwIKEklFEuqWE7qABlYxpTOI0YTz62HVnbo8sflQin3o2qjU8\nHCDZWJDOuKkMlt7E0HufncJLSStrcd1NGeWOvQynOLexUhJ0dprVWyDChCnX\nBsAkIZMrCoXr0y9xtVl7STKioz2Me6BfY8kQI02gUtjFwONxqh6KgjQs/82j\nC865Z9mCYLgiP2qmCxn8zg6Dcu/0JE0QY3Hsku3KYPB0TI40Ctpy5bPHK7Kc\nT57d\r\n=ClRK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0fd1a82-1613865690349_1613865799873_0.9362432693811693","host":"s3://npm-registry-packages"}},"1.0.0-canary-e829452-1613984333023":{"name":"@iadvize-oss/store","version":"1.0.0-canary-e829452-1613984333023","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-e829452-1613984333023","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6215fe72ddb65f7b5f459857087e9c78c85f46df","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-e829452-1613984333023.tgz","fileCount":7,"integrity":"sha512-cGWzkDhl0gJ0B17A6CW6hSIC4mjqUV4xyh6hhpskkF5aW7Yo9o/HS/ZxXfxKp024KziOXCyzaT12hJ2VB8+UIA==","signatures":[{"sig":"MEYCIQCOeeJk6Be0a51WgGIwvhbjNUl9wULpIzgLE6WHUUQBtwIhAKgiqMYTyHFm9GDlAdU02t9Vbmbdoe7lFixpUkGvJAAM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM3KECRA9TVsSAnZWagAAhGAP/0VW9PyrLT6cRg7wtla8\nUHjL8GP3yhjjpi1WhCmmqWgHKCMk51+sVPdKWJHMbwjDUhMnzkp5sZwm7ly6\n0YTKwlDoWwSFu6fdG5+i1DmGJw4EXd/lrijVSOZzoqBbkWugEeWIQyoNZbz+\nYp9fflaJKkdAInpwjIsB1v32ZTahX1wOpydKkAyOUyx+Dw5RjrOJ7WYRPWQU\nYQiKN0/kQ0uw6oBnepfmFHvIzE0O+m46z9AsLfu7fMFy8BfCEj7I83Hg5TKP\n/WpYSeiEu6RDvgowqNbvxK7SJEu1Q/4EWWbC2SU4ZUqVihf5/f8Ed391mwyi\nFdU5oPaQs7xigX0pnjVRk19eN6HcyTnrHBJbfEsERBeRfhuikZ3LkAOB+scc\nciWMqCRNz8UTanVLegDfOKZ7klsfl6K+qybFuSxqUj9PinYN5Up4K8uvTrWJ\nNJYLb6jtCmZQ9ipXohxzS565pcnHKa9GesK+7cj6axokL79fAthQ+deEbgXK\n/pa1OUfLEa2+kqXQ7X/wjMB1sJPj6/PH1fQ7PjhenVoz8u1o5FlUBct7sZ4M\nx6YNb3sL6eZqKJIz9LT4zpcQXkquib2jbyNS+Ev/DLhiEaVipv8ArrrQ2koQ\nHNTNb22xIz4slD3eIciGbzJEgU9jbn0ZccwcubCJcXg5dtKISlCUwgSYU70A\ndDxh\r\n=fhdX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-e829452-1613984333023_1613984387943_0.10485928545064738","host":"s3://npm-registry-packages"}},"1.0.0-canary-d70dd1d-1614001736375":{"name":"@iadvize-oss/store","version":"1.0.0-canary-d70dd1d-1614001736375","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-d70dd1d-1614001736375","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"db39bab169d2b068937cd952e6d10755c6f9f1f3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-d70dd1d-1614001736375.tgz","fileCount":7,"integrity":"sha512-fKfIPbIu/jXE9h0pkvhE5akPXYcVamJxcEmhaPmz2TCL+TWaxX8fOgpOd9DmR9NiQc/33lsF398BEEq0WOBivw==","signatures":[{"sig":"MEYCIQDm5ovSq6FZWogIPUi65M1stV66qtF69YV0X4P65NmcMAIhALgQaqdsN2+E/lHayVkavy4CvpSbcq9e53/BUCeOLR9N","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16750,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM7Z8CRA9TVsSAnZWagAAMFoP+QDRKanlae+x5F0zTKEH\nflwgX2CE2oNPqAoRHvy/QnQpZMit5jWYnV9UMFondhE8mRvuhTwdHG+tS7Cg\nFKj2w/5USz68Ch+TFwLw0Gq+IYnEHLzgrMaFyaoRyAiT6E5dcSbH6o4F3aDS\no1LGzLZriIEjIUAbmOn1Wi7l4wHwcRQhYB5I/cQVEYBXZ2oxlOPnsRbeK7xX\nGvDfttiQ2mIdMRvzBclrPMSUypsnZvwlXHqUE5GQdQFuE33d1RDWSLAciXM1\nHXPfDtxeDLUGJPp7m9A81PF+GCB3LJ4T241jTJNWTIZvvUtdaz69dpN8BAp/\nVs79VuXQkq7KKIBdjCGPEVUvs1WLk2l7KMZXEE+UgqSe0RZ8lAyLIbpGqN2N\n8O4nrOYc6XZiXnFwwQ2RG4I396is2tXbFbWqi78BQeazeEXmc0gti9Aa9wvv\nsROtDASNXh+3kr3yn9CwZRc7t9iKXh7CIbsfUKRNrOZpCxXK8tWlEO3Kvwh6\n27VfWC1lDsu1l94MlrMPECKsu/noKajJiIHSHVNJs8B4RSbLkh/nkhNxiILW\nhxIHCz+9jP8xE1wbKWQIBRm7hHeishuO0s+cLTlfx2pdKyOC3gBmfk58jA3D\n0awDRAX036ilJNpNw5uhZgZdEnguFkQlFXB/xsS76KeFOFNF8P6u6vlaC1Ab\n5UDr\r\n=W+Hq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-d70dd1d-1614001736375_1614001787365_0.38670293288617796","host":"s3://npm-registry-packages"}},"1.0.0-canary-f10fd64-1614002829344":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f10fd64-1614002829344","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f10fd64-1614002829344","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f92e06f8fdfe5ce828d767f74cf5d18ccd4437f5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f10fd64-1614002829344.tgz","fileCount":7,"integrity":"sha512-Me90mi7ARESFECTz7NcenJCyflOR1NRi2Kz/SLi0agMcDV2opDVz68HKIpsx7P9KwfCUKzs+lP6UFjxD9txA1g==","signatures":[{"sig":"MEUCIFcvCuaMiY/ansux35KhctCLCeCXzjyCLiS2wA5uLjsoAiEAgTshZmQ+W2YCfINgKEuzzWC05TKh7Wjhbuw8BgbHL+0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16773,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM7q6CRA9TVsSAnZWagAALqQP/0aXZcg77KmigNpD5rxz\n1Ro8sZP1r9CYHrP+OrLItUBzQxLMA/+BIxIiFcAKvPFPAg4azTRO+uAkd1pj\nAoZVISScgFnj3PVZuxapPzZloaC+SokaLhpQ6qvatDxN5Xld1ImEjwYU0L2t\nQRk8rfjULLYq6pmY6ulYBxLEoCa0UbNbX4LZF5ox8QTN1NAdd4CPTPXlxm5i\nECLPVo0afboknhMbOCubNFLPLiEr7vZV0TlJFg2xkCpHpptAtfWwZ/O3STGv\n1PiAy9oRqBKH8D7Df4qCAOMjRVKKyDBswbLYhrG5CdkQzm2WhpKLoM1dyyw/\n6VGLMPH6blYSo4/EYn/mYls3xXjlNAPkVq/gFQ0su/tnFtXx6z0J9SnAe5RO\npLPr0VaWf9JcVn7UQ78rBNxbGZqerm1fVVGHPSiLS87dH6CtlgNvr1aYizRN\nHxxxFTfi6KVg38yTJK36bKw5Ew552Wg6A1AFlF7GaruU0CqEsSRyDL6BnhwG\n4fWyt++Vx7Rej9iUCH39Cp4cntMFCjRHxF0tyhLXbls03wZ1vdPgOXI7W9Jc\nnldU01LINt91EALceE6+Z1wuy28awEA8vP5HlD8tbI1z/CcPcauqaEv/zkkQ\nM6e29jNXgA5HH5VdTln84ibO5vArcn5dqjnliaDxO1Xn9FSd/bkVkP9URRlx\nOfHF\r\n=tSsE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f10fd64-1614002829344_1614002874098_0.21040798185000797","host":"s3://npm-registry-packages"}},"1.0.0-canary-f10fd64-1614002828692":{"name":"@iadvize-oss/store","version":"1.0.0-canary-f10fd64-1614002828692","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-f10fd64-1614002828692","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ddd1c75ace4af3789bc50dc2c5114ec586faabc3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-f10fd64-1614002828692.tgz","fileCount":7,"integrity":"sha512-GDOIEWYhdhbFMddPFcxKBnddPElTigmumSOIUlWgKO8UJblNoMvctSQNNIuZIayFnlhuuBxichTIOr5vMA8L5g==","signatures":[{"sig":"MEYCIQDPQ/ZxPZmHafcWVo2444T2RW6ZlCAKVPFLKxMdMUGa+AIhAItv/WqBQXv0rPmVd0jS2DNaV+bl9ywRWD7/J/+9kt7N","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16773,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM77QCRA9TVsSAnZWagAAVvAQAIaHhuJ8awtPU0SHoaxk\nWF9P+q/VifTusnL4SsOmYEKhxyU275bD4Tl/H2IRjydfUpStIj0tlyEP74mc\n5alZ1R/g03gofDB72PO0C8Y9dIC/C+6kYC5Hs91aQykFMFKtV9JQIb6nDL9E\nqgu4TxlNqQmqAQVUDkDGXNx9Y6zQjKVgZeTVMiGw0owzsmxIDmvj5PckD0+O\nqSa/uv4YqaXTxyepJ0XG978bs56Rg31T8mjukSE7Wdl6egC8ncfDETZAbqUJ\nLjEVdfLPPys7rvydo4EUArws2NafH1DfhnkhPHgQYade+ZA1sPHx/PU0Oam+\nNushMEs6VA3QNAojlAGTHTcT1PrJzC2fePiUjDeICziSV1HhIcNHY2LD0u63\nBVLbo3+t8beSXEYHdq4dMb5XkfMRfF67AKATqs9yBm7uVQKw6hJgO4vlosfH\ngmKuun3E5X+VOcM1/EgZzag7qZDCdAOYKgPRpGxf6ij6Uw6erU1A4VRx3AOG\neapMrGsCe3cTy0sLMlXpuHXRh83iYYlhrEUCyDbcaX8nBHR117Ls7gC4xyLD\nGallhLBw+ac4a2y2G9L5kcML/b/y6fEfK0tm+cxaJFhyJEY3ZTG+k1T6PgGy\nyCZw2gVTkwXvKo8kvdhfLdEIMSDdQnIwHDRd3+jtIRwzD8dVzsa+IQ4AqXdQ\nfcXC\r\n=in9r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-f10fd64-1614002828692_1614003919835_0.9472410197746317","host":"s3://npm-registry-packages"}},"1.0.0-canary-a2f8ee4-1614013287719":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a2f8ee4-1614013287719","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a2f8ee4-1614013287719","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bf5521d4b3cfe8b9acb32c0cd6f123e841d9d434","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a2f8ee4-1614013287719.tgz","fileCount":7,"integrity":"sha512-sWRlyqqQYVM5KrzbG3BL5hnhOb52w8Ve5Q7lIL34gg5htKnRcaUIWDPZW0JedklvdBUkbZV1uYGqjGt0FDZ1yg==","signatures":[{"sig":"MEUCIFEjWgiUE2HtORwv9Riqa84MUN7X9OFLBjITQ4rXJLGPAiEAuHRpEYnoch6CWCs61J39KonupdDB3XTEkbMlMgdLoPo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16786,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+OXCRA9TVsSAnZWagAA9/UP+wSp11QpB3N7sYHr/rnQ\n4dgsMvCMm/sI60hVUDaATj/L8tsWLeGMW7HYkHg+Jm9YxwK8nOazJMnK3omG\nrlNqDjcJj9lfP49Hd0zwRUTee6Z/smIHqOIkhFNpygTb5HtjmSqbViVralJP\n0MApPy1K8GDddocwdeguEsbwS/LHl6ERL5WEKW0xx2hO5vYd5klpcX9H7AQC\n+lwKQJyl4umxwxK77YgUj9g9Y2xhGvFW8+Qoqon+RBkhxq1uQIHALYlLCBSl\nfsfv1bi5+BMTAX4zNVi8VdwhJrDImKSbSo4iQ1CVB3X1DqdGwZ3rdU9yff+p\npFTmY7GvwOewQ/rfGur7LIwCKig8YFz5CGYZyfHRRbzdHZoDPxsAGlRXAW38\nT8PxG42s4Pzem/9hlJzTq2aYlpbpIor2mZnm1z0OJXETaesddefDZAQP+vOp\niSrNrS0LhJTxfrqNKCG/gH6V7n8gnfH1N3UP1EZjjVIZRljS7xlgcFFQ4ysH\nqLZtuho1zYJ5FDex6NjC/a0SFIIuWCsdf0JktsBIT+jF0N9RsoT60k3t4p9Y\nZ9CUjEi/wKgcmb3GvR1oREyT2KJdbAnihf5OL6WtLLNr+cULhNO18MYzO+3x\nVvqql99Br2BHtO4zwi/cOOLqwiE75gC/o8EMhwxV7SqaXQ74Emwc1cVDT6K5\nwXZI\r\n=OVaG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a2f8ee4-1614013287719_1614013334935_0.48636525666977426","host":"s3://npm-registry-packages"}},"1.0.0-canary-a2f8ee4-1614013292912":{"name":"@iadvize-oss/store","version":"1.0.0-canary-a2f8ee4-1614013292912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-a2f8ee4-1614013292912","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a566bfaa811c86a72b22e0718fd429a62555ce24","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-a2f8ee4-1614013292912.tgz","fileCount":7,"integrity":"sha512-TXRN1zDPAlRVOnYwJUmmmGAWxmgBv1EIUGeCPaTD7brqH31Ph3MK99Ladt0UUoFRUq2OmPDVMNqrbDrBoWPoTA==","signatures":[{"sig":"MEYCIQDwLoiHaeSarwN4Tx75N955tWdqrIcRMswQistozbVxAgIhAODulBl35mQUZwN7CsxL5+JiNlRCfkSrwUpDOXyjdr/h","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16786,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+OdCRA9TVsSAnZWagAAw3AP/3VZx+7fwjZHKRAFPFCR\n5egL3Pcn2spaZAyL8JupNG6ho0cR6D+sdmwF6igv5fuSUpLi123vTZNqAp9I\n9R/+sefQJGXNFPUl7l7MzalUWs5HbNN/qMQdSD8bzmsHGQEVDkAFbleDb01I\ngW5jgl2MYu40c6xGSE0oS6spyMykYaVZoq2c1GdE5aeHScBPdX6idobCtKm4\nNA5aO1gws49PuEJr8unC7QEML2rjUw2T4QQ1khNyH5895jtEyhRFJs2KtbUb\nuaI+ATTJc2sum6jExqnK4C+BFerxXwQ7O6E2R4goy35aAS8MZ/J4HQkWTmWU\nNJAq1KulVu1SPwLQk2zBWZ6YLgFRXS6U6tItquENzRIjQTl7Nvx8xGtuVLWr\n8PRW+GYoFrYkKXdplWKNquC2kZIbFcQYo41Q6zW4KQBs9wzvT2H+uWs79WNv\nUt/ydtnA3BZvtcpFVKz/Tjui7lcdmBWYabPSLYEg6Mn+HSj4SA39AHpnQvs6\nmhbkdCqYs76ViyUppxj9xGtedN04U6prMSB7qYu4dNxCj3McHGHrCZNvIvSs\nVgDKkft9rXaik+/9CVpJzTvdwI8iEy2c6zaLzxs4O8MtqPNmCNbGEj75aryc\niaWXcICXwnCuShtUuUdJM6s6FYWZz8d+H5CK3JeLDtjoItdEGgwEqS2RCkpU\n7gkm\r\n=idv0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-a2f8ee4-1614013292912_1614013340927_0.94656337012839","host":"s3://npm-registry-packages"}},"1.0.0-canary-3683e69-1614013500069":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3683e69-1614013500069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3683e69-1614013500069","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2520d8ee984507b9978cc76edca89718d160a103","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3683e69-1614013500069.tgz","fileCount":7,"integrity":"sha512-TF01rq5yXVBCpoYkYMb8vB9xVpb2arr6KQ4O5gCaDmDztpgJGCp+hgc7YYQYeqKNvqlwRUoUryKIe59W6wA+SQ==","signatures":[{"sig":"MEUCIQCGW+Gr0zx0/+eE430syxhwTssTlpY35Vrjv5axG9MpEwIgCH/XLpw8p4LOBwzUM8Rnq6cy4k6/8J1VKopprxj8kBU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+RqCRA9TVsSAnZWagAAMV4P/i0haqrujwpXv2kZW0v/\nIh9r3xfMYZ7hCKiVjxvTQwtLEO/1XFfxm1q5cmBxDc7Jn4dxYmhipD4ckgwh\nEnK48d+eRYZQbIlTPZt/tNdl49yP4ZuG3rQRYLxUw2EZ4xUWS4jWLdzYZl+M\nH1LWNuxNLVpUr2DJ7rNnFdSBxJgntNQ/PPxHYcpf0EhPQzm1bh9rObVg8GmK\nNQ83fAl5CIex8U2dHkxzi1M6TSOnH0Z2+VYEc+i0inSTe+lrGdHWuV5JHAzP\nY65vRT4jUayJnlJzh5m/zDLLhinXkIP4bsojIQ7WOmkQU8hhRAfbXjsqDPDT\nP0q65/ggS2+IZrrh8ZXdThmWGmwirybjez1HLpzLumT76DeILitqz2HwauFs\n5OeZu1odBUyvlB1IWFoi6phunWKkbIMWmREItb6O8T8s2bPm2VM57RsZNk1R\n592s5Xj4HwvOtWDxL/CHGDUGJXdkQ+6ZVBkgTFPFoZ2172CJJXds5pZtppXw\n8kS7x6fDI3AS+8nZE38ugRGT8PsqBrHxtxkHlgh0Ol8+roJti0JLJvHRoOax\n6NQd3ov1+h0dahxOqNWPHvMWJKirLNJIWQ0vPrS9XllGGkpj9nhJDcvSopWn\ny8sT150mA/raaJn0aax8kDSC7hZN0a9iHP1j3oeoJ4Jr7MnXFoQyPODRL9di\ngGxw\r\n=0ZHn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3683e69-1614013500069_1614013545435_0.8589492116972182","host":"s3://npm-registry-packages"}},"1.0.0-canary-3683e69-1614014087501":{"name":"@iadvize-oss/store","version":"1.0.0-canary-3683e69-1614014087501","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-3683e69-1614014087501","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bc2c15df8cde0db414e0488e9d71982eb7ec168e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-3683e69-1614014087501.tgz","fileCount":7,"integrity":"sha512-XEFfarcxm3K5T3Luz4IzBRdr+SuRDE4HioMY0+Hb1n9Z14v95bRtVLCSXy56rmvVqk9eS56nT59d9KdnsJFQgg==","signatures":[{"sig":"MEQCIEfUQtFZzvnCXa1gleSC/8iUTdg2eE6ENvV0PbISzF/MAiAC/VE/1PKe4b9mhJJK3Y79xWgeqJD/b85IzeoOZqOG8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+a6CRA9TVsSAnZWagAAC5IP/12+TpqSUirRpB67IiKW\nde5P5VXyh88qrm+VOs35o11yYg/hqTdrIWbuJkb0rgJq1hmm8bBS3nwaPu+C\n2tk+8NkHRnefwdGuxkkrsMWet5B2zvxqb2S0zqPEfh1LVcQ8V/DpEyG6FQ0h\no17r9p+2K90m0rQ+apT2xD5hGE0CNuJEXbdbWmF0R4XgxoD97y85XyRazTFO\n26Eu60GHY8YTEapwFn/PZJRGQsAv4b4/eloSMdJWgBX7HXF+jf/GtTuED+77\nQYy9PUNYsNkgCkyla1LBYGe7oAg5YW7uYEbwYy73DWUoQUQoyQWPznid91j5\njkJHL87+34W4kfclUkfw7J64r/p/fjOVk4eUJPTl8JB81sval/O1ZPBTq1Tq\nNxqoCfiJ71XfJKERIAHB55lffiXM3m7Au9AUw+E4TwYcAHAv3k58S4v15cUH\nExLp/D3/iO3Mi6ijS13WlKR5BXN2YkZrMAgIlP8dMSWbu92bs+AuW2Eltv8g\nkteXTspRrIB/2WgNZJ3QLGjipJ4+zIs5/qQ3H7Tcu5LC43PycbEDNKEgnuwK\nJiPMcW3OUrv7imRQEUH2CYWQU5OL2mg9f+GvRdbjssusfQRdUulkeY1iouyE\ngJk+VFV/I46/ByCkHrctUlrJqu/M81NIoQ+2mNsadZ4FxDO72U83PtRVsCDy\nGCT3\r\n=Xa8+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-3683e69-1614014087501_1614014137607_0.05399227916087157","host":"s3://npm-registry-packages"}},"1.0.0-canary-0b9ef8f-1614014140520":{"name":"@iadvize-oss/store","version":"1.0.0-canary-0b9ef8f-1614014140520","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-0b9ef8f-1614014140520","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"03a340ebc2dcb050338da00315a7f86a38e91f51","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-0b9ef8f-1614014140520.tgz","fileCount":7,"integrity":"sha512-CQ5SS+QHm54lw5KxgVdVZsl+39mPMrtzkLwzzeKdj8xztOiixe9RUFbsiMyFeAocPg5F6qMcQZW5YpRliAHJhQ==","signatures":[{"sig":"MEUCIQCZBA4i3cTxRDqG7stk6Xt+dm/ORhY+HxikOnZswMpblwIgJ6IcVJsYf/D3rNm4xhMgTenhWhOA7JPbvFemxQFY6h8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+bzCRA9TVsSAnZWagAAAysP/ik5tK+s6oDsGbIQXQ+g\nyS93DUkR69hYINFz3cS7LkPggKmC7VYrmgFZC7LnmIvm0qkXbsD7t5W4Y+8n\nIGyvvf901YjCPaLW2Ejmj/sPKwPkYJRp3rUMsL5DgtZQwWoKn21zs25jV35k\nM7X9jBB3YTO1cNQB2iqXWJ2SeZ2yk7qMCA2thGLx63Jrf5z0Zrhd9eKqwLFM\nKNsoXaA8R3FRLiMDfpenPiksaQVpCStmBIJLYp6ageDCPycQtRAegIcDoOOM\nlr/sIzd2ifPMs39EepyKzUaQ08lMUMqHUEu3HOnZRmBvK+ryoDedMpJKLyxu\nmvQ0EqqQTMmMCsTKCkwFzSfPZr0wtkEODb0zEzX0JzaRNIjEeEt0wftKmImP\nHUpRtDadJ0Q5sBMTYWbZXIrm23iSnE69voBE/Vbm5JomAMszpJhe4YCveGCi\nUcxPcr2wsTAfqnwVYeLkk7lkjq95rkdYLXWhOvxds65DwHVetkMjhTY/+ecO\n4snGHBZ85zJ8ZbHZOR/pebxjWU1kisKjiY0mRb2ksZV5CZEdT+JnLgF61p8V\nsFZCgGlxTJ4oiTF2vHx9RIGvQ4BiWc/K0d1dLwQsYvqUOC1PdvduvGLr1f2Z\nqJYKLe9XKznJP9F9v6X6zLzcvPgWkh2mFilf4ZxonpQc1KZLmtJY49PkRxFx\nt/p/\r\n=ji19\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-0b9ef8f-1614014140520_1614014195019_0.43209856356726073","host":"s3://npm-registry-packages"}},"1.0.0-canary-43621e5-1614014751171":{"name":"@iadvize-oss/store","version":"1.0.0-canary-43621e5-1614014751171","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.0.0-canary-43621e5-1614014751171","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a46ee02c6e21fac8f852f3f4f93d1c3c6e7c7380","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.0.0-canary-43621e5-1614014751171.tgz","fileCount":7,"integrity":"sha512-ezN/ydiBOHGg79V0EUlyGr3cmXaAaVdMr8ZFKodohPm1GrlkQ4k9F60mNVYWfbUxdWEfBzvnoBv4J1MEuMTM9Q==","signatures":[{"sig":"MEUCIQCZo7jeXQfT370R8/6r/MHNjmccUvn6292iQjTqNzDNCgIgZWi7ilN71bfVRcc88S0+/OQnmcVxu/GCQXoGY4zxpVA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+lYCRA9TVsSAnZWagAAbKoP/RQPFEjsCYuKMG17Hy35\n7OC1GYvLm35lGvQ60I1/73J8s2nmRTQ7DQQ28sCSvsk64dL8ryrySW28lx9+\nX1jOTLs4X2StzsRy8OCGoR/XRuXpc9fKutGWmP3B7rENl8OeSY2qIK50oC3S\nXZ+GzbW7acoLjgF6CYPkZR1dCAA9DBkJZ4ZVD1r5H3NsVCsVyEcis+ug5xwy\nxMzd0g1WEvjG/D7kVYLZr/J24+3k2oAt4b7zgZms3zQiSl8+yT+uWx9lETN5\ndT9feFO52lApUK2mchfgQjRuoyjTTEKoTIgv1sF6x7FLwWxfnUvo96yAZmic\n1o+2mDqBkK999xW42dD6r0FBkygGczDEdUl8YEhxkkwxGtmd/ZVZp1hQhh4J\nTTuD9A955XVx8xMQK5TpskNKMm2X9VswWUwXdeszvxAlTywF67OU/pBdTnEE\niVHtlfqERLLUtB6PBzEILSdty5UoDs+Nr7JufCpr0SxWYv7Sm5ZLLgOPRw9e\nLu6H64j4H/i10KwWhafmNYKpWn8xaGlI6tgx8i5ZgL6jtZu6UL4vRD3LhVqS\nsZtfItKyERbfrCI0q/I+NWKrFM7NLtyxDvXLz6fEg+l9kS6EkYMK30sU9y7R\nwdF7Ry42TP74eKJq8w0reBt3Cd9Qo5PeedWAL5fruepYPsBIgfTkFJn5SQzo\nf3ul\r\n=OJaK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.0.0-canary-43621e5-1614014751171_1614014807709_0.4019872059211871","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@iadvize-oss/store","version":"1.1.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b3d34ff544e4013abd6077127d507facb9160536","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0.tgz","fileCount":7,"integrity":"sha512-MU17weXu+MPdRXRe75v2hICSbguTt5V3ctwx/ygmpOolXmZw36FnyPi2nauVnoRNa/61vRKHbLwFcaBwOcJYsg==","signatures":[{"sig":"MEYCIQC6LrtShY+rKr+KzJsclyBi/kmb0UVSk5cF2YB2kBA9PAIhAJW2dmnk9twkbG+ONKMgTYepAX5N0wjGfZGkq6EXN7bw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16790,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM+n6CRA9TVsSAnZWagAApD8P/0xC2VFjDOVrrxTrDpi0\n9DZGtq8I1EJBLPqptZWeA4ffuyBFJhqlviok+6DKr+bOBw3NQ8FXQJW1C1ZL\n+3sx2qyUJPBd7sGKnI/1VQi/bmpcD6RT5vxH02lK0btYoVEKW53q6Z0A/eBc\nBSmlyul6z0c3UAKtxfAiXfSzyiV0XznIawi0+QRDx11BuCId3qaANcF9fQ5X\n2FBrvnEQxhFshxzYMqCeJ5oopdiN/Thwla2Hs9vg2s8xbRYP2FFgrPQRgOfL\nTBpRBCxp2G92BoG5S2IKpt1oy+63OJuSKTJBlGEyuwkYxM+O6JoB1ITSdcUs\ngRBZoKT8gQXxPpbHoGUa2PLVBQLY5UjbLVwiacSaTF8sNxSQqwD47nlR4ALQ\nDelrKJFf8m9ExVq+vAuOlni3QeDCqM2oQ99xfNKoZdtHPpUKQHDuPds6nas1\nuUqWaQvOJcHEMKM5o0ByNDwRJ4S4hl/wq3maMiGOI53L7uHWGqQ6EF51PLCi\nZUHqL0BvMpwNJzQPNPGc+Dhw+PxivxGtz0ucJIHhyoHAuaG6e42UOsGZN9Xz\nRm5CUjloTjctajNOcYvqENwTWOgOZ1gX1j2i9qfrRtl7lnjFEqc5WfCd/Xoh\nhU7hVVCSmhVwY5EFqcEuTec4ym1PrTJRf/VKW+4CAjLL4Nu+rzbzsEBERw8+\njNYU\r\n=27pN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0_1614014969989_0.5400488700869235","host":"s3://npm-registry-packages"}},"1.1.0-canary-2740533-1614045905592":{"name":"@iadvize-oss/store","version":"1.1.0-canary-2740533-1614045905592","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-2740533-1614045905592","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"37e733287f75400062a9a55f96cb9897e3321e35","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-2740533-1614045905592.tgz","fileCount":7,"integrity":"sha512-104xIiigPuvoMBZ7RGc2GL01KWHEHNJyeb2g8XucM9+QijSOdcN0ajiqZPIlLczO5ucX3KAVHhaj68b7cnLcnA==","signatures":[{"sig":"MEUCIE42+oblCL68ZmYH08diG4KPb+rpteSanP/fsrcF+SguAiEA+Xmrz/I6B4NOdfgdIHJHbnY4ohm+XWPMS9G29Batn2I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNGL+CRA9TVsSAnZWagAAt84P/0TfLUqmQPbEp0iVPXqa\nFyKDDvh78AENk29+u3JD8qihguLR1vgXjGXKsodVyMxFn2vDL70tbAac6JJM\nxIEvrnHrrRqXX5B6WSkOpDbLivqZCDEcJj11lxTkzIYk2GT0oyyQNIfsXmYd\n7iabkBmafzYw+COXm0O73ALYAyq0sG6Wyci4aK5vwpjoQLp4/+QGnwy2ITq1\nB8vxkmcdK4Vv1qlJHFdf7j9hdUP9CPpxFgjoS6joccr8ESFUVJU+nHDoyPIy\n4QGuhIcGs1gmuhiyCsyyx+G1bdYACcMvB2CeGXTxkfiFfmn03H7PvGZb9LSo\nS48e146iRGPNd9GCcVKvVMEzI/OFnnNtr3Zu10bB8B2r1lGCLbyw92lIX63r\nBDDWreVG7UuLqbzbx8l88K/cX6ICdrJhM2p1pb2p5F8MafaxIuCD4R11CW1d\nOdOaya66Eu/UPI4Yvdd1twvpADorG1RdQSK/1eHLMqyn+tqkV1SiMiftTpMV\n1CmXZKRdFmkuxa7cw/Cpbic/mkAWt5W94oYbhIWRQr1J410h5N0f6du1QCms\nWD89NitGzEahvzIAza/V25+/gm2gpuDN6hNtD21tRNOLkWgj+91qAUPism0j\n7nFVzfeCIBAFGhjjzrmvNgW0n9dk/CjtyhT9aIc3CR1xhfx/T9x4Ti86B2nk\nkTeX\r\n=SqF7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-2740533-1614045905592_1614045950248_0.3158824355638492","host":"s3://npm-registry-packages"}},"1.1.0-canary-2740533-1614045907300":{"name":"@iadvize-oss/store","version":"1.1.0-canary-2740533-1614045907300","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-2740533-1614045907300","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"76dbc89925bd053bf2e040a8d8052f066470801b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-2740533-1614045907300.tgz","fileCount":7,"integrity":"sha512-KFWUbac6wqteLN8QJLeEPJT1MqICixufyAMzR+9qMC7mjdNNUwpjvGkNoXSfx1FdWifYI79A0J939CLEyxfUbw==","signatures":[{"sig":"MEQCIHIOOLXbAjmrVVPwKY7Xqgrfrd/EcMUdimR/Th0IvfcPAiBBYimeBUHw37qLoN98rCstlOkZ7PV4sJn+0UeNk7OUfQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNGMGCRA9TVsSAnZWagAAJDUQAKKGvMqXMXHHBLMV/4uF\nL6489BPDX7gzKlNALUR7hq6dlE864Vd7fL8yGOSkU/pbyns2GXkm9S0bHEAL\nmD8Lt771cfI6tAJ2tTQkXDcgyjY8y+C5Bpf2qE5SrPyTvc253y89/LNyB2WF\nRfSTt228MrlIqqaAYEcP41jom+tjtgG6O+M6vFmdFmpk8lnvRrTVMAjwTYQo\nv4uLwu1kF+q85MmYmUTUy9e8dduY2d/1mXffMC1UzSsy8R2vagi1mJjlzfVV\ntoEjrYdZbwYesXdrY0yp/Miy94mOoxoR00ynegtYmgW1CmwjTyT49A3CXGYx\nYTPfj6QaO9wsVcmhNMqNAlklB3nsFwSCkyvbetMSUIhkuBQzDCIBKrU8P99X\nH1gU0u6XzY5fgo+Lx+9/q9k8rqdUXLIXC86yPmwP9ElZZF9wk0WEAPX6Fk26\nEWJ5EJPfATLl/QqpOorNfPrDhouCa8kKjLFMo0y2N72jKvUttmFMvR+t6J0x\nGDqYANoe1j5NXBpN0bG+gMV6EPtAyyEGR07asz8LPcrKCVAsi+cPeE4EN66y\no4vTPtOsaHb3LX0gQLSippmfOU0cyYz4UIgUAcJsYFsYdPkXYBO++uNjHEYs\niTxmqaos7XL28jUb/Il8LO0F56VqlNM0g1k18d2hyMwMOxeIhutbyF3LeKdj\nDclz\r\n=bVt1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-2740533-1614045907300_1614045958351_0.569260235528102","host":"s3://npm-registry-packages"}},"1.1.0-canary-7bcef51-1614074761405":{"name":"@iadvize-oss/store","version":"1.1.0-canary-7bcef51-1614074761405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-7bcef51-1614074761405","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bfa9aba6e12cdde5b6f656495e7206f75cd9f051","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-7bcef51-1614074761405.tgz","fileCount":7,"integrity":"sha512-GJ8PI4bLRSq0uHXt9xiesu7AjZao1m0yIvlJPRCoWlwxfkVHDhpJNgcCTmLipdnSJQfS3LC8kvEKQV/TgV6uww==","signatures":[{"sig":"MEUCIDOAtvWYb6JLix+1/x/5bUsJvTmDJqQBQO4rKbde0vZ6AiEA7EdVxERimY7Z3i3tby6pjn3GGQ9VwVKoxGnCj9tMx1o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNNO7CRA9TVsSAnZWagAADm8P/RUBSXBD/Xnw+DjyO+aG\nlzXtdS+ws1B/eLhunb+m1nwwKsOhU2yph3LrCQhlBsdyVAl9JV8NW4p7q46N\nk8WYv/rOh3Cai8/3rS5Ndf0eYhZwwq+5QZLbUgNzBGwIGWYxqaCdFhtjxmV9\nyH7enrHvbl+Y+zeBZz+8gZ0bvnoCRrnYLXMTkxy4Fh4hwwRrCbnpJReJRLpz\nBdzoSv771E8U3JQLX1pEsY7PE6l8fjgbI1JCxOBUeHSRPKJhPp+h0vH2t6K+\nYwx098PQUMjs9dxX380ltGN58Tkn4+K8Lv9HBQCmp7IleJu2E5+lxEM+93Fx\npn8Ts2YPRP9zDTFJtuSfedZa0ICqUPb45s2P687FDkcuyxcsvB8nJ81zBpDK\nttUQzPz1/M4koGax7S05vHRSwm3e0ICoMb2FL6/86ARox9joau0pQPqG3VGf\npLO2+v10JZowzoc5sGFzBKghp6KWB+aSUF4W/5nFNAfDYWMrKiiP5B5agLe9\nQp73VQYdojP4+w/fdkFRzCm5ML9MBR2oDhHIVr1/PNTY9G9BrqgP8H9YKbJW\n1FNWqD8Fyu9DSMUvq1w6jG4iRCtb2/1HJ1BdkAIhSJk4yyW61+x2MJoedWQ9\nKMxv503VoHTqapZf3D/thXYnkqgCTK4wjqtKE4ARohmp8k8+Ct5DP9Zir9QF\nLf6O\r\n=mRDx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-7bcef51-1614074761405_1614074811071_0.693662934231442","host":"s3://npm-registry-packages"}},"1.1.0-canary-7ffecdc-1614074763892":{"name":"@iadvize-oss/store","version":"1.1.0-canary-7ffecdc-1614074763892","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-7ffecdc-1614074763892","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2bbff9c3deec46c65056a25e23803f3fb3ab26b4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-7ffecdc-1614074763892.tgz","fileCount":7,"integrity":"sha512-PPNsmMptQg0X74xaChv8I/EpbLDJ5/jQffqUoQzFqDdwltJyZ4Vvi8YaVwe081bActrBFpLxiWUvaZgh++0Wlg==","signatures":[{"sig":"MEUCIQCMu4W6pNK3y6bWBG1Pzis8utJyuSHZSj+OiTRIguxFzwIgC5EiJtkdLqDGEiYQrriZKSL1iUq3rpi7ZIBvhOJs8cE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNNPJCRA9TVsSAnZWagAA5EMP/2KGrZDxRlTRJXO0tN3a\n3kJ3b4F6UoXP/lKAC8/ZnCx9xkx377HJa1LdshasByPrHomZZV3T3XvwXx27\nSVZGRkioRiQ52aSes8fgP/0QoiXqWSGxidH9sFxi+MUnasIMzDnIAx7LxzfK\n1az70bMOybk3skaRtmWKJTARkIMzR9yeq1ZtbgrlyUkcHSfIeF8myF1njeY2\nAs0LzZdl0nxxS3jTFXBAwsuQtizC+PfeCUvgJtX6eON+/g+4/10iY6wZXpk2\nVKLkS1uQKm5yxYxaLQAFyi1wBgm6N89PuwCdKexarI+AhzQkAIrGNYqglmWQ\nqb+f0Lvy9mP0EGuRZEH1ENyOoUJHccGjmwTg43Yj/T4YV+LajdAjXkAhPdDL\ndD2wqXqpklMQQJWNUtOo+Cxm9eWGOEgNzrbYdlzEDDJApxsNF1Z0iQOsSEqy\n830mWAwjTQ/SfjS35L9njU2EGGTAzLSopGF/7Cbf8v/ZuYEYLVhbx6gvaO0n\nH1gC48JuD+8Z6LbQTklZ/QvQDNx0Mb8rZLvRVFUZkC65exdlNBFW+ZZeichy\nSMWysd/r5B3FNb9DOuDlY5syP3nVKNl5Kp9s+O/UnBQIsrBv3QLLQooS0tiE\ncNWYKZOlEr3zsxXgFlsMBGUL6A2EiBcJ22a/twbY4k7fQAQQ+QrkORe007Ts\nigD6\r\n=SVE6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-7ffecdc-1614074763892_1614074824640_0.9225711343377876","host":"s3://npm-registry-packages"}},"1.1.0-canary-0390e68-1614116860862":{"name":"@iadvize-oss/store","version":"1.1.0-canary-0390e68-1614116860862","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-0390e68-1614116860862","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"91ccca17764988dfd6b69ebcba3ec1a09f5ac4f4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-0390e68-1614116860862.tgz","fileCount":7,"integrity":"sha512-hXFHJpfX7QJeU53JAGCkEKmVEY9yRxONtUZdG+SV4YqSE1mIkc0PPoDBgk+6CPzuhxpmj2swi7oo4KZiPfcxJA==","signatures":[{"sig":"MEUCIGMJnJXP+Y25JYeFE7EoCyykynGm1zOscwy3POwidDJSAiEA5FI3XE5bw4sVQI1nT4qKGuPW6BaSnpjttS93VnupPLE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNXgyCRA9TVsSAnZWagAAktgQAIA+rj4LeT1w9S4eorMY\nFm4e4xwZSr1wimMP1CpX7IrKkbQKyLWvZjvz+JM/4Sk+pihFP9rXFNFl/s7a\nWi/ih2l/W/Ak7hbd2LMCCwshnDpjTOww+bnj9u/kj8FsHxO2g02gkkPC7obO\nUlJyy3wF3iY9RYTBLb3bE5CwP0LON9gpn7MyGMeiW8qvPCz/k3e9CAVHOrac\nJYQE5Xe7SRrCNM2UBOtF78AnMq8NsnO4G7HYnHupKbaVN2kCjamZ8j1mJlLD\nwqEpx6SvofxbNnPi4MGT2E5MONQcq+S1ubs9KSjxdoUDurdJ8chx5jeig8gN\n/dARtbsSw/SIpPcEGnWLSEn8bGT7FSTyZM6949ra+9XOLylctnfySFdfdNXw\nEzFkv4R51x+F33/B/Jdcp7NvBtHXAc+F/PtTSevHDdHO0KEkt7HcddJIjV4e\nlxQrSGoLsLDIBTr3qJn/8Osohmx2nwLThvcQMei4e7E161Dvt8ZkRpFVBF0v\nhJSrhQkeokXryXOnplL63avjanEfb/2e0nNQD6HIaFvoppi/IurtlJFHVEPF\nWrySaqbD/pKCl0MG+g6cbFja5WTDqQ45jeWOhwIvWaf3NuvjyBVis2TvueN2\nVP7VvHgta4dJQW3zjH/P1YC9Utm1EX9/28C+bc6Rznn9r6u26wPprkgZm2Ex\nrmgK\r\n=qS7i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-0390e68-1614116860862_1614116913813_0.1500725774696059","host":"s3://npm-registry-packages"}},"1.1.0-canary-6977b0b-1614118741073":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6977b0b-1614118741073","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6977b0b-1614118741073","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c8e4ba5a4bfa032e1eae416de038440c070cf191","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6977b0b-1614118741073.tgz","fileCount":7,"integrity":"sha512-IjWMa9s/29+vHVagksEJEWuGKN38b16vbpi5O7uTjZpbzm5oZXHC/5qxZqvDZ+mzLlNBCL8xvMX3JIpe5R1MnA==","signatures":[{"sig":"MEUCIQCo8UgK34W+Yc102E+vpqEsmjFbuh2ThSJsJV/ceLai/wIgZuXvRBmJv7exlm8xbgoNFmmkWIvawlREkOcadxHrLUk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNX+GCRA9TVsSAnZWagAAkwMP/iU3eVZLqm8u0XJ/JY6f\nBRjQ0J0UFI6Wn1gzi+kL+grTtXioXu+Nf+U6C+v/EhmBptl1s7Hca8CIZPxJ\n+uEzBsR/+EjxkFozov8Y36iVgflW1K+Uvjl1X5DQJwAmEANCfZK8ez3P1ap0\n+Li7pntVrZpPHV7EA4O3LndybsNuumYnMMXlVw9rcv8jG+qbxFCU5bnBmGiX\nrPtxUnHo0kZ5kKsQqVqW/GSKj/3+4fo0Q1m26UsBldJgHHR9dAu+oQhNDRkg\nWfbo7wzc3+cM2d5jOLhbV9iGDDd1ju57zgi7NWBTK+S7U8Ga11/l7e/KEZXy\nqrsYumu5Fs3sD1pX406Ja1pEatDn/lJq+LGD7pS+UkX3r/sRpbBSjjbRI+x9\nCc8qsLGr7giUYv2qwm3mPtywGSPa8lFe3YQwtE1kjdAZLJTZZXuWebnCEjM8\nYl/sd9a6xCVs+QHKIlBlwWjthHsEMgVJ9RgeeP3iYLaxl89dSa9xCIKhkOmK\nU6kubsHAnbA/JyCRHyyvtH4ZbjrObOD1Dn32Otx1EqA+3+gELkpSYBpc5++j\nlmwjFqt63Ez9jp6of/eY5ZWj4HUEANiztBtoRQim1Ag17FaWfky0LMQ/Wksq\nTPILea67vruIZvYhEz8PMzItj+8BwBlJ6nqtx9aoRk+ZtRQbdPYvaFT5LgdY\nL3vC\r\n=b1ui\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6977b0b-1614118741073_1614118789587_0.6021592952779291","host":"s3://npm-registry-packages"}},"1.1.0-canary-6977b0b-1614118741398":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6977b0b-1614118741398","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6977b0b-1614118741398","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bfd6133c5e65fb3e2dc88c36b69622a098a3ab88","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6977b0b-1614118741398.tgz","fileCount":7,"integrity":"sha512-WGNWMHmLMhocbpUTTe4BLvDuohYh000ZkVrNul+XouBcgByUYf5nzxwowcYGjnjCp5zdjz0jvAW5zhdvLGPBEA==","signatures":[{"sig":"MEUCIBrtHrlDLkyFS/TPirW/waUnGA5TdHnBDFIQ7M+a1akFAiEA2x8nvqOK3omtz3qykYF+utEc2/ArbJfU3spCuJo5+eE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNX+kCRA9TVsSAnZWagAAln0QAKLatMADJFDm8qUnEZAk\nL2hYyb1z2jCcuPne+ZH9SolCj7VeuwUKxQIYBLWY0MGe9vOfO/KuvcXB2NMr\nA8p+avciUHngKjCXemo/XXN/QIpyUwmnqQIKpdEdsvNuNabQBcxkRumtb2m5\nGcRS2T+8apl0Y7oqDNiLZV1RqSLC6PMI6Lk6H8Tir5kIpPaDtYPJu99RyaGs\nA8ONYXPYZAzR6so6ZrDLq+l2HQiUCR1vHI/hF9KskbfKzCwl1o4ZZ757Fhxm\ntRjrFE45ja466tZjSzfS4mOYfK8V9/sRO9YCNGyB5cAYz/kKzxEcZFoosnUr\naX2WZxWaC/7nK5EVmIDBlcxS19cUK/d93BpalQ59l/M5Wyl6TqjyyZcKzLmp\nnSX6kx7NLMzPaTIRaPLQ7GFcXRf/2O2qfQR/MVAMCtA0DxD1YJQYYl6I/HU5\nHKaix700i7rNkpTYmfVYGCDLAhyRm3cONYPMvirOrHegEaLVWhCTZACO9dH/\nUsuXb70vuKPnXM4vC99+jsC/81MNr8M0uoTBY0hlioAEwufNwwRY7yYTnVzx\nA2DgpnEOnbO5BJ1fO/AoH9MeTQ2yYIho40IddTiuj3FKUs7MwPy+3gmbP8tL\nA2uoiao5/SL3M/vQZyP+91SFkN8kEowmakSu4aKKUjwbr6Vsw/bCXK/QpyPW\n2nHk\r\n=zxix\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.1.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6977b0b-1614118741398_1614118820266_0.9215625215651766","host":"s3://npm-registry-packages"}},"1.1.0-canary-93e17ab-1614184334069":{"name":"@iadvize-oss/store","version":"1.1.0-canary-93e17ab-1614184334069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-93e17ab-1614184334069","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7118e9fa687d6bddea8a882a18b8405709dd545a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-93e17ab-1614184334069.tgz","fileCount":7,"integrity":"sha512-v4+rhRZ+cRzDRgR+JyPkMF6ElngXYb31Xcyfx4xe8WhQWPBPnR5eVe8Z1uxCAdC3ne1NOVm1JhMX4ZmNiSwB9A==","signatures":[{"sig":"MEUCIAwQh7MqUgIRsoqoRuVoo4KUCXdAEOJbHPzn+avPaMTdAiEAlBBtAVM/JZAq+5FbhraqNKORkhYjGNNU71/A9NCDtfc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNn/GCRA9TVsSAnZWagAAUYgP/067Oq3BDNbNPcDtpsKQ\nP7Yr1HNcnVx8t2p6n1CusRTnqF9IVsN22eiI9WFvujj98e0/hgNbvtTQ1rSi\n/juHULmwoQTCJnwVQs0LYbYSPiREkvY9XKhuRuSZCuwOW+8ShmDGDVIPxqzR\nhEsPUJ5y0ZVQvX48QTywixvDNdimlwHREhhDNcq58RNKBt5YOxk6u1jrjGJT\n0cbwKkAA38wbHflO3PgV8nLngig9LqMIo34nNAKH3PiH6hQzDIbSxKmSWuxn\nPF8t2/3bzW3LytJ6ZEdLddOk42NZBCR4rPRACmvG9g1IkTu1ROvs7fow3ebZ\nSQepuqT/Uj1EFojpP+iZ/eveUb3BRE71nlOrDu1eYRMDUPdk3IgHQBGAcXqA\nouoxoVlgZ3zzc7sE/s3fioOGYEJO5OyYw9Grg6w85QDcwMN2tOjhVAqFuAMb\nY+wTC7rb960R248cyjO5zpfTGng1TZjNkQHcgl+rJ97syz2a9cDEl4LR1q4Z\nbsihkXeeWObT6o1AqvJLybWAXRcmJZcoOXa+I+6vX3awrvnDGG8P6bc/k6IQ\n7lgeSGmvi6Y81wsoa2JblmVXFaAySDkQpprXQatWYR5UYiJFooJeBvJDUCvC\nAH284JRL1Hu/6BjxnMWJs/njpAc5JBV3KPCZ5cqu7qC2pD9PCyxuOy3AYflA\nB5Rm\r\n=Tu6b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-93e17ab-1614184334069_1614184389622_0.4094724400973695","host":"s3://npm-registry-packages"}},"1.1.0-canary-805d793-1614350770600":{"name":"@iadvize-oss/store","version":"1.1.0-canary-805d793-1614350770600","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-805d793-1614350770600","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4a5d23c41bca1695afbe6a0b59cb8b5d837423fe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-805d793-1614350770600.tgz","fileCount":7,"integrity":"sha512-Qu8CQPRCWi3ZSfkFuUUoakIlM/Zl6tKc9g5s5tVpaa5aBbZ33nOpBS8t8qgAIaoO25l/CBfZ19ztbYio/69jSw==","signatures":[{"sig":"MEQCICGtD1qqCweCkjeT91TDZiV2lEo28foTP+7YNch1YbyhAiAcNex98GlF1IrjM+v/Pq2bhQ9tlQcmqezRHKwsEdDB6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOQoUCRA9TVsSAnZWagAA4N0P/2JcRUpNiM0SswaDd6Qs\nlqyFlCTrFxR4vzitBM/DhEKZte5LTwgbu4B4q2o90YnOLSrXG9Ed5dkXgz85\nnvy+6jRiUsbQ8IVwp2tgV2WIE43fyOKjWMQWXHelqJtJglP4PLMrKld7aL4X\nmJk8Zidu1MRCq6eT8xVapj6/W1ytrimAtnx5GCq7W8HYKxkWIF4SioPUIFtb\nGO4jxaPyeSlQTB7TszQ9Ng3TOCyIQYwrjpJv9ZCUFs2u+BKqrjwnIDnywRFj\nhuv+SeMPRigIA7lyx9fW68t1oEKK57S7nUJEXzAdxDgfAd7ttA/rUH66XFIg\nf3Il/JlGwGlbNoq4FDCox7d8YM5L+/YJI1gxaivQ0fw1IEiAjrfE57chOj9r\noo9oMQOc+NYJx9fVxZba53gRZCXbOxW408ligI8JfGG4dvH5R2WqD8RYX5kb\n4LJOWudvY7ANP1g4Nz3IGsaKj4baRSDWzHVNC22wNggXrRAJCEfwfb6wDMDc\niAKY3TuAtiyedY/QyXv3+7sv/L540tnDnPDKKs8qXbvJ/Y4z/Lz95iAJb7Ph\nkASW6grhMGVMper+XLB7RtJKIZe/1SqtfK8i9lJw7FYfDmU9PQRJ4v/dMgVg\nfpLgjq5HUqJgkFtfjsqIbDcMoOg2AxwbhN0KLiNin44DNfaWBQF5cL4SP0fF\nYo/+\r\n=mEp/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-805d793-1614350770600_1614350867924_0.39307402107763334","host":"s3://npm-registry-packages"}},"1.1.0-canary-b3aae1a-1614355844238":{"name":"@iadvize-oss/store","version":"1.1.0-canary-b3aae1a-1614355844238","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-b3aae1a-1614355844238","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce95e5080ea49dbe0440b8142a5e0edaa0f8b946","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-b3aae1a-1614355844238.tgz","fileCount":7,"integrity":"sha512-6q+J7pDw34Wh4N9vbYeSIC3VeukCp/ED/LX/1ujBwxtjcvp2wqJ5dJKzncRcf1e4jEL/IkJE4dMk8AIx828HwQ==","signatures":[{"sig":"MEUCIB+LWwCmiTIeztSajxpZBDIRJMdFNK0Wg8DRJeeaZjv1AiEAj3uALcFOGPthajUxkdSJVGl0HOHJno49SBujzfnhfLY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOR22CRA9TVsSAnZWagAAZDYQAI/IZcRVaFqC4W0HReDH\nE3jN7rph2oBghhkN14E9lqNQwH13VBtOI66yelIsw6unqmuuLbBM2BuOI45T\nkxHV1jziPoFnWTGfNXiku4rgyGzEBPWfyYRj2e8UUrS7mMVdRK/IILKRTxch\nuzBNmgQtY1xWxjxsv2rCw5ZA9datt3IVVaKHMMyMtkWyCszqGDKYrPS1yw4y\n/ER28qk4QfP+SEK3Gt5cacmkLvZEpf8mj+O8DGg4A1PQgahQUGdxv7aElpOo\noIknv6r8vMK9Gk/Por42LDlUcyfonPB14G6PJQHUviL6s/3bbFIw8UenJlbe\nelabh9e12tEo7M6tMT4eGzPridS/e8d6UhAVoUuW7UBnhnOxxFkXVsh80N6F\njPbJEV3aHGJnTfOXu6NFmpAk/o68d71kSKoO2ZgQ49PM6w82Z9S7NBvC82Bo\n9bBpqxSddb8rVobpj8+p79EtOJyDB8I7PXsjUkKtBcfS0ZESYqJ2aI1ho+xI\nEsgrJoCT/7hI38u9zLsA3EAhQL5piJzkx3dS+H0fmBJ6t78BV3K1/U54naQu\nY+4PKyzdLOGi9gLPqhRjpnMl1tpmhQy7h3N/r4g2PS8vxe78UbedRsmjT0IN\nzkHeEKB9rKSds9AsdGkbER0Pzw2vpTPdoJtdpc898il6BEdvUB6a8JmziYAF\nMQHZ\r\n=zFTd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-b3aae1a-1614355844238_1614355894051_0.44032840880839563","host":"s3://npm-registry-packages"}},"1.1.0-canary-33cc796-1614464185504":{"name":"@iadvize-oss/store","version":"1.1.0-canary-33cc796-1614464185504","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-33cc796-1614464185504","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c414379c56b95030fcc745b53aaa3f8d84f43d00","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-33cc796-1614464185504.tgz","fileCount":7,"integrity":"sha512-xeq/KHZXKfSoL92ZlFUqYw/2WRbNLbkuD/lC/QjZgWIKQ4DKhejSIhYNeXI+m0uF+MEhfZvVQkvmGj8mvNIgow==","signatures":[{"sig":"MEUCIQCIJ7ti3Y/tP41P5IQ7g1TJOrOvHlglVLT0Ey6EmDzpegIgfo3gqCaJxExlhy7pcVppOFKb37eZk2oTlZg+1mEtNGM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOsTjCRA9TVsSAnZWagAASD8P/3voQC1QAEwwUHOvgu58\noOMffFnrz4qt95CsvJAnXJkyy9vrqm8xZHTXgYeaS/UxBUhtpDsX120cm2FD\nIjZcItsbk9A0dqMRA2NQVCc5BzeoshVJj7IgJcnrmidEmg6lU9P+q5At+Hdu\n+tUib+3r303zexQHz8TsTLRIFJz6SO8WC5vccGnJLLWpOzZo5SkZJvnW5sVB\nWj4m5Mhwuio4Co9qG3bIDmTnC6DXAL2kDJX24VH10gEjHus0iafg1C9gP/hU\nCQYCECq5BHT5noiQIvyS0G2rnmvToUD9hXW3qeZ0I3copGRc3hNJ3T8L+DmV\nbZLY+7J0Hv4ddCayUsGGnw1rXWBCQfQ1gK9cWJFE3pdmmxByQC/TWlAI960D\nc7eK7qhwZEnwLu9MXAfR2YyVmlXoYmto71FmTZ5X6ZTyBbqiKPkgJVxzgDdQ\nKUf9/vhTuq/qVx6PwACZHa11pmgMmcBQEVRIeT0un9LdytFeM2zW0PRa2Gn2\nYZxKRZFZMumKvk2Zlbwe3Of7HIkYU9fj6T4R9QE5SPNXL/E0bYiotaSiFMzi\n2Hz8LvAQWeVlhPuPhVQ4WQoEfOU2y0RpFTtCTfQBuvpbn9GxYYClvkQunxtz\nj4lvtn2n76FzSOesA8UhGAUWwCDh+8wGDB6ws/jSsqTgvtWqyXgv5xPSH2S8\nYMPK\r\n=c1Ez\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-33cc796-1614464185504_1614464226676_0.3041637651154534","host":"s3://npm-registry-packages"}},"1.1.0-canary-33cc796-1614464187876":{"name":"@iadvize-oss/store","version":"1.1.0-canary-33cc796-1614464187876","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-33cc796-1614464187876","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f0b8b35733b85fb415989db63c0f730fc8c287d7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-33cc796-1614464187876.tgz","fileCount":7,"integrity":"sha512-wqjbDJ1Pw9kNuxbmEKHO8boXIKltiPdWy9GHWwy0lzpnGgCEiJsrJoJEVaS0ehNLHVZXk3rWwEQ2ZSIO/sSHcg==","signatures":[{"sig":"MEUCIFBZzkAaSnx4wG9aLlFSHVTiAQzj6EP6d6Khq7Mfk9kcAiEAsuZu79OBis+cQUOqYBxFXbSrxZcm4SXTrtjo9niq50M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOsTvCRA9TVsSAnZWagAAVEkQAIcmvJyPeIfYh0RWQOzV\nzm7Fy2tMUyz6yFQE2+odHYzhjka17rrKvSse2xYUUqpDSQXVGfyY/FLsY4VY\nedk950dYcMZs0LJnx4y41PyJ6FY1mb687swN6yvwD1W5zR+xLGe14PIoscRG\nxOvPVedfmdwUihR8sgFzI08fyLMJ5qlisFbINtxF23plBl8ZNOl+p+ll7U9l\nYpCh3pg8gK9qP/Z5dn3s1DbJ2STsoG1nCMyhp2ahiAPJGdKxP1HCVwBEpTei\np5v7xG8unXmXMkvJqhwdHp1pedZvOM1jnFs+kFuBJvwz3HGS7xCC1sv/DYfI\nSgvhfotYkXikuJLfrYOcu/SGc+Umazu2IssG4wtmTYtarlh5IfI6fxXnvzkW\nnIuYtWcM0Hhz2mlGBQe6r7UbRZwUc8Zf067RmyOcrsgqw1IpAMnMeOsEEB7D\nTl8SVUMoBT0Ujb/4BWEZn4pX/dfxkBh1Hpsu0uZaZWVOKS424SXLVEwQRygj\nVnmlPeVGN2EWWYKq0k+pBdEzN/az7RED1ZI7uWc82/wE3ZZbM9rLWcER9Lma\njQAONMhzbNGiUPjv0ZavqvQzE48fQ8MyBsdDaEB6ivhzXVr2KwhfG9u29K2F\ndReZeD311hqB/+Cia7A/osRVLDRYyNYFqll/2paa57yxF1Lxm9ptVqqWobim\nvJXJ\r\n=4D55\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-33cc796-1614464187876_1614464239425_0.5938311216056846","host":"s3://npm-registry-packages"}},"1.1.0-canary-14e8f67-1614554896619":{"name":"@iadvize-oss/store","version":"1.1.0-canary-14e8f67-1614554896619","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-14e8f67-1614554896619","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0e924ff03528f1167f268dd0398b3cc6eab4ed9f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-14e8f67-1614554896619.tgz","fileCount":7,"integrity":"sha512-Y13llplTvDEGGeh0WlpIWzx2jjL8f+kPLZjC+SA9Ww3rHKjEi5ivKlpv/0yC401x17chao2nv2KglohecNfMCg==","signatures":[{"sig":"MEQCIDVAa0qqVgpMznsiytjy5d5/he/unYc21cdv/BATPF/XAiAnpOz/tISqPu59z5qHIyv9kwRpKZXDY3BZ9FD6kkFaMA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPCc8CRA9TVsSAnZWagAAQhwP/RwTrpfvJOWa/dVsFdwp\naVK7fjFNeBfIfeJyaWhIxhDUdISmyCyzSiPkYQk+VKfK/dwyhZ4iUcoDPcWN\nu0VZomPty40UgU6hYkW3QRh+lnlP8WOVte1DbUC4eKgHaBc+yQ1C/O3DJeOf\nDgpdlTI82hHHeLxQ68Zlpa1DEEIgoLYRhrXnO1uWMMIcSfFoGpZY3EK6bFZ9\n+EPvEthjvHo51cBAzw8EzdsM+4Zj4imAc+D7Fxcsp8gPxQYWjH3zZOUr0lfk\ndt+Pf87shIRaWZsIqLQXNXSc4SDchZCn6AUIZzvIgGjWHaTlxOgUuxwoLD5n\nUM3DZyuOycZObT1HaPiaXFzVOkLdhs+VDWOSTpHTaDzAKuQBblwjdIpEKSlT\n0qqhdkIJFgsqWbOG1F4HLZ1xxsIXPgXesOsrOk91e6+96sNcm/YnSr/WNlHW\nRXsLNs+86KBzAfuvQEYCE230gHQL8QWLFeEjeh6par69P8T2gwUUgjBm3q/D\nWyDwf94zJOG7OJkr7UgeHqfd0hmP8okhTYgpWPnXB+td5JvJWbyW7SJ+lZQ5\nbypmD02w+4r54E+1BhXs5UON7K+NFma8Fo4Is/rVujupTJ3ayv/cURSU94ps\n78KSVVZfLicI+cGVoqOg0WswHJ1n859ecjuaUYCr1PwzSfXwAZSjPYtQRG4T\nK2Xh\r\n=giIH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-14e8f67-1614554896619_1614554939829_0.09162138054537516","host":"s3://npm-registry-packages"}},"1.1.0-canary-85a0b17-1614589310125":{"name":"@iadvize-oss/store","version":"1.1.0-canary-85a0b17-1614589310125","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-85a0b17-1614589310125","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b7f0d377a1231d470affe5cfd5ac08a6e36bb22b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-85a0b17-1614589310125.tgz","fileCount":7,"integrity":"sha512-LMpOoRh8QXdiIpJ3NOSqCQ6Pl9dhTRYK0CkeJrK1Dos/dgJ+Xir6cuM5oVV6E+WSFtI5z6FI3oNJdFrLqyFnGw==","signatures":[{"sig":"MEYCIQDlus2CZNb+wHuP5EfgWVuSqqzTV7b9EyRJLl4C7LeTUAIhAJCR/X4m1RD6pDddGxFG9TrSEtkdJ2Skcvx/iaXp5rw9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPK2yCRA9TVsSAnZWagAAbVUP/1uWGS7ySREtSQIXKl/I\nY1UHfHLQsPSyu9t0BqF9hKhQJOA/CpBtoflEYX5/k1dTO4ekScrU0W7LZrTG\nMViH3ox8r2QE/mmddy5JIhk8+nqSjnRbZeaDwO3J4Em+MrB50hLEQQ8hMBi2\nw6nLoz1ujRjboqPRh1T1K21tswB4xyWdlqLSp+EwYla7f4Ik0Ejh/bzHE3dR\nVrt5B9PUgBjZn2G/muzvckLeM5hFUb1blgEvJVgqc2fiNR87NxnKZ3LCHTli\n6zE5rWWLGW1QlwimD6apVZ+lP20Jh2K5r1JEre0TR2u19FpqOFBbQrdgZdCV\ndd78vnCRXGqdZvVYc0smd3dfd/6fPUykTegUL7sshi2WEcmt7pPz+EDDzcWz\nR2DX3pY0F043KNdf7UxdjiE9WShwTuMtXDq7elLyerQfr0iX1bbgs8CBofM9\nF3YmJHL/KDiy9Ej7vDvx5pgTzUEO23JnYspJ2VJAhRN8onQDRii5FGptX5WZ\nQOLJKr3OsnDiRNtPP3drFdgm9IbIu/j2/onj6SqyzT+W9rIhMR00QwkaVDcG\n5RtSeuYulTiJtrEbxW3jys8cz2NVetn8rEVoQp0UiKyRxzk/1BKmKyS/hvpK\nevRcY4bRwMkI+dXKa3DXyxdJNHJo4VcSF/d8vefgQYTPCHCDrV+qeSKpvpSs\nTomV\r\n=QvpG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-85a0b17-1614589310125_1614589362460_0.14027759194713485","host":"s3://npm-registry-packages"}},"1.1.0-canary-f117734-1614835254541":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f117734-1614835254541","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f117734-1614835254541","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"32c2263863524760d3e9a38a19b9871ec582969d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f117734-1614835254541.tgz","fileCount":7,"integrity":"sha512-RHULeihxetpa+EHVmUze17iZX+2x/q/tZkJXz06vHl2h+AHzxEP0fwNkuJCpd1Vqio5IavwS8TQsXbRqwF7pUw==","signatures":[{"sig":"MEQCIDAIlXUMfR5AZ9CzmhU8hWp8dDxek1Uymnp1N4eSVw0BAiBCJAog9L1LXosrWNVvwSn+2krd2cAzVBOjxlNE8F3IpA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQG5mCRA9TVsSAnZWagAA41EQAKHh6SgTwNv/v1RcRayn\nASnILlG1/3LHRtEgEGdQ2/TCFrkhkimiPTMZUEnpaTPDR0wHXek87JlqD+S6\ny+i/JKaVNzRmPeiKGI44FNDyCttW7+QXrkc9O26K3nfl5vJ+RWPBYuX3qElF\ndr6nXgMYip05K6TxWEoYQMAl9ZXdM9i3dyYEBIp/dNrSBQqPJtkMlvhE9RAn\ntXLtd3oBjuXAVwW+n7mfHY3aN0eRnbqJkmEdeUL737KGnFdlTY4R93EMkp7Q\n0A8HKrrMOPSVOE3w+fyYJCW73JFgj2CBFwrZeSud1G9VXR94RvaGn/m3fnCs\nRLmfez2fcERIEctqzJBnE8MY0IrBTvqa38IY5vwRpp2en7Yus7QJJvT2K3FR\n6Pi/1I+W4jgJ3bprszZOj22HtrXwNEqyuohFxUtVi5guemZf71Vn0nd1ih/1\ne/y2EjIMrXiWn+jVzivVk33V3+GOUTuda1OR4H16D1xEA5WEMfZqExd6tvUi\nB57PdMaLXa44AQcopxVKks6jeW+l2IjMsuZsrIzNIa/MAbTR60o4wMLDGKQ2\nPdh5hG1CAWVS97hvQxBdRaAJhW/UOrQ3l0BPx3QV5UX9MJJJQKg3daGvMzK9\nCtSyhAfJbeh+yq/ukDIty3I0KS/qZA34uhkgj9DsiUsrGeoeoFx8slIH420N\nxrnr\r\n=wttE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.29","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f117734-1614835254541_1614835301992_0.4472342025855174","host":"s3://npm-registry-packages"}},"1.1.0-canary-c8f0e70-1614847047294":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c8f0e70-1614847047294","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c8f0e70-1614847047294","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1e8f2419ab6f9543ec3dca5dc0d5ce5b1ae9d6e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c8f0e70-1614847047294.tgz","fileCount":7,"integrity":"sha512-Y0QctledUH9ignr/Ncdm7ucDqZL+1yyMCISyz7fYfy6cM6c+uyT22ZWOs9SRMXlnFx9S5o6OpADt/gpj4t386w==","signatures":[{"sig":"MEQCIGdBOzQa08IMeOfHqorWG3YwgQaVoNjUK/sFzmt8MqyVAiB5EscJPTtuKWXI6IIyVXKFzm3/rNmdfzu43u0n8t4SKw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQJyGCRA9TVsSAnZWagAAe4sP/3G5qfRhkkqoDmvdUxqE\n5oH2jLA20jJ+aUZZ1lF/lZRqjrZXg5Y3a/5FGkXfsf0oq9J6Ixe1BMLEpn/p\n1p7tlDMPTtiQz1JLN6/hG8INB+t1OuW+yba/xVMx9C6vmc6XyVDBQniiNkJJ\nGomn6KXYgaDRz+2aUH8RIajicGuD0cKT9oDKFBrv1q8vv4072EXgozQyIia5\nBTb0Uf/wyQEpyZvYma3MiSNSS5refuvukaPggNcTc7N+fqFVvDqoeuXgGOkj\np6VWQY3EqJbs9xApUm7M2DmKhksE9FaFrpFLxMDJlF6lV5dZqRMf+mJyJPe6\nfOu4nXzS3KqOZ9g1MwyeaeFeDLfQiQdn0FbZAoDPSw2y6/TaH+1zzqYH6xNh\n4aOiK/O4lCL34rzdILWaO0QSWZOWqZ44rPBy6mN0Rk2E+7MWyDp1jocCJCgZ\nj1otLBuBAX88JielXA1lkqF4Ik96qp7qFthfPpc/UiiepKZuWcS0hGbsnUGS\n53+E43bHtRyt+gvIWvEMR8Sr6e+xEH9LHgfztbns2jtGMRd+c+LJy3HVIQpo\n55BcZCc3AQUrTZ01/ulJVKD+7JpYHjKRd1oEYQ4iJaQtBe+VX3D1gQLdD3P0\nIvDgvui8XpHKNQPvsrKiI3bOqf8UIEeXx6S82e/uIhEGGLL/DIpf3YCpbXo2\nGw3K\r\n=dNhZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c8f0e70-1614847047294_1614847110383_0.8355168323256243","host":"s3://npm-registry-packages"}},"1.1.0-canary-c8f0e70-1614847061112":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c8f0e70-1614847061112","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c8f0e70-1614847061112","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3fe45c249b804c2ef8eac92aecdc5663bf3a1b93","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c8f0e70-1614847061112.tgz","fileCount":7,"integrity":"sha512-xJhJs68htafup0kfYIfNLjRorSiCeLeXTQZ+J5TQ44XGQMr7tM7PR84BboizdBGMCwIacPfB9l4bEv5947821g==","signatures":[{"sig":"MEUCIAi/+I/0sBlh6qG/pmy7hrvjbiBNnIzlCkcZAqNXaH26AiEAueHBEEgt4BBLyTZHchzCvBsFb/iHwSoPvkTzTNUDXl4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQJyMCRA9TVsSAnZWagAAn2gP/1p+0qkt0aE8pOA1Cy5d\nGD+mP6r9XGGyceDwPZGQ34TyZ7zYfh69MijunPjTktoZFvEx8fqS6XxiF0Z6\n3t61TgGPsGrhkAyIFGvUO0pN7LTBeVxn3xAH7bj7eXqa2BVt7S2unZW/r6lJ\nA2mzmj5t/+zivm52fSTwS9PfWm4o4DHys9Y42xlFpD+Kf6XDNiHV67yLKN1L\nISct1659Y5/jKbuEdp/WF0qJ8ZP0sCZF+tbDJN9/ubQrBrCLW75tFtb5nbzB\n5S5OQXT7zBa+nSb6wmgSzMsEKuWszOLTT3kX9ZsqYu4SWoAXEGchlDoOynCI\nFsZjRsX3y7aB/Jei1+m8xGvwZPIGZck/5z2nl8Y1zHz3lDoRa7hHJfqN5oo1\nTkIwmaAlQPNCIejwTHE6945vVZNoMVPxADqON8H/fUOtRsjU3b0pknZIVUKO\nENlUkUr8ns2oym4HijgHiENBO7LGM3uBGsjNy+xOqXUstafNQTdNZX6uI6l8\ny+0ye9m7cnKIw0WuECBNgXzLAuqF2SjkQHN/GmcjdzuRQ/2AqfBV6nFYKmOF\nfflkeubugbhFZzaAV8UI3uGRIOMF+kJByVDOg1ViMoaYNIHIWGihRgU5VbON\ntlQtTezs5Jdw2xsMPUgkN0Nx+33iMNoMDOsVvbO6VAPOWhIsb1FtQHsGjYcE\npHWq\r\n=R5Hw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.28","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c8f0e70-1614847061112_1614847115848_0.509515801989828","host":"s3://npm-registry-packages"}},"1.1.0-canary-201b354-1614851177942":{"name":"@iadvize-oss/store","version":"1.1.0-canary-201b354-1614851177942","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-201b354-1614851177942","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ca254b7186bc4b9e0628ec4e516a5454213c4e79","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-201b354-1614851177942.tgz","fileCount":7,"integrity":"sha512-W69qVxeTQmGnC7Np7408/wwJ+zz9l9g/9w4Ch6S1F5hx7YbYfErdqM4/HG5j+DsNlgtj8MdH+Jmf2/x/CACCRg==","signatures":[{"sig":"MEUCICRqFwDEWdA774LjGQQ8yfDbxLIMDopatV83Ke4bo92OAiEAwZLXYbQngEljUEl51Oy4NugNZ394F9dyKxuhWNZwQwE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQKyhCRA9TVsSAnZWagAAwcMP/Rb1OYXwt8GOldAFJKgJ\n8/YZbElKRT5pmNzYr0y9ce+bD5ujWRbaTINZaE+Uhu/2eC7VnzbBihMnAYZ+\nI+FDAW91l+aIUVxeG3t6E1RFWZOIwu5Dag4IdwObhvsvFnaqT5BX51q9r2hi\n7ooD7QINtllJO63tcD7ARmQN9F0Csgh+Nd/OR7LUs66FSA0NdxCnDgy8PKAV\ndQWZ8NqwHOepQqLjMzS486CaDg9fnW4rOdXth2+1s4buIaNBWxPBXbFfZm6u\nYozsn0JNLprUY8tc3xNnjj+xnYGnwAVhDB0mz7qK32acckk1KtV31SMIy2Pf\n2nbeAnqXN2U6ItcgXjsTB7oDZ8UirZeVGbagkzMrEovDonMAoP8RvzoFwuhx\nFF6GsiwXl4a3JB2OqA3HuiM8KQ55AjFricIPjjzU/KG9yrNN/MGXvaloM5nA\npln+IzhA971aRzCqbe3swQ0zFsD8/Kr+4HubZcc2kHBiqe9z+cne0Ks3ny1A\nOE+a8Np51VA3uNPt7YBBz9k3Mh5Ly+JMUFweJ1sv3wadW6D29b9EzuVjiwKN\nDHFDDx0gN6KQmBTjvTsDH8xNgfGofxgLbu02tPe+y85KcMKlesw2lEZ0SUku\ndH65VgVA4BqOfkC31PH6q+Z+LtreLckXNqKisWzhqOEY72k4fUoXeeP+QHIZ\nKR5d\r\n=2MOf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.15.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.29","typescript":"^4.2.2","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-201b354-1614851177942_1614851233391_0.09802559211312012","host":"s3://npm-registry-packages"}},"1.1.0-canary-ea5353a-1614897657437":{"name":"@iadvize-oss/store","version":"1.1.0-canary-ea5353a-1614897657437","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-ea5353a-1614897657437","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e24c1f70f0c5742347abbd5ede54826ee69fea6b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-ea5353a-1614897657437.tgz","fileCount":7,"integrity":"sha512-I9r0Q8yt3W2w8DxwXSkhwoT9wbX7P5c+s8nOhi0qqL20cIrxkVLdtFNKGa3a2Sfv5bFBk5c/wJk8fBdzermhFQ==","signatures":[{"sig":"MEYCIQD6rx7t3l5PVfJYHEPArSOctCSoUzLW04q9Vqq2oSELIQIhAOian7nYq/EmB+Hlhf4v4SWcqITxRkM2oK1KTYblQpkm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQWIxCRA9TVsSAnZWagAAMlAQAJO3VolAB7K1jfi4jdCJ\nTkTD4IoruJRIrS7QPHd5IZSRaFm+z6jBb/3cYjRR6M3ypTZw2FNZLfpVxBTK\n5FhHRQnRNKtZzSlL1RP8P01nW86VxqByh4WJ5/Q8uWa5UGaqeKo07P80aBmg\noS4Mxc8LRjsQYGZJquzQ+DSJVgkdj7NvIant7UkxNBo6aZTo/9iXqdUbDp6H\nDGbqcRLEILBb5ke8ZIEwWsBeTJjQyEjIMZOQAcvaRHe93GUxPy2SPlpTkzad\n4l4Anddj5/O93A6IqxceJqI35iBUIPNw+cqmUhcRyDTS+vBXNRJ3AMODnHCd\nF2qESzwSYBToSguxNEViTysvO6ZTdBRIU06XhP/q4CFGs+Bt6h0Cy0l1xWGR\n4ilai+QXixKucPYFwG5Ew3VECA/8KAcSJNr2JQGiMRCoOxSWaYo/DkXdTHRO\n/0i2aHic6iQrmdPkCohMH4EyIqG7fjT/VRUmQI3h98Bf5RnEM2riE/OVXgXb\ndAFHNJ8VUqQ2ysa2P3JUPZpZKazWOPG9QIZysl/qHzeCb52WWxjNSE8GSA6u\nWNwsaqWB09dyKZTByGNUjf9l8dbDl+kcpu9LIzkN8PDMZ1TyrlVh+qXdjaM4\n7vZ6SasvNZx3WDggc7J5z54Ul8VibunmXm8Qrb4TfZ4o0z1XWjPGYyEbvQ1n\nrMox\r\n=VTes\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.29","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-ea5353a-1614897657437_1614897713119_0.3017439831701485","host":"s3://npm-registry-packages"}},"1.1.0-canary-ea5353a-1614897655805":{"name":"@iadvize-oss/store","version":"1.1.0-canary-ea5353a-1614897655805","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-ea5353a-1614897655805","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"34cfb9aa95ee4770a7e14c487c66900cd44dbac0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-ea5353a-1614897655805.tgz","fileCount":7,"integrity":"sha512-UXrsbJx2NYGAVL8K2/BmLegjZKCdlAzWY/Sui27jYVNYl+JzKJPi1Y2SVoX0SJu0YcJLRGmP8pL9w3FftcI1Mw==","signatures":[{"sig":"MEUCIQDEBJN5jmTIN21k+OLdkfBi986FFnHEmLaVcwRXnWat0AIgRdqL7faKgD4nuCRge119s16r0I3B6cMHoQKXOX0whfw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQWJFCRA9TVsSAnZWagAAzy8P/A0j+Z5yUtje+2Kiil8T\nc4t0H7+vhBYPZL5ee+afJX6T8Mr6qU+csSauIbzfTmmB5Ja3v3iMlydnsKqe\nbsjgM2XJtKa8SlVjp5HZsVRZZA0lB3Am5KUkm69Syblkguyf7gEPc7SQGQxM\n7P68L705rU0n/ywDdHvSDNU9KI0pS2CP3pt1gqMDZPS7lkMEFCIGp/0asSyM\nhrTJt51yIgMqUThDDIF4zbvLclfDE8ha5/imaWbXR9dkzHxMSF2a/d6WOsZg\n/RbLlFzY2BJ5xQk0NsxWJFNlLQcxol2ekGHYKk+XqoMM6f+e3L4MY0X3TWhK\nNcY2unIutLrcb04pCjnwb3RKv7IgR6BSuL3QvMvGJrN3B7V99HxMEzsFZy4z\n7t1BAgqWivDhB9i7e+N8fzvuqLm8OFerohSvdptgY0RViNkuNQtRhk1pV71I\n3k4B9SZy56t1E2Ew/fPW+fATbH6o7LHSsmscd82bMKCgQF2CXzrUgzMP4xCb\n+yhDG0+kAsFJIPQjacOIKFeucs+wPedQGfrnkGFlAWnKrQiRMEg1F2o/2xVn\nmUvY+ipuRmw6UtiRPXIgXwjPOvGpJYkcUqhLYuvEAb7hfZMm45hgb2QkVHUK\nzRvtgzzBfNIeyhvALmuZiVGEOEQdfdSktznm2Cv1IVvzmMSFlV2YzAYnTHea\nyJDi\r\n=uu1L\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.29","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-ea5353a-1614897655805_1614897733015_0.15038725480363313","host":"s3://npm-registry-packages"}},"1.1.0-canary-fa2aa79-1614899903195":{"name":"@iadvize-oss/store","version":"1.1.0-canary-fa2aa79-1614899903195","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-fa2aa79-1614899903195","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0b48bb6bbb873b989e0da53f32e4a34785874b97","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-fa2aa79-1614899903195.tgz","fileCount":7,"integrity":"sha512-eJbvrYQGrHlSMhY+y5ot264BJg7weQwtNWLg00AOznA9vXgVb16S5ShgTA2Qyb6SCWfagB1CExz0mQokEp5pjw==","signatures":[{"sig":"MEUCIQDoCp60e33d7oog3B68vtwK5KjuwTyr+WD3UeIlf3lkcQIgMTLTxBy+sVXhUM9m5rNWeKsD2NUsxr5beldt76IYs04=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQWrxCRA9TVsSAnZWagAA3awP/i5m9+hSRRwaLoEGG986\nmwRtLkx/unoCqYtVnFr1HikQaT0teJ0fd52A2bKJE2F24tzU/vJDLKsBnZa+\nGMKwsRCKkjXnawqnvY1HhkRsIF+kwgg2myBxAJ9O7l5LvUZPujGsh1OJLBi7\nUqhiCHF0vrpVDxF/Bp1KHYSYXUW47W9YH7xyVcFIZ+C33mtym86bRPbdwCor\npVwOCl4AMc0u4t4noh9UORkVqpadwqOTaxW8LZlallSMM3Th8p0U3K/ftDJX\nL7itquUDN2VBsdqzSnvHrHPha/Nw7LjeXZZuyEtRAqrRAtADk6jaI2UcEwmW\nd6ON3rAKR3nxbkV6tjMEpXkkrM4HSklrVW9ahGhupJLtWf9Cxf9qMu0uL6sT\nVLJ81z6gCNYoTYnoEsKWna2x3kYedpBtppBTuulppje8F4gW5/rN/dKMktne\nbHcFgMdVf3qbXDBHHbTu6dgniRJ3qbNo5C85r98K9iaXjBLIGmqyKuy+Xkn0\nHLfIav2Rh+ShrIox00zVcqWq5EAPQ1OaVXc8h+tls5klkHsY2MAznsz/zG/9\n32PxRJAXcyV0TnloF+tfyyLNrZ3jrNt8XUMdS0QnJ01AyWVIsO7gOY13iCPI\nDcoca2wT92pyWRk7yZOsdjsbSBBMEbfmruHw3v2+Pyk7F8CfiG/MGw4KvEnC\nA9Jr\r\n=5w1p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.29","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-fa2aa79-1614899903195_1614899952487_0.8246033927124994","host":"s3://npm-registry-packages"}},"1.1.0-canary-04c11a8-1615048039370":{"name":"@iadvize-oss/store","version":"1.1.0-canary-04c11a8-1615048039370","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-04c11a8-1615048039370","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"17ba7e53e6bd366932cc5d482025894ae135249f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-04c11a8-1615048039370.tgz","fileCount":7,"integrity":"sha512-sTUup0PwZ0+CHSD3NivBbFb65y7oKqO8wgiDqnp7TeQTCWQ0JyvkCGQn3hFqj3F4D9ZCAcwmF9HD4MKLHGoeWg==","signatures":[{"sig":"MEYCIQDzmxnxCCaBdPB1DbnNVYKLDw/N22EMnRCxLGRBxlNQ4wIhAIqhgzROPgJOXpITAU2uS4n3X84aVC/Z8xRl42Q87jv2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQ62fCRA9TVsSAnZWagAAPXYP/3oh/LK2dXlDilCWAoJm\ngxfP5mcLyknLcj0fTxTr26FJ0Zegsk6NBmuOTvnHtp+g2N88W7pGeX/lb+0N\nMQxLaA6VeZ4uEcmQ3Zj7b0kYPqCS+Kt0VCUdIdkH6/B/kOclkEsSNZaEuQfK\nNfXY2aYLrdB9deYAdDW5R/phnoZZM6j80jGEOnz5ZTZ7HISl/reojr4+KYkT\nZnQ3jglVxH1LveRSBW1LUh8m2BX0v8IBAPhev3xXxYTV0+vZEHxBOvUPtvGW\n5D5dxZYz4a/K4I5y00Qqdbe7iyQjbfqgEaaP4pHfP7qJR1G0cR0JXDNo1O1g\nJVEONeaXEd3cGlV5Rc4aajrzDnUcD3oO+PrrrShM7UBuqf4gn7jFICa0W62t\nMOEW1jHOHfRyzmQGAwoAJrQH+2w35+WbieBuHxb8VqDJPnvmIC5B3uor/vJR\nsuAiTV+hufWn+yoLjOc4dTUqsHjaeRimZAld/6U0ztnNA0vpiUw5RAKLz1xM\ntesBR8dx6Sp9BQNpExe0xGTShOzfHkh+JU8vVH3DXlWpGb4Nvd4dZtklgckK\nyTTi+HEgv1zY/Rb8Uwf/qrlpM+KT4Irf+jZ91nqQDB5v6uiXVyNtkCN4tYIw\noreK3NyQk+/M/+/0kA1hlrtKYwPEDCTGls9IA5ejvVEiU6+D+UsrpvKZsdhn\nURdc\r\n=dCDN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-04c11a8-1615048039370_1615048094471_0.42745889226174283","host":"s3://npm-registry-packages"}},"1.1.0-canary-1ecd0ae-1615193548552":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1ecd0ae-1615193548552","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1ecd0ae-1615193548552","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"85464de108479ca9b1163422d39e040c617532ac","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1ecd0ae-1615193548552.tgz","fileCount":7,"integrity":"sha512-NJaPlY/ReSzeesexw5zb1YrtRXnQ4hKBEIfdGLFGUKvuS2+krZV+45IyYllIXl8S+8eIp5Sckjc86WSAb9nj7A==","signatures":[{"sig":"MEYCIQCwzjk+Ho3H4/3Yh3rEsefM8iELZVE10IuKYMkGGNyUNgIhAMTbWOXqszsbkdl5DkrWRpVDcBXBV7Jg2KqfsOprkTZj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgReYBCRA9TVsSAnZWagAAtcYP/1Q8C0QKi3Rvemw6DRKV\nAi+L/2/EGCGzCxI9/Vo94uxlu9pHhivvdYK0pjQ7BT/xK6hAVQgOdOSjd1dn\nGF+8NaCbN7eHTgrs9Na+54dxLTO5yWKgB6KVHqWoCeWJ27MQIpUQyvqLP86B\nN8UoAHi0LVJJa8TNIl0ecBN+9b1ClnxFQAjIeEscaLHBZ3zdHb1jiN794k94\ntb4uRVVww73pAE+K0Rn8AoCgK1UBnQ9vqKHEElUMdL9ZaerH5EKT3Bwui5uu\nuFy2le/6JWQHr04nBB4HNmJr4KIiemLWFCQVk9J+paijFMUdbYGf9SFWGUAD\nZUgahYd+CShl8/HbQnFIP3aJy4jFYPRi+x1feHVwc3q051/CrIZOOq8l3FcM\nNurTl/pCP1tfq4TTQZtKnmF3wYo0eGnByoqwDnRrSuZtQ1WrhQYYY2eJhmB/\n8+Shk17iFBhNBMdFvZWAF6MofYTHS+JDEEqGMFi+eohhjfvwBMsbfOVgWd4C\nTobZ33XQmoRgh4DncfrOGfUPcYPXGlTfDqj88cyMWNP1rXGkXKHR+c1HxDh+\n/PcImVOE03JRY1LgoueboHLceMOdkaTqfKBU2P+SpLgQVgdqvfY7aXIzN1eA\nh182u4H8ZKezor1zSV1LCV+Iprn1AF4V8lqaXvZVb8ZK2Y27b07UM4R+Sxzk\ntXTE\r\n=ea47\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1ecd0ae-1615193548552_1615193600746_0.3260066160832815","host":"s3://npm-registry-packages"}},"1.1.0-canary-61c4e8c-1615280261314":{"name":"@iadvize-oss/store","version":"1.1.0-canary-61c4e8c-1615280261314","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-61c4e8c-1615280261314","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a4ed87c7e0c5ccdef80036f7d8640ca1fbc5bfda","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-61c4e8c-1615280261314.tgz","fileCount":7,"integrity":"sha512-R2HxeFNf7F5eZvYhzE9PiCmLIlu37zVJczaMQ8+qQI0kDGjuQmu+FwVVHw0tIPy3pNomCLlsp1QOFvP2Xo1XOg==","signatures":[{"sig":"MEUCIBTViZiwd4Uc6N7gSacxzuGhatBKrvWVnVhJal/Mfm6nAiEAjdZo9BIvsYSYUaA4UporyEnMljMpAn4MRIfbMOuCfdU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgRzi4CRA9TVsSAnZWagAArfIQAKBGjgedNk0srlumomWK\nfBTOlGAIO5yQU64fI/sMiy9idUGu77lB9m6KEAUDWt2mfi+eCgfiSzisKm74\nMnaFZssMfpQ0aM32NS0HDWDVz/6pQmxG/OBh6FBnUYSgkALFIvaxkStlR85h\noHVnsAgZ2psJyp6q7FpepVFcW7c07sgMxKOwrSraIm73J3oPqN8Q+Dp3S4pr\nwXA68pf/KhcQ7sJcnY/eYKQMB8ZS1XIEzE14A/YYtBpUpKpR/cJ3iZqHGdLh\nIObSM7zJyGK7gIG+ht+XRBubY0P0/V7JpSvjsakCpagfjIhgQEX9RE+aQcUl\n6B3bv/sR5MOQpcfMK9teAVywHkA1DNr6Ien5oYQboEYHoOQEhjOtWKZR4t5V\nn9tgLui+Y7ulzIV4Wr5uItMg+4uTXe1YW65iz25OLgk8faaerwdAo7G8Z8/Y\nNditPtbZ7UeIwp5Dp9K5gZjJF2iNWjY3my649AKhsYM80WK7mgtoaV4E+Ijr\nGpPjpPh2hkxhqQrANxm7cMvaU/OEm03I0jJcfxuD3Gq7fbCsca7jNmIbB6Lc\nZgjp8/PYyRclfQdIwsftNrI+p6kEAQYDDpc6Y5e0J+DGswpGCWdCVagayAip\n7VGuagzQqyxF5BAD4L7etobeCO+Wu9mxnHd9Wm4FrcHx4QYQgbITSB+UbFTJ\nV2Fy\r\n=wZem\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.0","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-61c4e8c-1615280261314_1615280311506_0.8735786357414321","host":"s3://npm-registry-packages"}},"1.1.0-canary-15b5e29-1615301036537":{"name":"@iadvize-oss/store","version":"1.1.0-canary-15b5e29-1615301036537","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-15b5e29-1615301036537","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5dc7f15c1667e3be1dc010ea033d2da774a2e520","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-15b5e29-1615301036537.tgz","fileCount":7,"integrity":"sha512-x1ZWjTd4y0ZK+8914GmeKFtxEKPW1ojeX0SZVTVRcemDJSjpfY7yT0URl7OA5TU883lQoi828s786vdQAe0SkA==","signatures":[{"sig":"MEUCIQChrrRhv4EztEcK+95KuOSZdo5SPHOdic6D3ft/ZDNm4QIgczdtAb1m9WZPNtcpYGqrM+8SNDvqM3aHG1wjeb95obo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgR4nmCRA9TVsSAnZWagAAzYIP/jLrLZel8TOVbjTXSpoV\nmE9Jg61E8+0DaQBgWZrp6GVoBIEkDPKfh8r9Ak3u2uABUDDaeI3o0GGG1z2o\nQA5Ih84Tzyw7R5rwYiOjnWRM34kbTtL9XRQ9k04jvBQvnAr6vGmFKBeec73d\nVa22xaGLsmWtadoaJd34CRLrjYFvgaL+b9Raz0AIxm1EKhEseumyZ1U0uYpK\nSrhORVCGBnU1Tf7Gps60tV8o4zrhfp507h+3RVqOEz/BeiDPFICN7VpEx55j\nAs0cfEXO9efTlcgvTjSQSyq6pAx2VgSpmTQT4xauzo4uFMyqN7fLGCxxrHzh\n87e3fbKljlnG0WdKu5Ny82ObBOVx0mLXmxHKuuJcxmX2n+EAUsmJYANX0yXC\nq64O6R98RYy9a/Zjlg01PL3FgVv8k1QUqBxe8pzIDftLC8gs6o/h2L++Wr80\nx0A53gerWX9gkN1zLu35wi4Br3yJKou9RerRfQyvcWmrNcZWCsbpK0mz7+tx\nMLgdFrUPjV/Y7EYtHZE/s82rHZpm0QPxOmSMS0/0uF0Sjv4NjyqGJaZ9oQ64\nfBL1FBYcFKe/JU02+Z6toKMpfl4VpYgG2KR/OYfMWZHPT6CaCpMrnkYZ5UN2\nLfFLXTEmMEUZIluNXz/KLVuk2x16p8mFDZSPQezw3+f6mDTfch2kRDwN9vQY\n8pDm\r\n=GYEo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.0","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-15b5e29-1615301036537_1615301093806_0.5600812119703895","host":"s3://npm-registry-packages"}},"1.1.0-canary-c259800-1615440561562":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c259800-1615440561562","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c259800-1615440561562","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"810697723df2ebb89d121152f27de55732e6c535","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c259800-1615440561562.tgz","fileCount":7,"integrity":"sha512-ynolcsxujk2lGSkuDQzvrw8BZ1obxYrYuXr7jflJS68aOpaRIez/hkRVcCyFWnUWm+5xFM9mBkaXWdqnwUGJtQ==","signatures":[{"sig":"MEQCIDrJzJ/UWAaYb/ORRN9h7YtqDv+FlhttWD8PK3dKARsjAiBxf6VKXUNpJl1xsoeifzFJqMB+qpTCe0Ok4MZ3sDwGcQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSarkCRA9TVsSAnZWagAAsLYP/Rjx4THMsECqEIwSG9Oz\neoeYq2msNLYYgEoS7j41ptf66enzVIBtp4V5+VtCia8fpjSA7H/UUDwCY5d6\nvzGhVNTz9Q0sUJePdtWlr/ABjWNmeLSIALKD1m08wiWQc4lAm3m+s0Kfp1tj\nVvrH0j55mW/sofbldxC6zrJAz4FQEz98ZS+vNlW35vu1CmMPxrn9sNVvvpmR\n32BfG/LzNIFIj2U1FzpXY2cu9zJBYuaWgrS1BSvs7pgOJCPCf1144op/yjNg\ntjYSXWIjJ+xYV8N970kPIrKUDOrU9yENtfpvcCKHBqcjSv/F0e11q2omGfnP\nmMT0f5CiCLp6yBXAJxunPyg43f4ZUgHUBFwE2ZLHa6XGW82yMHxax/XYRZCM\nfZ8NdLakcCELeP8euyfGicmO7AcI+8jk0Y95d+pEyjU+pa8HLnuuIzccRG0R\nG0bMk6NcqozxbSH1ltcHpQLil35RdAFD2rZTGx2YA03Z9vnoxTWjOSsXCGcm\nybcVNZnzvQKijIxTPV4ihX4345VU8BIZL/oHMaYNzQXKwpWJMNaoWYcoj6RC\nk3QkfY5eFvJRrCIXi0tmuE7+O15MfQjiRcomTpbvVTq0F7HwMI5nT/PlHJrr\nydINN2Wups5buAbcbINrGQlEfLsNdVsOxwrA7yw4OfUsmbjs4XeZZ0eMIqVi\n30Ej\r\n=SVcu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c259800-1615440561562_1615440611781_0.44345239433783146","host":"s3://npm-registry-packages"}},"1.1.0-canary-ba4ea6d-1615458999549":{"name":"@iadvize-oss/store","version":"1.1.0-canary-ba4ea6d-1615458999549","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-ba4ea6d-1615458999549","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7a22870550ec4473e9328880f2eb9dbca517f2a5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-ba4ea6d-1615458999549.tgz","fileCount":7,"integrity":"sha512-h4BQLPkkWjTqfH636UvOIucsxkJ0nPbCawHaG4rTwqcO2lhtqvS6gGt+dXrDPOuiSc8pvi3T/evc+kS/RZhLEw==","signatures":[{"sig":"MEYCIQDFvNAQsqPlhzp6BkSq3OSSQzNXUBNXCJ4l98BarG98bAIhAJEPiGXaLeQ27Wymvj5VseSfX4A+eD2dqNrLJxI10Zcf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSfLlCRA9TVsSAnZWagAAE5IP+wTKrq/JuDv4FoRqkKRE\nFoe2W9LMp61WAD6NRZud3JWCObino/Fts6ABrlBjWFuY328e+pBPNE+R/z0O\nahW9TJTiWa+qekJFD1tE7vaSlRamUkoDTjtGx9A1X0PyTR6sOedwlcXVkz3P\ng0nSMhK7nMrGV8piLFvMJtOVKYcTBV9nwB4slbKWK4yqARXrtls5N/XFhit8\n5R2XNo81hjat+kn//3eVExqjRK15G/p+wk2DPdKaUIxDqwt203b9wYDN9V2Q\niWhRYrQMekOhnZWsodCEv7fcsWIYOXgm0xh2bxoLXGmTktWpKWh3OgnplKzV\nohyCiooBV0hS2//lO7vbQQaeWdzwivanVtS6qWPqO84MCIxbXDla/ovVdFph\nNTMyc1biir1QlnJjj+xrbTz2dY8YnAyKGbVV2LqxMpE+3/MF3n2J5a84uqDA\nkTTWVcgZYv7Zepw8Qfd3Ev7HKXkIMh47aPDUu+w6O+sJJUgEGmnGv+059bf/\nS6B+zrhZO7PegjDQodHGj8piAZEJWMLbLGOXlZHPNGJ6LBiz/8UTGkvWbSId\nNL28rLN5N4BZ8uXHkWxd0/lXKN+AGm/8koFJ8EAwRcLb/8HCB1HgnHGW26Dl\nc2P/ZZSuGYbLhBkLperI3dDfc4+UJOVGdIdYxfmFJohDEu4Wjp+BwxkRGuFg\n4W7a\r\n=2G2s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-ba4ea6d-1615458999549_1615459045043_0.2622732243282122","host":"s3://npm-registry-packages"}},"1.1.0-canary-a7c9ffd-1615559986817":{"name":"@iadvize-oss/store","version":"1.1.0-canary-a7c9ffd-1615559986817","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-a7c9ffd-1615559986817","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c38e6f607717866584e1ccefa06bf84d8a9d7869","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-a7c9ffd-1615559986817.tgz","fileCount":7,"integrity":"sha512-2nuVq66zNAoAgGP0piX6cEWvFsFqnHHFYIgknoZCXaIh4iDrirCMES7rJpXJie3zhQtZScOIJFrivQj7Hw5hhQ==","signatures":[{"sig":"MEYCIQDA2+H5eEPfYRXKh+W1rd0SHa3sn9cIcQJTwMtBzJ8XtAIhANtkwQ2rTi1VQOacST2jVZ5Zy3q8G7ZZQiUu2vvZfzAJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS319CRA9TVsSAnZWagAAJcMQAJi0rJF5lhxEtoiLReu3\nSlgID4MNRLYUUrYGDWM8FZ2X5fhtt9hXomAKM84XADldAGphljZmJSXIRBo4\nW0O5g9XDuWZRJg7zb20z7hbXtsG7BODqrGRH2j3cBi0sVckA6BBnQs7+Ka/L\nOaEcEI9O2pVD+S+0nElw6vnxNdkM5mMEPxODft1yu2+kvi9aN2DkZCQdyvfs\nK3oNlclETHo9L4JJ7gsMsULdtxg2QIEGmqofEtPyVc7L5oVu7TTUkXQ2RZGH\ne18EipYmM3HOYVemnL/dvWsls9XsvoLkXwpPean/eNFDY3PDaLyXCoDQFt8h\n4d5WbUfuVsjNyx9yOU8yGQfsZOjUdzTd2RxUUlkdNLOKy0lqOoV72KzkjN9Y\n4HP+ygVGNhPmVo7P+Y0nmtRlcxkK2AyR5e4fdOhbWovnDiL3MzHmPEEXGbxz\nXTxVrn7UlDXilFPmGgyDnFfgcabSswFuji3I+1Uscz8hoavOxPlLdjuzU5dd\nVjf4NRRANZdK+1xOCS2dUHUL/IiU+EgqmkSXhP89xSSBoeCA5nQGUSnFItuS\nKBn2YU26V6QUR38A95wszCgR1BaXNGORwUE6MDsaxWtlzUTYr/pJ/g5NJJA2\n8RaTG2jCWsNdBJQCbgy9cRSG+DWXQS72HlREHXFXriZOqVfEOe4seBoYK2Ye\nTB6U\r\n=8ahd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-a7c9ffd-1615559986817_1615560061462_0.41387446912795034","host":"s3://npm-registry-packages"}},"1.1.0-canary-11fa3e4-1615586002791":{"name":"@iadvize-oss/store","version":"1.1.0-canary-11fa3e4-1615586002791","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-11fa3e4-1615586002791","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"52756992155fb0480546e1b23804999acb330b58","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-11fa3e4-1615586002791.tgz","fileCount":7,"integrity":"sha512-BoVP1KSXzXRndZ4iyBPXXZsaZYKFD3v3INAil1Ct/q6ToCEknBg5hbwuoEGACCxlgK0Kdq5dqlP1ACsQabBmNA==","signatures":[{"sig":"MEYCIQCL1uIf2p71Q1ooTQ1pFbYVLM+aBoiaCFv4IHCcYdNMJQIhANFeRAcXDEt2V6jqeN1RzqlgRQDhZtAXZCJsKYmLlmmV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS+MDCRA9TVsSAnZWagAAuU0P/2WI9S/cPgadqG8cUIu6\nAcc1QhZamPEnf4bvo8O/2yqxYJwXtuwrPth+nIPC2Cq7VrtUiqZGWYEy4h7U\n6TB+RlagoEDS/ZYCJAz3wkKld+/Y+nkGrAP+NEO5Xb6az2W6YXhMTDiH8g7K\n4Qe9IR0KVpnrb4Lpvj5pE8tHd/WMSrb/ZuZR84Y4G8/rELmxId2jzOKb1hiq\nPAIodJpT+YLx1DgfAT/hiFcTMB9bloz6jI2RX9p6pCPzi3YdD4QGbREqVSUn\n2AS3vcKN1bri70jIfwCHK/SfRa4qWkSZ+jZI2dApe9shbL8P7FwkPpObv+oB\nQE4q/MQTn0nUhpkxLUT8OkFMSF9Y1OEGyZbkTHKw4tDiFc5oseMTRqmptAtt\nCLFjdwqCxcwpQ+qMsEhvvX3I2dhQsIdYRH5moh/5UzZty6mbkxe+ZXWbqdz0\nnRojmasQeSYaZe7qySs1klVnxc6pHFF8PNyigm+M98At/hWOQLISwc+1wqat\nzltNxW2+hLIMkSIJI0ftyy720UyTT5FHh6jBbVXarrq/U5ywa5id2+vGRjxX\nZQnAmtb/CoC0k3wM03V9y1Jo71qRTabRQl/B4vivWO07Nv0jCpaL7+STipQt\nA/RSP6DUvT4QWrhq/MtdkP3dbfnncQ5dCHufJZMjt6oOpPxpvtLzgc1Aw/x/\ne2TM\r\n=Gxp+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-11fa3e4-1615586002791_1615586050527_0.8561257043272916","host":"s3://npm-registry-packages"}},"1.1.0-canary-f40eae5-1615693924634":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f40eae5-1615693924634","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f40eae5-1615693924634","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"be6876da44f33ac6d2b998309b97b8ea6e8ebd4a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f40eae5-1615693924634.tgz","fileCount":7,"integrity":"sha512-RbFyX9Dov5x+1o4mBBJDL5KZTa5LbjB/2ov09JQzIlvMlzqJ4RQD7sccHWI1VWoGyNwa3KYuWuE+vEYJi/Mh8A==","signatures":[{"sig":"MEUCIQCZLjqDrcWgDAQsu8gXSQ19/OxLn0qRqn6bCAxb8NDPvgIgHniZMoBHvxsDPGPzXqtDOKWGULQhLqRYw59fS6i1wn0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTYiZCRA9TVsSAnZWagAAmrMP/RfX1ueIoJ/0dK0dnhdi\nDaD7SzmpSaAtr7UcZF85v28szv315VvGNpn1+n0y+ai+dZ9Q1hUElDi6v/uJ\nBk32ZH4kE6aiJG2M7eBwDFuO6oo1g6logqkxx0ryaEQ86uS5jKoJrNEGe1iL\na54JnCF3x4F/q2xRqk2MR5dQ25iMlWSdzLKS6tzTvGkF5hRknUdaiyRc9lIG\nedaPwxGYUPryYMs2QIIGjWCc/y9tYaaPd4qVhaTdyY645ECERrD66Ois8HYK\n+UTVw+Is1Gz1nmUiWPUE2nuY4oKKxykBOW4MDVhox8xz1UmbzmUzjh82OpgE\nwCoGeU878V4LpVX2VtmL/DpXxlL49gZyUj2QdWiUUM0HxCcCi/5V4+GsLbm+\nA6g7l18/pATZH0RGcbIhbERNlsniwc/lhGTgQKkqyJBuyHmCBtrFq/i516Vr\nBFEu4N7rHz9sVvM/75h3nfTr/seYRc4u3K+1pXxTKp/IR19Z4vYnNDEW2tUO\nEkc1Qe/TSQzq6LxB/7wPCkpAV2dFN+NRkUqb6vwFGTz96HlPr2+5nGban4ni\nYGMyl9t9mv0WN8Va+skENwHUhXNihORI0eCgkPpfrbLRx68T0ZvWs9sSwb4L\n0gksEGWr1A1h9pSHtJKpOXOQhhf0y857LO2nXUCfGzNoM6aHa1opLRrhDlHZ\nQeFe\r\n=ixWW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.31","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f40eae5-1615693924634_1615693976961_0.24950458930446984","host":"s3://npm-registry-packages"}},"1.1.0-canary-f40eae5-1615693922466":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f40eae5-1615693922466","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f40eae5-1615693922466","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2bef437fe904b94d225f3f98134a8ecd862162f8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f40eae5-1615693922466.tgz","fileCount":7,"integrity":"sha512-Wr95S/nMsF9omfWR7O+J/RafzpukLR5P6CyJfKHeBAkFPBWmQ4m1WoZbGRjXZg3XWWLNqZrsBMQ/yCELSj34vw==","signatures":[{"sig":"MEYCIQDsvykC9doDN2Gn8RUw1GUkFWDcuLM89BAdkRd1qxfnNwIhAIwrGV7DJTvknI6AlVnihCSnCOuAcgij+bWm7kPOK9b3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTYigCRA9TVsSAnZWagAAz28P/iicJKAfc9sXrtPhdNVM\ndjPGxDCJLyF3OQboBvUgiagW8IRqVwDpunf3CUcvHmXcJQEyOQmqx2wl3uuc\n/MRXXfT3bRJELXI/t8z0AQcHjJCXaOvyALCQeE2Hq0kJImNgugPUzOIblBZc\nSULRCBrkEkZY0fG5o/RPixiAPhoK25oLBZLjTvm3ToxGj7ngJUAq6Rhg0CDY\n3Jxq1vHXxB7lhE3IUbDUrScBTrznEnAfyQ/NEHL/hyJTYDPbLwQti2OaSpmh\n2xzDB6n3xO7eRFI2qzfSR0/6bzfmUSWncCx0BC4nZOLOp2EUpSDD1MsEYbUI\nU6ClPZxroFH6RdsS1r9FF5XIDiXnXJ1FQdPzbJV8FE0Hx6RRiS7riy2qyyjJ\n7/EFbDMYLVde/S9vn3IgNkrwORh4BA8gR23uGkS94t2vn3B/4nALXUUiS+9g\np+8AiVvtzZW3jvr/6gIqZkA4zMh4PPVwgYLfJSl2W24evEtrU1p1wU4vn4tE\nERSN1a0ZCZe4N1pJ+BjD3UpAYK3OFJNQIRJYvu8mq2R/TiqoXMRGZldum5X2\nWZK18XMetj5dZ0Nq9U2CJ86HHWHOpgYjoHrd/SSuEjFk2CMqbf18jDSO7lzq\nAJ5hd+de/zR2D0UfrH6lxRhSPBd43ng03HoYiKBGb+4gmEdwWpPlacIFvlgB\nhdh6\r\n=ZUSU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.31","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f40eae5-1615693922466_1615693983698_0.6364729847301025","host":"s3://npm-registry-packages"}},"1.1.0-canary-8902d06-1615752257802":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8902d06-1615752257802","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8902d06-1615752257802","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"57758063be486b47b95b1ec5e0e5e4dc4bbfdfb4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8902d06-1615752257802.tgz","fileCount":7,"integrity":"sha512-ewaWcnwpF+7ckLqFGU4Sa31dhitP0kDcB6HHZ1qd92aYa/Jw+pFa9LNxwqPyVJNiTZ229A331292V36oECW8tA==","signatures":[{"sig":"MEQCIHfaPcLqSpkXjNNam8n0znTAgyG45SdARA6UZJD4TIhsAiB0knL9DffZe3AP6pa6PSoMMiOq1nyWuF9xXSb4tk183A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTmxuCRA9TVsSAnZWagAAlNAP/0eBOXSIgTubmpeCIj13\nisG7ASw+Aowf/kfKgZXsPLicbP0Iy094rRUgWbOcp4PD+rf1giJcw0HHrf5G\nsEJxdPTuQlKM5Phy40wP1fFDeMsuy1sIZlsH9a/HdfDZeY8+MEg15itD4K9C\n+ECtUzK5CW8UiqEg3BYRS3Ppv/TZKzgNaRhfJPIr+CqJfiJ9id8XYcN3ZJKU\nhl1Beq9RBOE7ou/ZXxcC9BV7QWsjTkQ0m0W8F3jpGFcIPW+nFTMxZSsIHhp1\n+7EABYOtuNZPsbXdXudFVYu9s6LKGS3oYYIxxHWpxe88U7uBoKviyp04s/G9\nB8mdItLEo50Hj9/YNdNTREWDfrBWNOSojPg+04NLS0CxhH/DUHWgh6F1boGR\nnhu7XoZkBbniRuI6VT1dFc3w8/e7zWNWF5dSHMOWByAG1fkEAnU53vanV7fA\nRYOWm4Tu6UJ12Zfiet9UnR1cL/IvPMvD/4RM+lXproQRpzLRnNHKgAaUg1r2\nXoBLnfjeEs/nc58lCn2kqB8w4SPC6SGRBEMjymX6iSB0OQJVlc9V/Fs2WisD\njfpplIFLMPHp9uu1S8hSg/kD4hTqkFqWLNSZvdhdA+ffwfSBBVSJkZ9CFR3a\nrDzHImj+tsRMd+wfGLN2SWBlnrPcZ9vpEBghy1UtdalvUcNNu4J7QnW2kybj\nmIEN\r\n=kYZq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8902d06-1615752257802_1615752302053_0.6400224674115149","host":"s3://npm-registry-packages"}},"1.1.0-canary-8902d06-1615752259264":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8902d06-1615752259264","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8902d06-1615752259264","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"df7977e976140ef16c6a03b65917ff0e853dac5b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8902d06-1615752259264.tgz","fileCount":7,"integrity":"sha512-Lj+spEhOzf7TjmFMTdnJsySDwaMuGeyA2ghycc+h+sZ4hBHeRf/9Bj2mXf5VOhDPYqvEgcxund1zRTBRQFTwSA==","signatures":[{"sig":"MEUCIEA+RYBNFcIQZm+28djAkcF+pOQf2TkIuICuh+8pTnNfAiEAyOQgsn7/4E8XMlWgyaBOS3V+SAIksARnVjK8Pt6aJrE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTmx7CRA9TVsSAnZWagAAl9IP/2VOddRfSR5J78aFMQX+\najVlZUxRY2oCIoX9iX/btcwZMe4AZ0OgCbUzesFn38Iy33pvfGOQBw8X4kVZ\ndD+gkPxnbprlxAY+OjxFav7bpDZirgSdVC4fsOMeAbvxIxYX3c9k1ZpOKWWr\nyLvRixeKLufw2s5gMlzhJHY0TNBPtgjT47TnJGZOb8T/dSSlj6WcoUom2U5Y\nGXzpNo0r0Ufu20CZR3fAaoGmTSsY7IqMcldFGby+207UBllgr8EXAmw0+Dsj\nczAEabWjyBGCcgGFLTDQ2wLSi3b2551y7vntgirZAHyOXPQBrub4Mi8MT8mA\ng/XotpzL+gRiYAIFhFULgKTChwAW6g49lCv1KusQsqwIOQLaLJ4znFdnkp6a\nJZSvqAw+i4vzdWWbtuYlfesM4/KkYuRi4nqo6E9kMGPmb48ViF4kf5Bkpo3E\ndsIvFh+JdrveDUaXBUsfPH/6RVie9sKBqt4mOqEtM4Cs296hsKJZVKjlNcH2\nOYLhTk4R49qt6UDdnhaqut01YT4GdFxuLfiuOl4yQZLQra2ZSnPEVhbKxHDP\nq4+TYjUdWZh6Y/Ys7gt0pjHGZ+PyoUWzbGsQ12i1OBXGxWkRbVEmi81RD/ux\nTrHEIxrp5yCK5e/i5H/8t5US2m3IH2GuFUbQvrelb+kIhqC0wdrw73WpBe+5\nyrwo\r\n=p3jE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8902d06-1615752259264_1615752314442_0.8276304215595145","host":"s3://npm-registry-packages"}},"1.1.0-canary-3bf22cc-1615799778810":{"name":"@iadvize-oss/store","version":"1.1.0-canary-3bf22cc-1615799778810","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-3bf22cc-1615799778810","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2c8a98da5eba5c6155aabb47d1955cd6f4eed9cf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-3bf22cc-1615799778810.tgz","fileCount":7,"integrity":"sha512-c535NXbwij5UA/JTGFH1rWxWGs2EumGY45xT2tef8jXDRcjPN05g9tm7coSoe0hwHJl8CNTzIa5m09Y/2skrOg==","signatures":[{"sig":"MEUCIQDwTW4dSwsRZv0CSOSP4ZShttnwVcfBhNJv/3kz1LSONwIgcuoxHjxqdHIbhUl+FhAXAOXDy96wGI+MpU4tIxpXkE8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTyYjCRA9TVsSAnZWagAAu5gP/iRLyBAZeseHjVqENMOg\n74uAR5YjqyoM4Krj4b7T+I5AuFF2eZ5J3ns4W0ZTxv3qlbS4ZbXlXAlTeHoy\nb+k/AGPXkT4eZ8pvy3/UjGGQntlKKu7zR7aEGgrvprynvnLqy5YSp2MdoioL\n/piXmewTCGsBwmAEN5CUEhfZNmu2Vb4fvGf9/jJg3eQsmczkhwLa2fGn1qWb\nLh5yYRUPUVWgyY2ykLP/ZaxuMhSgss+n5SRyDhbuzhe5x3wEw6RX6XP433Up\n/NRPlL79OyppqK4H5hvOlTM9rwBujE8akEtQzbBIT8xDjuXstaxetDqX6Zjd\njJgrpNgNkbon2T2QV15vtmk7s2+uT/Vxt6FVe/xE2GLO8Wvs73bqZZLICPIK\ngoib6U8RCDsTogOfoBROSzuD4IxYIZolg013Thm3e+OCSwqhB8r2bBp8P2DZ\nTi5PA+AWQZYCj4dDbB8n0+6h8S9qCAvINiRU1poAhKekY5LfdVUW0/2qcEjw\nFU/vJePtj+MDrAEKyuibHm+EPUGjf8YjWKWZDYMoX3Id5u6qVs6h9no+MK5o\n9oZKZ/bm+Q4KD9yqp8u2rq7bURaqNAmBQEcUPg+Oln9Vm4mxA7MTbPbpnTXN\ndn1CteB3j9jyNYuAOt4p0iVzScaKcO9wh+SgwprtnELR5tKgGrlPiTuFTddi\n/Mbm\r\n=BnDk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.31","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-3bf22cc-1615799778810_1615799842532_0.3520193968022449","host":"s3://npm-registry-packages"}},"1.1.0-canary-3d25e74-1615800420662":{"name":"@iadvize-oss/store","version":"1.1.0-canary-3d25e74-1615800420662","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-3d25e74-1615800420662","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c0fac15ae91e2d996bcbbe021e7262b94fbe204","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-3d25e74-1615800420662.tgz","fileCount":7,"integrity":"sha512-swo8yhXIoKcmvj2aDCJmB9HHW087QdHsIbSJvFpTF8i0z4jlhb1f0sSkrxEiaSR1pRCXCn7uc/kozy+ma0P1Kg==","signatures":[{"sig":"MEQCIAzwPBCd7BqvqfTWkvO+9dHmL3U6XuUCERYvtEYJNl9wAiB7Hppc0/nz/7igHySYl5tNekJGgyp+2+9gRPYTAFlnYg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTyigCRA9TVsSAnZWagAAI/oP/39MBWjL09OYVJmNtPZy\nFtO5NSofKXtVn+k5hEVYcF95ZrE89OaY5SFawtbI/VBBjEbQW0kB7e/0lPZK\nAFNSgfokb3TqEWKzeDDqZSzdOy7C0BX8Uo9C/L3fFiqEEZ5ioG8WBPrFhEiw\nSpWLPV3fK0JQ9xc3VfQBP4iJo8JTPO/B41sYfcU9HxblAE6hTuPGwax/NWGh\n9Wu1Y1tg8ZLydGKEuM44t2NW/JPc2FtwqiW8Dz9CCl7tUdzFVUHbcP98V7NQ\nhV2Dl3CiA5BsbaSf3CRc5XlNZR7bpvWO1r9hYTDBTK9P3V68H9c48MwUQxF0\niWpb+735F2H0+RFkkuxik2ByIR4kAOBnBuLQ6WmFQdY15SYTxr0gRNcvwm1G\n1cyM624biAwAudQj0fcOryei2T5O41WK6mvmveCJooxP8CliErQDyJdrxJfj\nVNWujJWQtVJ3kmTWPSdXDrgoaTdYdBDs2N+ZDFZCGTzAJWsRcY0DEfcv8KVh\nb/1lsa3upOZF2FPZ8+xS1cBJDZ51UCkd91yc+1zBCv73vERzelJvIsKS8+1t\nNApPV4dSim10mRZVFAlX8zW4bpYkeD296F7w8ZxOhkix13Rw7mgDE+/+XoJu\nhTtecdxWT8fdKjRtise2/wJ6IUYKmkONl9t/A8VVnYePBfnbWbQowUIujrRi\nz8Yu\r\n=nEFT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.31","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-3d25e74-1615800420662_1615800479891_0.7599903186429624","host":"s3://npm-registry-packages"}},"1.1.0-canary-850afe2-1615800819347":{"name":"@iadvize-oss/store","version":"1.1.0-canary-850afe2-1615800819347","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-850afe2-1615800819347","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"729a6223376f0a3312bfa721e3382a6206eec895","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-850afe2-1615800819347.tgz","fileCount":7,"integrity":"sha512-+SlGRXArx2wq7V84skTS1FVVbZfyTsQUrVxPJgq3aaY8rjYnDgVrPOJlfVEV2FUMRb9LuB8mj3HHl/6oJITMbg==","signatures":[{"sig":"MEYCIQDbYS45RlXK46jl4QBIawdu3VzDyjb6i0LQzqPcj0+PIgIhALacI87YudlZgDzkf3f7R6wxoXSPkNjwYoTlesN1Gcdx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTyo1CRA9TVsSAnZWagAA15wP/jxoCBNHVtxa8MHwAkkt\nC3ItY91I4kcvzGRnsK7UlI8lcuozHNCLPJjOhU2jfwPxtM+PZTRmnivyw8rt\nsfcDlWv87qLjt+Kv4YC9KaJOVTfj8xcfIDV7GJI9p38Tr2UW71Sgf/CxcESq\nZ+1eg8VdVh7PdJIWYAP7+6sW0U1cV4XeLs1hZTdf+/P0iQEsId4RN05pSHUf\nCPOWyxs5vk5aKp4CPJpIni9qam0WU0q2G2ymKeBUu/c2Ojt4FIJHJmv53mlw\n7qfv8BZfIJJ41lhIEaV1Z0Y0JwmU38jCn7S8FgUBdlioUw2YvBPjidxIMEeb\n78nPGb1c3NgbLJOQdRWsZp8lLerap3zcSj6bUztVjqsrnjclG46yi+YnWOEg\nUJWd+sLNAu3lEoCFfgAN1bsUURwgmbtpBSfcecK7tAEAuhS+ylzWmEWAnsAr\nGmC6V+mnOGDEIAABCNWXVmQEF3a3+iLlFirKoDBgdDuRIDCLjPz//WjrceQu\nMrFWVfRVxIJTKGkwXPdAt0a/RDaEetyUFCYgca5CKBIxnbOQ5aChztU1TiIg\nB5P17AxI8GjYPBAe29mETvPIqGVuSAQPoR5tM9f6PGmejGRdn0w8Kw4va5e3\nZz2L4OdfVbsycDP3a/e3Rb9PmLmqJoJEKAu/wyXqjal1OfL7gkqClWcSNOxk\nINgr\r\n=ozY9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-850afe2-1615800819347_1615800885474_0.10896627344707843","host":"s3://npm-registry-packages"}},"1.1.0-canary-44ff3c4-1615886606779":{"name":"@iadvize-oss/store","version":"1.1.0-canary-44ff3c4-1615886606779","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-44ff3c4-1615886606779","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"84a97e947d707b93efff461e378c77ea5d1851d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-44ff3c4-1615886606779.tgz","fileCount":7,"integrity":"sha512-rJOQmzkgpcK3i8IP0DEebQphzPPJlfLQC33mtvtu+XH3CtKnVlWP7vNRSUADnjonbCjRW/iBwkRDUuhAl2PsmQ==","signatures":[{"sig":"MEUCIQCDUhq35645ZN2WN17zvOx4X7yVcno+nZeVbqbdaE/32wIgZTrgyeUiX+1XK4LxVELCGfZ5aY+sFGLitf2xHpsefpo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUHk9CRA9TVsSAnZWagAAa/kQAJu9W2zD18f2ed/ottC7\nSnPUx/zCkAbg3Ngl+qMqFXxaii8TP5uoDGBt/euaTryLJ32ENHGcPKK6qczB\n2uOQ54p+B6onptJLXaLm1dmKBJYBzDzla6VpWYrPnALc/cgmAW/QNawM1jc7\nwoyuC8aEZBahkLLWG35RSGs6K1KI948/KxiC8j2CdLAUhqzIW6LkEcuCluET\nUeDjvQrnj/CM7HLz60NNsB+IVusGCjvaWbxa3IhYZ1sn1jV+4l+MTfhAavma\ngoGDV0qJ5W/qwXa73ChVWLzOn7MZUBidBuBaq0Kb0NWkustx82Lr3ovGTbGp\n04DF7uGECvpIHLf0AklT/EGjKdMBaPZprHh8BQ99ESGZCmCTaKbPMpN/H1gp\nFKlA/0CSWkYrAoyGrhEx8UO6g0ZT9k+ZB7IzrVa/31ZzeJJIGi9lgfeRxlUh\nMG2txZB8nCeGFsRKY9LsFMB0clCZ/t6s2At2W5FeZUeolLtyZk4m/mITTT0n\nPYwkJP0YoDZ3uu/gccpwDJxD7PCYP6B03hFLy64emtFvHlDNRk1Yi+oksPjN\nf8FWvdY62abwi8lMqz/g0ZJSyPaQajWn571EHEnjE2PajPyYaRar4kpGn25t\nrSWSWn/toP648xsgav0YsOAO4PGIqmhYZ9oL6GUtw+ic1lCNwbHILWWCEdEx\n7ly2\r\n=bmkt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.3","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-44ff3c4-1615886606779_1615886653263_0.31386937351717226","host":"s3://npm-registry-packages"}},"1.1.0-canary-37462ef-1615905110470":{"name":"@iadvize-oss/store","version":"1.1.0-canary-37462ef-1615905110470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-37462ef-1615905110470","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bab1b3066efe96cd31deca24e2baf14914c31186","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-37462ef-1615905110470.tgz","fileCount":7,"integrity":"sha512-KYF4bZDeIoacHUsmXRq7lOitHtOjhXq2ihTNboSmrfO1hGg9kVtBX6iszFrhc3LllDmmqq+SyVmo2JqkXajuCQ==","signatures":[{"sig":"MEUCIHRmpnjOcejMaBpe/rgDqrgcFmKk9bXGtJt2MZhytC3zAiEAmw1DrAQu+XxuFdBuCKN4t0+vZKUzxm7OfGMHZV9azPY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUMGTCRA9TVsSAnZWagAA0dQP/0ydiHHR+vG51TUP1+Ze\nslfuFSWBjsjMYhtyUn4ZIW/QOoMwE/w24lnA1GDavvGq6EBvYV7O15plGp/O\nAglE63sZrto+J26775GW1Dr5wL/VHjxq/IwRMTWygcnxmBm+xNJsxazXV4mP\nTZe0ny4x/QujKUp2aOkVGovnnQDwWHCAmR4jgxtSes+hj7fTHm4PTQ6YCWE1\nAAVeI7cYUZp9Q/jWVVHItj5bKQB53BqpPqL0KaMyeElrlPsREw9Os4DaakHn\nL5jad5UAY0fMdO04LLLXntqcb0fJ6ql+r/WqE9EU/I5RKDBrMNl5/M2MP6eM\njSDMuP780rAy+OY330rfmB6WD9cDp1zLuobY94botcQwfq2t5ELP2hqJQGoj\n/oR7iupwYK0RlOuISpeLOUxFfX3ENsElk4qbiqtNssYUyXydiP5NJF4rRYe1\nwJGKNfHc9xovQNh7kb0Z/62drUZ6/a5lKnOVAHALAQLg3aLMIho3BJYeQAGY\n7EnLKZO+tINBCWzpqoUX1e5VSRicr8uPjcbpcxUX+L/7FaS3S9GqgdgKufzp\nlmEWiPKLVSbA2wcOTNnIDhrt8L4n/fSpy72PwW82PLtCgKU0LwMi/hTbpy5c\nw/1t+HlUIievJhwpERwGwmG5sCzAQOJk7+Fqxu4JR32m5EOb3KidWYh/i9xb\nZtij\r\n=5m4D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-37462ef-1615905110470_1615905170828_0.43321112117042326","host":"s3://npm-registry-packages"}},"1.1.0-canary-62a30c6-1615906787265":{"name":"@iadvize-oss/store","version":"1.1.0-canary-62a30c6-1615906787265","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-62a30c6-1615906787265","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7cefc7ab9105bc112b6dc99f4eb091e099de540b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-62a30c6-1615906787265.tgz","fileCount":7,"integrity":"sha512-AW3+wWhR3XHtq5ILWd2IY+CMAdbSThwgFahobB+/EPHW6ApLc6t2PRBHxgTjtmuZyt1RzV3f0GTNmUFOXTyNcw==","signatures":[{"sig":"MEQCIAs1sUTIYy/uj5Xwp7SHe1ZE6OGGsjFk8V7j7DJzj9P5AiA7Mis76HtI+zkLtTdiON3RSKvCbjoBj0zR5fv4wGclyQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUMggCRA9TVsSAnZWagAAFzEP/3kfKqNgYtWF0Rl2p82m\nqY9i9BLQVcksPH4xdQSktLVk/4ywEdsbSL90ia2PEyRA7JClwmFC0iKqrIT6\nc3bHlzbARDfvwYi3vFEBce3wsERFKC9L9jhU93SKnkVg9mMfWkfGiIAKMGWw\n5B52VzD4vSLWS3E2PJKxvxLm12fPKR5U5YtwJEX8w2ErBhx8jr8SVYJnjzVn\nR3R+dK73pbcf4XxQGdfojUXEsht9EqgdLIFxRDs44ggQ3+h4Cd5JwN2vCZLU\n1rWBpJ2U29wCjL5g+M6h7dFtqPVQKVkMZRmQyWvdUpC8zBiVl4mW7W9dkX2F\nK7v3wnzTIrI9hQJOkiq+qI5OIu/oOCsNwCrfK90/LjOd1BpX6bKCuS2m/Hri\nEfS+aUJM4bQ8n3N0kqWVpt7iPF1HKbhNmwmppwaj+yjUvwK1tsP4aOb8SfOL\ncHxCqrEIhM/eb3TmYkmJMwNzirdtEHbpKSJ+vh43aVaywIyXC5s2amnBmkZa\nqjMFgU637TBFHrLGNT693gBwRkQV831C4zOUd6sNzWtdeif7xxIMsfM/7qPc\nrlyEz6+qtKeM/sEc1lGdFna/J2nIlZf7PxIYpODVCwOk374puH1Wt9h8DcHs\nBhz+XVCrtpr9CPopUPv3ivpTTZdynmI69aChANYmU9biCPAmzk4WCQX8dji8\nsRQ9\r\n=oWgF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-62a30c6-1615906787265_1615906847748_0.4143453113367004","host":"s3://npm-registry-packages"}},"1.1.0-canary-7e1168e-1615987984527":{"name":"@iadvize-oss/store","version":"1.1.0-canary-7e1168e-1615987984527","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-7e1168e-1615987984527","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c62aef2f5341e1700bdc607b1b8d2ee83c18d416","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-7e1168e-1615987984527.tgz","fileCount":7,"integrity":"sha512-80A6ImSlZlAEJxKL2FTlgPWaUMCgMB4//+3famGBkvrqLwCl8wLqPjefvTpA4hgDtUpNvEmHqo0HomEVV9nOFw==","signatures":[{"sig":"MEUCIFGzFNTZ3Wl5OnFeosGwBMC0Pm6WYatGmYC29uV9k3DPAiEAtBw+qigN6lM/F/BFnzd/fpgcZ9fxOiaojFKSGuSCGXE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUgVSCRA9TVsSAnZWagAA2uIP/1vAJHN+Cy3G2gKgBvlU\nGdiNrN/CqVlbP8WMLSFCftyiCIFR1VScYFYa3lgsycAZupLGYabpxpxOGAuL\nbklNhn++wXEY291jOMPrvjmM2IX8quXq6rROsHChbdHaEOHWbAuNrDU7tz8a\ntIW3lfIc/w8MVzR+5pDxyRZKwFCwj+MgltB2yJZW0xhm8Un9+tkASwJkchep\neiXYbJ5H9i3+sFeckHnRr/Wi0Sd/XJFR79DQBg7B1QkhotvnkVcWLO92Q37M\nfdkO+Ht8GhtWnXleLzph1gA7XZVnkJSJPAI4GpGZs/lcmN867Pl/DbP6J2ph\nwWHAcW9Vi8KanHjpiowmK9xriSU7utYH4s8vl2UTokD2nSCir2RzRzZTCgAw\nKSQHoh0zKrhA90iAhMg28G+1PAOFyDGZoiqM0aEcAQFnpuwgZlmzK8tqc8JT\ninXEt3Gw+6MawbKzPdmAzbaioKuP6WNU2bLHRq+1sIuCe370EBVOPLxTpUOy\neMk7EOjGdtZyYpZPaTCiC1AeVdlPZQ+dShKPhRM4hSBuftIAGDlRt7+UVWMe\nSujVePYUDehqEeD0N7jFWtnJQhc2vzBN5TlUzGt4pLU116KdFvbPZ11O9To3\nz+WWaOuocn9lVh2ggpM7hUKRN78+Z8+8lbUuwMQ0RU3fqnCa/ME9sMe9EbNk\n28K4\r\n=Zp1t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-7e1168e-1615987984527_1615988050145_0.04458477687903173","host":"s3://npm-registry-packages"}},"1.1.0-canary-44b1dd3-1615997027853":{"name":"@iadvize-oss/store","version":"1.1.0-canary-44b1dd3-1615997027853","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-44b1dd3-1615997027853","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b4254d7a4dd064d7713c58c0f16696b6c67496a6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-44b1dd3-1615997027853.tgz","fileCount":7,"integrity":"sha512-EEvoKwz/ICD6gC4m7LHrJcXlTaLG8NhImBfbOa+2Vr9WewL7Ydg4DdJdAxPxxvD1IFN09/qcBvR9O8uucNKT+A==","signatures":[{"sig":"MEUCIQDd58AWbBiPNHO+uCFeCvbYjkE4MvzzEMz4KeB+9XAmIAIgEy+J7800XzdYRqOlkT0XGJM0mCsRpyELkUhUeuZSWfg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUiiYCRA9TVsSAnZWagAAYVIP/2XM62nNx30KA+nf7NNq\nihm1wJx00tIfrTbKSTX0ruDZM/oBNfUZDfB20Q1e6Hm1y7S529DAOct4DEzd\nNCfmpy9vlAw9mCOlguDDqIPdUhOz2MwWX3oWrdHoSw2EJMwv0YuL93GMor9f\nPEWkJ/jCi9OLHubZDCjeucudJiA/T0LsHWnVVNtZaQQd2t6qyxo5iXWQAXs0\n4+l50+6Y9YIhfM17WnOR/F0ZWS27PDQBeXUlD3saKro1/Su3AHcsgxTs8njN\nf99LiarBzvocoqrtrwcABqC8wsMV/Pw5KXKGUvdqZ++ifcG1tKn9T1mz0TVO\nwMUG7DEJjNiaRgKcotJIkaGK86BedE5d81FLJsIyBTFmiaUoBdCYSiq4tgPZ\nRHyZQOe/sSZrrKZ+uBPtlPAcyLzJrzEf7r/JNncbLcY8I2kGPOnBJJ9hmwCQ\nylMvfibfkRnEFUyTNEiKY/o7LMYEJA5w9y/hel3GIvKbPJXeFU94Pgn4YnE/\nktadJ2uIuI15SbSi5WbvvJlrX3r5pm7yJgARJzMZEIFqdjOoEHq/7YOxWjpD\n89Q8uIk3B0Yen0mY0pTkrKrDprpP2EklREZVhUKTmfs43ZHTDAOrIHQH00/+\n8TEJmX8fl1Bx+iaU5em6SsWkaUqxBW+KhL77cXqNfYXYw65V9UYtsDAxZ86E\nB++Y\r\n=3NiY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-44b1dd3-1615997027853_1615997079849_0.11906150834192197","host":"s3://npm-registry-packages"}},"1.1.0-canary-adcea0c-1616045280313":{"name":"@iadvize-oss/store","version":"1.1.0-canary-adcea0c-1616045280313","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-adcea0c-1616045280313","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"07f5d820f0752911cadfc7a108d38a2ccab6160c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-adcea0c-1616045280313.tgz","fileCount":7,"integrity":"sha512-gQRSv67ia7XsAiKV98RPXlwer26OpvC0gu0GYViEKLxVT/5We3rxhF4nycKP2qAa6b87NRZ7C2ODrtciEUH5RQ==","signatures":[{"sig":"MEQCIFpNud5yZ375W4ootprRCS1b5Cjb0fIKgF5jae2v0PQ/AiA3y9MRepeX8UkhZztHjR6NjMz8gy51832jtywqnRaDKw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUuUNCRA9TVsSAnZWagAAgJoP/iO2PAM5+JDqOLeLXl9U\n63fTbJp6eGzEYWBpuNYBNPsBFOaCu47LTLaR+JM+OChkbFxAbECSuKvV3R3o\ndL7+4uCmlbxAgI6KkoNyp2IY7bIDaZd0rGOrY7Q8a2KYnq/6AoLgR0DFnC7w\nXzKWLTU/0Dx7j3pM1Gy2ODFX4bPU3sEb5FstG3xk1njP1hkUWssccEJcUmW2\nKhv0IxrRSuG6xMjD0mxMDc3Fo6EDHX36VvmT6D+9nzr0ffMVM/el4388MVba\nSz89RyMdzH5U+dT94Ooh/GXFcWj/29faPBzhlSzM3d3nuFu8W2cXHjUSCy8h\ntV1ssxmVWgfN2pU1GBDV6iGD9ZNM0US8qEIJOtg70S9zqfFSzjYDQ7IcPkGn\nkm+QZj4j0qnZ35xOn0nNvn2t6oG6moj1DHE570K5LJRiorvo5auMjOwVt5lB\nHlAKVYrNkhyv48+v1Hiiz2w+XbJTYlc1KTdL8OS1nBPDRZSBw4buYJGWxBdF\nN/FmPriMi80jS2b0ch3KJs5O3K+e/aWx4X0yCQ+zRnO04vr0XvEbg0PXyVQY\nTZaq0F8MGMYRT2VmlVxXkh/5+9EABqX2ZATtyKm9GqWF8qzaKqD9rKaHJf9R\nOqcxqw0ylcbGqfTACEPKJ7TyDHNDineaWdVwPYXrTNdQkgkwGvUuyC+h4OeW\nREh2\r\n=5GyP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-adcea0c-1616045280313_1616045325220_0.9322693219210414","host":"s3://npm-registry-packages"}},"1.1.0-canary-adcea0c-1616045280440":{"name":"@iadvize-oss/store","version":"1.1.0-canary-adcea0c-1616045280440","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-adcea0c-1616045280440","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7660d4ae08a83f569e4022c5a39bcab683374589","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-adcea0c-1616045280440.tgz","fileCount":7,"integrity":"sha512-rrQMIQXM+GZAC2hQpGaa7irU87SrTpm4kWxDGi44FrMaZsRwKyFHhgmTx/+2NJ+F4ezZhqnA1irKGwbbXUDsHQ==","signatures":[{"sig":"MEUCIQDrVNtTENKSZfdeqKSHoek/7gWT6iAxk7Zgr7xxZWro6AIgRGUUea7LKhemInemU57Tt7Xi4j6qrwli5oyqVrcIVJs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUuUVCRA9TVsSAnZWagAAsBcP/3SEaPXi+dXK9xaB3pex\nsdJ7U8i3Gp7U7LzRcclEIxabSPwcThcJw9HNN6n0DLg2LyvTbZgTh1ImRl23\njilpca4OHZeH7DAmW+s3hDAJWJgd+xjN0Xp+85SZXTf9EBTm0+IM52FMkIxt\netZoYbYYKj6UoLFxfh1/+3PNGm3vhOY9XCGgTHrRvObMHnjkX4X5wTJD/lgl\nB1zSSeJoeGxkYiTx5OMdAc6o2oWKBU2/p4pYkKKLOE/Y4pGggfkhLpmOlxwq\n/Zyh1Vz886lIESJVc804tgSKl/rHLWccH0w8bE4B+NyUDPIgUECA3zbazMbx\nQ2kdoh/JUgFTbFaeD/Tu0rYB8ZSVKjN2INIOLbh/vbDitWCGlZ+81wACyMmJ\ngEFoPIdZD2Qyha7/fTCYQBmsdct+yY+O/VlI9lRsA3FNFrR7DanLaznnl345\n7JdfF9hIB4mWLQX8KF4k+SNUUAJK3HNaAWLeItZRG1E68wRWCALhIWgJIqJZ\n+uAYVsZbsd3+dqh4dECZU0XaftZIHJqJkVM7lfItmfdx+OfZ+rzIuBINLit4\n1W7aP52ZiCwIXeuyGFK7e8pf2gvMpt6vll/Vf2t4rgSYOWayfWBuOjJlDXXJ\nxrc0BrQdUXhIMh/s+NpY9qrkv+ys57rcRyu90nRxtgIGcGRM0MfRyNyUS+2Y\nha3i\r\n=ozZb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-adcea0c-1616045280440_1616045333113_0.8962805255343707","host":"s3://npm-registry-packages"}},"1.1.0-canary-d4f6973-1616060337259":{"name":"@iadvize-oss/store","version":"1.1.0-canary-d4f6973-1616060337259","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-d4f6973-1616060337259","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"eab84710c63eb4272f3f34a77c4605e2995a5fd3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-d4f6973-1616060337259.tgz","fileCount":7,"integrity":"sha512-7tQjkBMrBtiuRyzbyCr1nDSK4DKd6/KfGr25yij+QRQQKl8gxSDaEfpXswzGkpJelGdjP2Vu8PoHInvFijzmAg==","signatures":[{"sig":"MEQCIB8eCoSXI88aa0tG/CZSGRYYjEkRE1DEXa4DbblU57GOAiBVufMI/gUBBJk6xgHRFZlndkYVI2vibDbhO1T8ESmmlQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUx/kCRA9TVsSAnZWagAAry4QAIah20sIc/YDhEdEGnV3\n7iT8KrKy2zRqmayctdPn4+634PvROoUObWQZg6sxqXmP0mnfHBBRBlBby24k\nXcHaBtDJ7xNVBytmN52X9abHHMnFrFGY/WmaBCnQruxrcg4C13J/PvmF7x4C\n9QZYrRTWaq7rycBGDcdBC6iyupe81Kx8kFT6L+hUD2esbm9oSHWlEp58VZTp\ndlqBA/vB8RPBVuuVyup9fogORZRTRujEePZOQRA1YblFrDGr+hNr9GqEY3et\nC8IP6INimlRXfkveMD4DNj/2NfO1CyM3bw1Pqje+Dhxb6m0k+wHtGrC6VEFi\ngAw4K+RrHcLKr0IrnCX+/F+90PQHD6HqFBWQSmJVrmuSksFjbahazS0zB5rh\n9J2xTxAK6k0To2JlOahABNHgpaEyc5oNmofK4O1wJEQTLTJBeAvgMI54+tRq\n6/wBT3q3SwjR20AyZgKFESGR9tOGOZSJfpvvJ6o4xzLdRzNNI76vla5g2GSV\n9Xkwoj92Rt+B2BZhQ2ZVyf1PAiAOp3u+DdpaEjJS9UJjzy9Dvqpo4S2C1ZXG\nnHpj+rIlefvvqu2XKgd/LIVMSCU1sDXIUvYE4EOw4DmRiCu/sWuLX0DGei4b\nKryjJU6x3aNhkYmHKiy5yUmteMwLYg4wi7gb5/WgbuBrnZ8uBIrtmeJncKGi\nDWW0\r\n=s+NM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-d4f6973-1616060337259_1616060387586_0.06921424051181058","host":"s3://npm-registry-packages"}},"1.1.0-canary-79fc8ba-1616060591727":{"name":"@iadvize-oss/store","version":"1.1.0-canary-79fc8ba-1616060591727","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-79fc8ba-1616060591727","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e484b88f6471a683fc75e05a9843ae254db5d36a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-79fc8ba-1616060591727.tgz","fileCount":7,"integrity":"sha512-IJ6uaTHkebShmUXlEyRAxNcCStlqIsoavbj2U6z/DzIN8vv5k+xRHBDCJ2eZCv/h5cfYMLY9zmV9dOp1QrBE5g==","signatures":[{"sig":"MEUCIQD2vWEvKgzj6OTtCPLsl3uitEzbf5Op9FmBPkSzCk1O1gIgd6kwN1Wk3EyLrDWOIwAmD+TxfbXcVQPAneBMisjyJO8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUyDdCRA9TVsSAnZWagAAEt8P/2o0TKZceTyANIP0AeN9\nU98IJkFlOuZAUUbuvlV4CPZqYXVrm13XcG8LHlrbiCXTX9ZPDO4Nrxh3+Jcf\noneuqPJTCMgvL+gpwnM/zaU0xckso6O0QX0bpdpFAmMKqcw/yqmISR2HKI6e\nyi33X8M7KHEzQWq3JBU7cXZ0nyA/yxVn9tlstSDG9xrXuvMnAjMY6Bv/zhPS\nFkEenx+FAh1T1ZauC0mclwALyTUd/KuSkcdUHuDfLIbbKQP87XmDrCGVG73F\nmgepeweQgVP7TFk+P4TOqIJ+Vue76wBeFx8iDjJ493QnB/WowrS4GBMJ8aYN\nvnD+phiE/SURJI4D7jKyDKnwlQn9/Ak4NqlKQHnv0mRH5idBblpWlbo/74JA\nupmnbuFJ40Xg1EnCefkhXidhtMsxJoVd0OuI22EE76xsgWNhtTfeV39wTFRg\n+H++VsJJt8MDSCy8cGz83S96PjwZQcvQ1ejpBxjwsZ7aNXzxkW5jIlbGumNc\nk84VCn0ghuBh+N43bT9UzKZO4AZRgMxRWddPdqSrRA0PdiKdJ7fmMByqJ8/l\nyrDBrmQ9dq0bf6tSbYIwu3efMh0yMAvyaQ0Q7d38lKJd/cObrRkvTsYaauQy\nne1qCossQOutBrfY3zndI4/HCy12ixWyuCX0YMrMN4pzVCTke0h+rE7uSk1/\ni9vS\r\n=jsox\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-79fc8ba-1616060591727_1616060636571_0.7529781548500887","host":"s3://npm-registry-packages"}},"1.1.0-canary-a17cbf7-1616063819474":{"name":"@iadvize-oss/store","version":"1.1.0-canary-a17cbf7-1616063819474","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-a17cbf7-1616063819474","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1cc32feb301a4805932cbfe06b4aaedce7af8803","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-a17cbf7-1616063819474.tgz","fileCount":7,"integrity":"sha512-7g5GhVF4x7TOVVOgP+Kh6qkT3JBH2DINyw9Jrahak5wyXQhoWOPomF+DMeDeNZ+nKytvTkr41j/cZT7l2aps9Q==","signatures":[{"sig":"MEUCIQCQhCCzgpChRUU8DbYIiOi/CzelPb+0iUNFtSq4oRBibQIgPQS+q/KsTfjhtZ6+qmFZaGtbYaOTcmf8mSvmnqnERU8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUy15CRA9TVsSAnZWagAATB4P/2ZJY1MaqdsYOxg+TDUo\niSYZKphzQuyaZkp+ay0F4M1hI4o5A4qx/soPlkkiTeGJ8d2ZFEG8x/pNM+mJ\n5JGmsnnnuSwDCJ+cvDlTO4cCAGc+vfMz7MqKPdqFAM5+rMHLhc9FWWfurWJE\nUWnVhfVFhdTukJZKF+x3VrCubrpJwe/cLgGLWwr6mh+GSuRpvu+IFkxwz4pg\nLk6FUVOYMExXirCQGIrsdkWfwjsHxX//2qIZeLD6FEOKWnGMG4xU7aInPlN9\nq99RMPoHPz3reRyEO6mXsCjRUSMBhLmRHfWWtxCyegKXMYeVOEMtdUIdPsX6\nSzcu7fFNw9MgkkwpulnCRn5fb6Te/88ADlS2KJu9zAxXU+x+FfAn/LgbD6fj\nUzxJ91nVCkKrtGAUEg31jSR7D7AyfOxYZr1qWpHR+Xijz064XAHURNE/MFoG\nTfrfYeA8ntySocdbuydEBwUlvblnqG2+EIirD25m+12DQGZhFrh9LCZPJ1pI\n1HEe1eGj11iQFZW6dzrQhxJMoMYGQ1zUBkI4j0bzaV/uEWqSinlm7XneAlLJ\n6DHN4ncxCBjPjgaeWVkUB+9Yg7OHOn4f7Hln3ZjgYJnsN7RdAMCiRP0bna9d\n2ex9tdd9iwtcW7NU4lhGpYkLdIW2CcwD2XGgNSuqf386bKTZiN00d+s+4Pjz\nFVdn\r\n=8mYB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-a17cbf7-1616063819474_1616063865244_0.5898505656016024","host":"s3://npm-registry-packages"}},"1.1.0-canary-35f3055-1616142590162":{"name":"@iadvize-oss/store","version":"1.1.0-canary-35f3055-1616142590162","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-35f3055-1616142590162","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e62ff2ee62ac2d89ceb34d79e858d5a6a71214fd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-35f3055-1616142590162.tgz","fileCount":7,"integrity":"sha512-b/S8oeqAV1NqI3DXP6iYYsOa30wg0oIIH2KuiYtHxgI4W0jTf3nI7aZjxCCVBvk7NgHvdy9XvgAPPQoSVQYRpg==","signatures":[{"sig":"MEUCIAFIZWPzDgGhYdalyYuhVaXdR9SYJaSKr/Kzo0VfyRIbAiEApqadeAOmfj97kE1NEDC3d4zoLYudB1VySfV/72LbmG4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVGEyCRA9TVsSAnZWagAAHvQQAIJvdd2sfxGe2X5i4B+u\n615nqmIiRn3wzZfAPs4yXSefwtEOhFNOflEKy7EBosUebqsSX+5N7Y0UiLhT\nnTbYrVZYK8j4CWKiE5s02IfHZ2VGTbsU4R860RiNTJOYIcGDVfQcrhbFa8pq\nHZ/4mwVel6eiLKh8BLeeJ0ZeblzsMHzzVS5i84pvp4DM+QuqLsEcGfRmZPjj\nne4vTNHpHb93lD4bP2+ezigcUGW4ujqeS/tHm75s645H/QcGhpJGK3GQ9h3Q\nIzlyM+VwZrShrh4DYJCLdpsqVEt/6NLGdow9Fdaz/HoCSaeapvI9F9tajFk7\nUroXWabGxZcBfU8QSMPwAPO51Jf5eb71IpOQ7WtTjdcf+qNQV0snBeHE0Dv3\nMoHwKQCNbR0nspmXao3SuhJFBJtu7/5ZK7ka26GoHHxXl+SFE+Q9ic3hBLFc\nwmhQUhwQd4aSBfeVlTZzNfFKp1MMSqUjHRNVJDzPUulAmhJJj9Y5mjvdekwV\n5QBID/t/4Dy+xECfEPpuhbdcVGf7Xo8msNBr0tS0n6zjkiV/LyT4IMpMxv2v\nz7BST/ou68LeMNzkZBharXicISVUb4oY9mntCVwG/iCvgU24/rvWj+rgral4\n7ED1P6ziTNowHhQFPtzMBIoQb9cHFpbpmc7vCJywjrLnjVT6z60ux+D7spdV\nL/J4\r\n=uMsy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.0","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-35f3055-1616142590162_1616142642394_0.7894560720745729","host":"s3://npm-registry-packages"}},"1.1.0-canary-35f3055-1616142592265":{"name":"@iadvize-oss/store","version":"1.1.0-canary-35f3055-1616142592265","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-35f3055-1616142592265","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7db3b0eaa2f778f5801273a82c794cd5b6afa083","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-35f3055-1616142592265.tgz","fileCount":7,"integrity":"sha512-IOydAr3ueQOKIiVmv+d9u//C2+njWzFlUYDya/VG4i5sUlmjRPN6am1Q3ZR8jhi+F/nUo61HFZSISDqAyPRu9A==","signatures":[{"sig":"MEUCIGrekTHX4SA/clFW++mJ2s0TAQVbdCzQtOs+sQ3q9IRkAiEAxr5VkqzWkQtZjszyZymZ+APDFklDfdMbJ7apNsaNvZY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVGE5CRA9TVsSAnZWagAAXIkP+QF0GwvOxAdBoMv5nfLm\nP+6JWcb3dy+eo/HlSA55kGUVCjUgRvHZS1vLkAppsaczfb+LAl0Zn22yIQf4\niWWH8lO5UneSMQz0T3QPiqwWMBh8RIsdrQumgGOpOfkshupLgInzEjdkGDO4\nmQzN4vujkXNXyvK1bGdHbXMe/RR+vl+i5Wzfva7+VlrNK6MX2gp4i5HC4smD\nNV4dgks1rzkkcNLfj3+G6RcMjNqYr7cJrLRqQmzsTuRTx77QyRJa/GFI5wLe\nAEER0qO8kuFXEbZevPf4R58zhuXqg8qy9TACypz9BSyJYXWHhi/+xrjRxW6Z\nK9wr2O0UlL/yPSisaGrzHad8EQoG4uz7MKWCIXdbFx9szz1lNkzt8FJiR711\nvZ5GBclA51xfGxDMWej3dZa8dW39k70yU0oIfoRZrLS7s+RoT5a65GJCkL5v\ntbBeN7Ti6OZo9yCjl848AnDRWv/LNLgHdCDWBhoX6Mr+Vahll2L722Lrd2Ro\n/puxw+om83rsKKQA+EuQgKcQwpniedPp0qrPQ1SJHbB/IytvaLRrl8E5vf2q\ngZhsdANZXbOfpGukDUX0KatjqM3M431/XQ+UB9q42vCGmVbcBFowkj9sFNqf\nVmmnkZIzek8HMmFujOCsZCVVI5vuzDMwm73GXzHDJOK4mFBgkPb9tg+T6iq7\n8GvQ\r\n=RtdZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.0","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-35f3055-1616142592265_1616142648723_0.29091414336822363","host":"s3://npm-registry-packages"}},"1.1.0-canary-213eb91-1616220408100":{"name":"@iadvize-oss/store","version":"1.1.0-canary-213eb91-1616220408100","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-213eb91-1616220408100","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f35a4f0b0793cd66e01fdafdbf62956308e20245","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-213eb91-1616220408100.tgz","fileCount":7,"integrity":"sha512-Ko6YO2R0bELQH1kWPWgQkltXwOy/WERu+PmHyVqla4C4h4/cL6alfs7m8Yh35XuXGRtQTp9uxwoLubFITOIXyg==","signatures":[{"sig":"MEUCIQCmJM1kr2YuyH3Fq/z7lp31eqZylHEFdTS2S8Mboo4f4wIgJsA/ddsxX9MG3d23mHkTJpZvUmX+NIEBrN/JIdUHZqQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVZE5CRA9TVsSAnZWagAAAzIP/2Gq3JnqwX314Mtg2Mxw\nfjrVOvfbKcmgySZ12T58Gx7v+RIbxYDGallCNRYa4DpavPnSILwhZuuf+4pk\nynM+/aPNBEJ8g4VBNv3V8M6rTLhlOelIqRl7IbRjv5sGac7YfD7PF6EPCCY4\n1uP9ia1mIPPeGYuq37hahcHBsU+ar5WotlA4LOYYghM9QPlVtGg2c+L7ZGDH\n13OGUDv71UH6suBddbP82dMN8QzDNore0iXkB73UIh4sNq0ZzR5ClkoUHVHv\nEZvlKY7M+X5OXktZMhDFPLZpLOhQwud2Ibb5mcZ3ehwEzoWbA1eq9U4wLX8Z\new+HSJmo29MGGC/2n+I2U1viAViI8fAf+8GU5R1m4YiFcFLIbqQDuL4n8Tdn\nc5AMyAIvpWudpN9NgLp4X7YCNO7tAgcJpxlumL5RXnUtkhgnisDw2gKeeDGT\ntnwpb+fFqfM88zT9SAUEbJd4WL53FodAkXcX5hmh6mTH019GPPFm/2mDWo7w\nJlGhFZCE6c3RqBfnjY1MMmQtX6J0X2upgXSVOdXXAyZEajQGuCOAHtPhE7DW\nSqp1254D9Fl0TLgXGnXJw/5zuBiP3B7Jdk1z/kmsCKvvh9ZN1V+JG2+gwxOD\nRPILJ9qT15sARrypVOkn940b/iHD67+a9s1587+nP+FHeDNLdwtIS01PNdQQ\nXixv\r\n=TFeo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-213eb91-1616220408100_1616220472987_0.2582505812544085","host":"s3://npm-registry-packages"}},"1.1.0-canary-9b02e0c-1616369055186":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9b02e0c-1616369055186","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9b02e0c-1616369055186","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7297543b1290f9a0f9f57540e1025166acbe22bc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9b02e0c-1616369055186.tgz","fileCount":7,"integrity":"sha512-gkWAXq99kB+joosRMBQLYajgXw1q/LOE0oa73hCX1ALx1AxeDjZj/6pyEwKY1pdYuvjFnwPh/KDW56q7WD3VCA==","signatures":[{"sig":"MEUCIQDUWM8bSAuHtVs/iHntUNLVJnyXrKyn0mHTd2La7JGadQIgF0n1HAekRSiep4SUOhyfUO7XqSBAz1rr/BTedQd9YiE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgV9XLCRA9TVsSAnZWagAAo+wP/1uBRs0skAbHufFM1vAf\nJzGFSa+m7i4Thupim8fLNmOVUAwPBC3WcZdyhUq6Swwv2S8721wnNQnLwIDP\neIBiNUZj/T4+8ew9f6ofmRc9Ow2fTIK2eM/es2ZsYtKqPqjjtSrVnavEd1sP\nKeg2BV3DBnS5EWaOv92bH4dm3yGaB4s/9b1wjaV0AKx0mAqND1lkzLuz6Ina\nR4KXRJcamibJKaWNSx5yyjHJqRSXmSrWp6RajGaABqfV2VqTJ5f0cqCm7fq8\nWZyNXvoitcSvjnM9GHyPzs0JmrfhJXuuAzZlnIRZyNCBhPMucRgS5a+gDyqZ\nGMcxQ1nqE59MP4hQszPvKzTy2fn61JnwoQMHcFDjAA7nmrOMS3dl00fsSmeC\n82uL8NeeUvpOdYEEOVi1i8TKF5KyPMiPe376bxhO+oeiBGwjT8fMuoeen/qG\np9aubS6Virjs8RLxech7oXhw+M+p2ZNdeB0wnDBIMTS9BgG99wGBdxbBzXja\nmjM64y0TSt8mGzn5/XrT0sMqX5B0B3ya8ggAp/Kg9ar8cwleezcsU7Lqc1+E\nKXMkRQJS69nNIvgvp0JDDw8YsUtbLP9nJhlKAtv9GsSTs8fQA54MOItMmqAo\nR7U2W6LXhIwEBDb9+1Yk5bsxYrNc7P3CIaO1eFnJpmzWY+b9vk6KBO6nddtb\nJDbZ\r\n=PgYe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9b02e0c-1616369055186_1616369098791_0.0556078366504944","host":"s3://npm-registry-packages"}},"1.1.0-canary-51c498a-1616376513816":{"name":"@iadvize-oss/store","version":"1.1.0-canary-51c498a-1616376513816","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-51c498a-1616376513816","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2533baac0069f815640517762a355de2dccf7842","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-51c498a-1616376513816.tgz","fileCount":7,"integrity":"sha512-BhHXL2LQzzScIHikGGWswfMfXHeUHt+31KnrRQ0+gih5h3fYHt0NvQ0pnNxXPgVPcIkKDEmyQdkQR7iQejhHyw==","signatures":[{"sig":"MEUCIQD8pgmowdlQ21JF/YydbzbDjA6AsicD/6u8U/91St4NGAIgQvzgO99w275fen4B324lUhSoTIKbZBmJibzelaY9eMY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgV/L6CRA9TVsSAnZWagAA88kP/1FTGwlCYPyukr0Vlek8\nbLCfJvlec3quSodV1KoEwFqpJviXli9LDg2D7rQRHgOb8ASavBUN5Ryomhjb\n2f9CeJf1wj/qyjDjQBxf3jZb1QxwXsiPr+YioMS2IbfOfmZwnlhxKU+kCJFB\nlnzs+XGScja5hjEAKHjr1OwCagn2FFHsyHCI1er4RZMZz44N6VPCjc3Lgfx6\n8NUqXKAC+Gg8d/cY0kxGcW1MW/r89aj2BNACJbVJ8ne02dCWpR2uvyzl+RgW\nhaHjAs/2TJjUWYxoc5wayRogAjUPanzoKEXUh1X4rkUFwyIvJRCq2G4ofsD1\nIhLJ0uxJy+yLo1J/u1gcJkr917XpV4Yyvt/7IHlr6jDaG0E+IIL243gWBRJM\nivyxF8u+N/diKqX99DT5U6VUBxrf5mnVb50MSoJRfT61U0EL2hfD/OshMplc\neNrQN7n96eaXOy5JoOm4LbOnh53FfEbmTLm/zbVn+sELywwt5LNILPeahm8n\nDS91Uezz2glvPGGDPUe7wpwOhIL1ppaFlVc7jP4055/3WmocBnDvH3KM6hMW\n9XNSRUF4D2UCpXBfBp1yFBuZDY/xLa0ZFw0vULpn8ZVokxPd44PUHtEEWX7T\neUbPUEksxauD9Oew8PlB+PIm8u915f+V3N3B7PR/HikjAy01FhxoCkw8/Q9J\nwg4G\r\n=tW0P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-51c498a-1616376513816_1616376570132_0.26660633361017605","host":"s3://npm-registry-packages"}},"1.1.0-canary-67107c8-1616393890006":{"name":"@iadvize-oss/store","version":"1.1.0-canary-67107c8-1616393890006","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-67107c8-1616393890006","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc248a2da6b14da09e8a76571b2bb2e7f7cac457","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-67107c8-1616393890006.tgz","fileCount":7,"integrity":"sha512-TcslTAZL+qz2JXDauKm5pbvo9dqOj2PcvcW6CwwPxZoLzaWL5Qn5o2wXfV1elkeTxvvoNXE5xKjiHlo7FJ7hFA==","signatures":[{"sig":"MEUCIAqsLTO8vqUXDd4fg+pYJEOw6+xt+yqU3dCIQWNuzfsNAiEA0eQA1ZNiL5fj5J0IxFsdBAVsuR4Sanb57Cs/SG6cn1Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWDbRCRA9TVsSAnZWagAAxkgP/2BzKsmIizkj9QFeh2hT\nfgPtwu49b8IOliyO544pIjnmly9CzJZy5yCw9q9wjHXBK4swb/1N3p2mowYA\ndqGVdT61SRicc0CJUrxmqzXnT6OqDrogvzqqfPO9TjmRWG6rESsk2HA4VqD/\nK3IlWGo3QXXLmfyvbR6htrKA1NDI/1QJgE5DXh75eENoNVDvAXR0rVyNbza4\nUq4PumbmuK51P1LHOGCmaBSa7P9VVtUW/sj2QHAEVAW/yaWtOhCv0t1Z9OMQ\n4wdFVxXCfcfiETuqzXPZ5+IgBotPeaHWcyxa5P651/1lLzhcfVEXEvtVM1tA\nUybPVy4nQT5Bh1ZKBHI/Aeq69/cXfRvPMhRJlCRohfC9OFlLCKBZ7AVUWj4t\nEqjv6j3qucvUtvpA19JpA60qh2XhZ/4CoHQOi7qTgxeo35jg/PQ/THasvm19\nJQeurGkcBalAV137SpZb1rQi7UQUz1ffiUEOm7Tuvp9jC3qlQa43hFYts5px\njFzWRHlaCGndgiTbEu8exMQjMcnT+KIx4OCUSIvlDcW1aX866OSDOpps/y6K\nk3/29Zix/4de2pUBBzCFujKtpYXidP6nLw2/ZxDvRhjJ3gC/HwcdIhnqRyFB\ne4KcI3o/zXPLjiOsLfoZv95iK4ltP+HlCkQ8i6729tL3k44hwcnBX5SL5Q67\nOoqa\r\n=+3+Z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.2","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-67107c8-1616393890006_1616393936566_0.7747462763675155","host":"s3://npm-registry-packages"}},"1.1.0-canary-025b1cc-1616404000766":{"name":"@iadvize-oss/store","version":"1.1.0-canary-025b1cc-1616404000766","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-025b1cc-1616404000766","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"45e62605fd8062131f1a704d7565574e00ccb6df","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-025b1cc-1616404000766.tgz","fileCount":7,"integrity":"sha512-zQ58Nyx+HfAuJlVTGM808KoamS+t/joGWwR4fZuJbMUPHTdhI97HHwKO+QGUn96d8YyCwpbcvupA4KeDsX+luA==","signatures":[{"sig":"MEQCIGm2TsDmSIUXUcuEv3HT401NbqRPANOv20uHFYM/YF76AiBEucaq9P99DR6OXcdoO7b8eR2E7aDUyidAHZRc1PanKQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWF5RCRA9TVsSAnZWagAAfjkP/Rx4hPvs281Rs/mBqJG5\nRqDzyAbRua37PeluvmPZzlr14ek96gNt5T3u6SF0Vo9Q2xlpGKjbzaZx8NK8\n0jaEKUkyFOwY5BFX3cailaCOJOaIsuRmBjmIWAMAzLRI9dgJWWwiVIcwY3h6\n0VWWRFMi3U8ag3dOdBNEkcOJgOYpWxOENLv/zANlReL+IQ3IMHigA5rpDZBy\nyVew9RZc/WeGiGmISKshKmYTFFb7/F3Gdf3CNfrCsXl0b+TXmcYZ+Z2ek8xt\nlw/Qpgiw7WSIGM7SRBPTCzyOr1qLA72i2XGn0axsWxcySHwrvknSQf+lvqyT\nPzM+xjvv7lgbGMrHJU7Cb/6Tul9FDvnOztLz1NmOUMJPlIMAvqsigYw+EbDB\nrDaPLzhsADnayJYswEmWR1U0GhLGWnFS/h9AZbNfhwlkUmIQm2heZ1qUF3wL\nnFNTAw3d4xtLlejcs+q8aCaWTa4HblhXzhoLgW7VT0SBZVvY45v59QzDWSTN\nqviJqX5Qvx4aKfcvp3hphFWrdG0/d0buDPYlXoRcQGQ7rnRMSO8tXDvIblKf\nvAA5wOlTwQzMa4yt6IL7ssRmLWkLC4vij32m+zzjSQN7MYAKGxwzQhSf1tbC\nzkldVSRmRUIcLUm+iQX8LWAKbGkU3EDAboRmY5871H/lHEnshzaOk5fq0qa3\n+Osi\r\n=H8SM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-025b1cc-1616404000766_1616404048920_0.4998407773957294","host":"s3://npm-registry-packages"}},"1.1.0-canary-1371bcd-1616404620931":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1371bcd-1616404620931","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1371bcd-1616404620931","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2f93c8280ed859a944c315e76a5327e67ccf3ab4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1371bcd-1616404620931.tgz","fileCount":7,"integrity":"sha512-AroStolr/vlShhjVY3+0bE77IO3G4TM2bXdEdHK3VGpL5bfxFv3aK+xKQu2EY3+YxF2jtMjbSPqU/WwA19PLPQ==","signatures":[{"sig":"MEQCIGeMEqgyGjI/VkBu/Q4lgu2t/8lSO/DL5MDd0bt8pYliAiBrSXK8/V0DKgkF4s4TcPDxzBL4qgWtthuhm+bqNJDuJw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWGC9CRA9TVsSAnZWagAAQOQP/is5AVKSJcd7FJOe9EfH\nzI+Sulspicb0srkU5JzDc2PsXiBSkr0DhWUvEsZcS5OxQIdaVW8CqIzdlDP+\nB48j0oUC6YM4YFqRORYKK70u+UcUe5wLBZ7ucFOFDvrEbVsIghMrpWlhCQn4\nPUA2crcEycnvtHOcVggcjm53dfM9icl1y4RYomDfnnnozNTjhLTzSPnrrvIv\n2tms9bPtZks8SyvzZfD1NoVMlhgMeSV/C9DAMQi8bRWhFflqToBusofa0Jzd\n0Ot140nMJqHjRVaxm/ftbRnbJEF+ieRDHMmUIbk/x3Bd7lR/4Djes5rOo7VA\n49rYcU0xUH3y5Fu+0oTtu88gloI3CXx/Fv/am7SkRnFCXLuPVkGRqnMU5Oqi\n3HOxFUCmt2hASnCd7hI2/4sqy82R7d1Loggwp30cbcu+6EkrMwSj+NWIAl/A\n1OmsDgSNn3TnNrsrJwYFVcvsLQDQs/Xd8QH6MT+xiggY3vY93FZVY9TNvqnt\n8gFimElEKSKejZvATFxRxl02LF2hvbS4nSnjFNQnS9dzC/1mJiCibcnsaNcH\nq0MGXSzRU/TVgbHSJzFAG/ifpaOgFx9siUp0JudV2bWkZWuW3xhpiEHHS4/a\nk6vS84gdHJeYSGLIUb2POGYPUtUZ33sTLCCadLhcbCB1wzTxkKlVDdk5i/AB\nQ+cR\r\n=UJE/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.2","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1371bcd-1616404620931_1616404668993_0.4140466973116761","host":"s3://npm-registry-packages"}},"1.1.0-canary-daba473-1616424952009":{"name":"@iadvize-oss/store","version":"1.1.0-canary-daba473-1616424952009","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-daba473-1616424952009","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6c473c6ce1a003c6fb7349a6ebb020887e25443a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-daba473-1616424952009.tgz","fileCount":7,"integrity":"sha512-DlQVBqVYC1EdFXi2Sl9Xz65oHgnwqSHtTaTuJITh/wp3RSo0qo3o1uTy34PiYLLQC4GQ32Y5hCIIxL9C6Vyf/g==","signatures":[{"sig":"MEUCIGrQbsjearaikUTmzlWmWT8nSuhp3UpLhUDxy22U1RPFAiEAliZkh2HAPM3fsYBQQa63Kym2IzeUorW5PYBilHphhO8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWLBHCRA9TVsSAnZWagAApAgP/21ZpwF6eGpRP4+fKMEF\ncN/2RDzBubcOmP64NbS2Cw13dXlYpoiRoLmYKQpC3q4DsAXyWj1m7okiTIH+\nrOaZRb2ggCnyLf/6pjAWFbiwMgLQelZaUZDr3tEHxurqQRbaUUTDwdTxS20o\nru4XCtqsyDUqHK/ze9B0Eln///12lqpMRHDfonpidPorX2xK4Of+uJrzHyUA\n6G7X8MGLebNRixniiRQpQKW3hGnJXcUqDxteyq6ZGnIUO/2d4fFe2aQLy+cY\nuu+Gqbqv7oGhcLWc8JG+DsJdCjwCKyAB9bCzhP/5hyV3Q03+zwIepCXbNfRr\nlMCIsMo85Zq9IDsAYGLMr3xzGRJhyLhJRK++u3r9cQgalHbAC7Rs2qUc9+hA\nsHjPbFiLVfc4s+wRVA6JhToxgrnEEKCuti8EVlfMtL6WET4jZYKEOWJW0Dnj\niprIOT8RMGr3Y8X7VBQVhktm+J7kT+FUFkD4PJhY8GY2RMvfWl2eqrAAdIwp\nETiCGFRlmhHZJ8NSw22kDtnLy/+KeQKSt9kEtSs92OnXqQCNO7kq5cuWkdUp\nMbP7Xh12MbwbdsdEamnwSca1dQHuC+EwHQCoPR2eSI4lunwZ0V4WQ5+X07tn\n3D85if0bH7z2Eafk4YRbrJsDCNHaoi/RK/c0GNhi6IG9qjO46iIj/4E56wOk\nKPYs\r\n=OpTe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-daba473-1616424952009_1616425030628_0.07964635389920693","host":"s3://npm-registry-packages"}},"1.1.0-canary-daba473-1616424965023":{"name":"@iadvize-oss/store","version":"1.1.0-canary-daba473-1616424965023","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-daba473-1616424965023","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b7f9dc049c91384a19bd9ed7ab0f7f3f4bdb9552","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-daba473-1616424965023.tgz","fileCount":7,"integrity":"sha512-vHtGmB48devy4QfYGgWBt/mpDmypRKzy4qtA0pg2LyGz99z/JAsRhyPhQNAEF7qrM6XWcCYQf2cR1OKsqbOIOQ==","signatures":[{"sig":"MEQCICnCcJ1yazcy99UkwGC26b3Q/dDuddvs2dGn4hWjzpBWAiAWsJRwEntIeofPoc0Ee4xxvGCNqmsnclm4Q8EKwGGw1w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWLBlCRA9TVsSAnZWagAAXi4P/iOuAuNbqKH2Be7CLx4z\nvQu+OTcZVgiXeRqN1vuP+4kvTtz6CCUQ4lH+hLIO7K5VJ7/x9Ie59RpVbS2y\nXWcpMJTZLlLhs6BiT9Oa6sUNa/+oPeDWKdPTkx8rS9nshsyl4DqRkTO+WyYa\nLgeajzHUblCIx5JE0g5AiChcKWfSyiE6qVhdVKA5AswuPfPNVCN/aKZr5K+5\nrphTOw+bQtfThc1oae4DrAmWQA/Yx73z9S3MwMrIhStH5F7lvLpzNDXsPXei\n0Utr+jMNfMag+KSLTsPuYWOeztDYzAxUOGQeIHBGt9BwKlvBIpT34+f9wwQe\n73DXmX7CzwcJmCHP9PgZkV3XA1Pjjp3G0F8SVzDlOaFJ+74D2Jg2IMN7NxpN\nLHLCOgWdEXzqb62H2w9QmzJDmMg3H0AhADCX2+Dm/zQRhQDVKuTH2BUxUier\nm1nCLV/lrgFtsBi9BYnAFr/bQWkTMnUFLIwNIMwkjtQfXrdrzagV8hqoz7hA\nvT3cmZjb4rtDsWE39Re7+WZ9kTbMVLxDQoFXBMAh/HD/JtzNvlXR2X74/VVS\nwn0vqcfU+qAQdIEov1QHzCjdlZ1pwSRQg1BkbmJc7khs/9YSTJvDgsFysLV9\nDbWA0M/rRi6jJ0bl02d4VfZh0fvhcHkMw13vfduab09hz1BW89fsxudtQwpw\n3Mdv\r\n=clxS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-daba473-1616424965023_1616425061433_0.7069844641919534","host":"s3://npm-registry-packages"}},"1.1.0-canary-f983f08-1616428389669":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f983f08-1616428389669","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f983f08-1616428389669","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2ef03db9bd30a2b286bf744dad1fd23457ef060f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f983f08-1616428389669.tgz","fileCount":7,"integrity":"sha512-+xrCUnCwb+gNGr68VZpsqEBYFIjEVVAj5U/PbzfqIuVabv8CbhKiri0xkhySbRnuZElZ8rRkqQq0ct362mRkJw==","signatures":[{"sig":"MEUCIQDMX0OuGUwtmyOFlZg/J2R5vCrqw+YBASgQGUd8UsJS3wIgI1ZvkprK00iF8vExJyzeFV7sven39BMuGIfyO3N4F/M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWL2bCRA9TVsSAnZWagAA+OEP/1dqysJTnVgzhIAZWn80\ntlFstGVWZaVwTDVcaGhlrqvVl+SoNmqtaepdQGMagfAj77CIbORJzeFl+PIo\nmsGuD9vvR1r37LVK0Dh+Hh5rOx0G2O/WQw3IldrhFQAMizt0ObGbTjI/SlqQ\n5Prwd1Lotrp3MMPuOcOmuXwgTfety/DxUjEoRJYMtYfk8V45gSMVWSV+8w/T\nF3k9OTU++y6iN/ddS5VWHPt5aBQAD18WJf5jRVs3PRosgPiQNilpA8YF7PUE\nGTK77lNX3gUXwfwYqtJHBOqXh08dG5o2u9fgK3nEn0MECbswzhpJHMZ5ygw0\neb2vFoUI3HJJDDsOrVVNYq7WShxNq/kN8ny5zsdQ0KzgoFYkdD9xjF1mWZmF\nvW4je7gLbAh8OgEsB6sm2ccShvTmzYHWN6xuAhXUbY16bWMxV61vfAROxuW5\nF9aCPAwQCZxDqkpd29iZUF/wMpcoH5JZ/tgXk5gju3xTRlRLmnEL1kwSBPq5\nNumhoYzITif4k1y9vGgaw9J02rH+HfYNK1m2WRu4fBOOnqpCFjmkXpvW/CoE\ncR4i5H9Z3H725n+OR+y4r+1dnAy9VVm2yVerReIg+GzNepRbphDGOhl3NjsA\nJmE97jmZp91x0m5AVxxtuzv/iKE9t/WaarO/pmAlmxgHp0rUDV7alK4t0/3l\nnpWS\r\n=Nl3b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f983f08-1616428389669_1616428443205_0.2651143971070089","host":"s3://npm-registry-packages"}},"1.1.0-canary-c396e0f-1616596807997":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c396e0f-1616596807997","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c396e0f-1616596807997","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"92fad93572388eaeb9b118da363edd6479ebb4db","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c396e0f-1616596807997.tgz","fileCount":7,"integrity":"sha512-O0jHwTYwaZ/vizOYQM6Zt6mH/FaGH5dSx5j2dBnijQAC5bGPrYvRiSNLcQh2Pj4W284H0VKK9fUD8bIqlucPpA==","signatures":[{"sig":"MEYCIQCK7C4Sayiem14VlH3ofia1vEZhsPtgH2WLKf2Ii28sBAIhAI1krVPkd9SzBEO1kM3fI+0nF2yJ+hGz+H6f6vnYlcCr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgW0+CCRA9TVsSAnZWagAALnMP/ign+JABpI0liKDynnrB\n7jjptrEaQE60iI94nYzrBL5LKv9q9HD6y+NSAzOYh6sWIKSJUz8472F0ZTyV\nB/65quZlTntCXgiWe5NR4rlh0gs3mOQvRyIOR0zo9j50xmC034mRV7YIQ+bt\npHmLKbOnFwEmPQgQzMeixAgz30QM1zUaDKCRHGsLpvci/DF+47FfryrMiZYr\n+2ucNa73xyRpYpt+z0Nrn2zLNhK0lJTh/5gQod5A1e//ODRE9tFyr23yxzAM\ncO0r6YPq3z1m5x6l/7HJi/6Eb30MsXNamVIpLqGjxnS1SzlF7x+VfIqEFsGr\nwvtAmE1kBzvS5PxZI+2Mflsviax7Q9Hw1r4//asiKzf1WzeapQ3EBbb76f8a\nupF1itRLr72qP6KvgkBzW4nvkpUOTnupTWx7fQ/YlEQVslGYeBL7LC7BYlb+\ngW+W2LZH2Xe0q/AHu6lXJ0FAzHlPVzABUFbuusUxES8aWbOey9KJ30VTf20u\nuE6aKAg7FqntDeUGiqsVqjBPzVd+QrVdLS81z4PAEz6ITTR8jwKS0Ox5e0tg\nlmJUEU7fAGxiZBmEnvtiiERcuQsH3EpQDdLLw+FdyDvv5oP5Wi+ly5Zc359X\nkhCiZQOCrPeempM17HJ5z1aEkbt815lAYM2FeUVWtKeavLe5c+BfM+CdStgT\nq4Ns\r\n=O/K1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c396e0f-1616596807997_1616596866279_0.2485536898054015","host":"s3://npm-registry-packages"}},"1.1.0-canary-c396e0f-1616596808736":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c396e0f-1616596808736","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c396e0f-1616596808736","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"de7485f644f4decf08a7704683909d7b7ba01bfe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c396e0f-1616596808736.tgz","fileCount":7,"integrity":"sha512-HFJaGPSL4Vm04RzY36WlKIFYMgrsvAjFnO4pyx9VawdqS8FO75+NpBa9S2D1UGZv7nNfjaZ3mrM/s5YpgH8UDA==","signatures":[{"sig":"MEUCID/oMYNuVHKlO9GcGVKgIrHHWQQRsgc52TNFv5qHe+iHAiEA4zVdxEnPL+pScS/pMIN7wicgaoT4O+P/PSL/mCTrA9A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgW0+4CRA9TVsSAnZWagAAIVQQAIVBK5WnluA++R2mA9Q6\nh+8oD+EvFGb8kZCULClHvrk0zYYStTVVRzi5ArXEUQXzT9mUyR0i1pNQqdi+\ngehNAd2Ygow13Uir0SoHYjVpKLzHzuCixvkKAnVQKqRLt7jcdY6lYXaCj7Jg\nxMKfhZozBQRpo9XcU3CN6IR+uENRS30ltNAaYNUdXzMuQUHqkFKDb16ue8ef\nXeCLb6dwd2QriFhos8HhiQvenPBt7+aTh+1hM0xG+gXziG6DkUFlxnCPTamU\nIYgOU8citCyYLNY9kSnwERUmHbVi3s4L4EkOrMN6Ggqkvbhca58gwHTlWycV\nzk+HZgt7A7toy0OsQLvlnFhUzn0APOv2CDzVYn3nmQkGAI4rBew0glpl8xh1\n6DTIAX3IWGjwoe350FwPIR0YPzz7+krVw//GlTQfWD6H5hmSXsVs921W9JVi\nw8lC3IckaGXmlq3YF5i4GGt+LOu5XPA9IpuHWFvZ4h7gqqUxQQnkE6OSWan+\nV3d9FwdnT4N9+n6Tca4oXvlyRW8Ag2DMuZTkaPVnXTkbN6lxL1PAnLOeSAlT\n7fZClRKlYj1u63Pmh5udZwgHiGXP0stKnhd+o68Q5rvPAuut+3MsWJCmvJXq\ncrDKNm8azkw7BQsBVH9bl7QEdC0kOwt8S/PUxNkcLGmmoVmt4cMinfCj4+pf\nI9xk\r\n=WcSm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c396e0f-1616596808736_1616596920131_0.8543244371410728","host":"s3://npm-registry-packages"}},"1.1.0-canary-8886b91-1616627765270":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8886b91-1616627765270","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8886b91-1616627765270","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b555bd032ea187cfb7e0c9d69aabbde90c0a7e75","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8886b91-1616627765270.tgz","fileCount":7,"integrity":"sha512-FGT+wuNZ38xG4e02qUmN64BzBWgdzGizJkzzqt85PduX/qSfmKvCwLmBUl1YEa7XVylagiW8cEMZnVxakIC2tA==","signatures":[{"sig":"MEQCIH1Qu9rFpvAVnXX2PkAghaSrh96/C3VhUWPGTnX2vmxMAiB0g+VwVU36zziheRv6gxoo8JZ7R6vhjiiVtGxRYgUpmQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgW8hlCRA9TVsSAnZWagAA1IkP/inKVPCAjJkIOi4F1EeA\njXHV/ZtQ/l/zvhWk5msHXgoKWRNwfZJxUp/IYnmlcgah367DNJytvx1z0b12\ndYqFoydPd7PjH2yek/9j/R9vHUSHMTGdeOfp/D8H70A4qkk0mUZbl3D2XO7h\nA0Rza1YIwiCDasUXB50HXrnwJcfbFyQuErHTq2TI8muzSDn1D1dFKZvorYn5\n0sQ45+0sLNU47/Uo21ThiUd0qk5aDo7NcWjzcy5vbEuJtxoAeqThCpjdHGb9\ne2MXuLfkyq/3wmTvkLOWhtQOaBrA48FbeWHxuXuASmh0oDndZ6OMYZjIDWQ8\nZMNkqYOICt/jeq91RJZbnqlctzL+JwEAobxJBueKuyHHKo8IF499fi+MPjJ6\nOaNLhuJyBs0Jypdhwfv8df6oCxRNOvYFRKyl/FdhMysW5mRhKHM1IwRTbz4b\nVr1wGP00Pt5b7F8DOPpOEdnHYrvznxPQpND2KomPXNVPApzjfpfupbxYIm2p\nrA+RfKJqBiiPrrCG+ppetzrAd6LaCHuhze7LxffvJ0CT5y2Vx3lfbfLXLRWo\nm3xoKVVxcbfwXU7kJ9cIgtXKSC7pxWk4GaSJ1t+sD7+GSbAvmrM862nJRGnG\n8zcWE2mMDh1t3awU4c3E+PDOV/alVagAP2FzeSkPRj7YXy/Cj+T7gnNda+NJ\nLSqz\r\n=dn4t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8886b91-1616627765270_1616627812301_0.12690001619315283","host":"s3://npm-registry-packages"}},"1.1.0-canary-105d16f-1616643397076":{"name":"@iadvize-oss/store","version":"1.1.0-canary-105d16f-1616643397076","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-105d16f-1616643397076","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a5509b348d0a20e1fc1a4f181b3ec5ae3343f528","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-105d16f-1616643397076.tgz","fileCount":7,"integrity":"sha512-7i+BtZMWM19x5br2xZV3eQROvduEU3/NSzaGH4KvbHFfpsXt4F+xzdMktQH6ifl7l173Wof7cbRbQgMJMp7d4Q==","signatures":[{"sig":"MEYCIQCb0oEP0KL5HatfvAjDAZpNuCis1rC1baRyC7FNsaKyqQIhAOs5REgr1vsm3L+VH6xea0sH/EdeRAA1QzD0L+9KM3sH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXAWJCRA9TVsSAnZWagAA6aEP/0quxateclA93XWmupum\nXYKj8lUROfybDBm7YQ9Y2pxWM+U3cJkAQMPWT6hSUcU2i9/VdGBuEQdphjBu\nD4pyAjW8mHtrcf6JHSik3qwp48Zhf4UGqJDHRMnXSuIrm1CsJSaUEc+OSQgH\nMpPufxBBiWYj4ntnAcrkHOixvdCv0+ArRClfilVIJ8ZAZdp2+SJd9/JzGLql\nKI8HBr74twG1+rzlOyuWV0iipUm1t/2tmAb5n/QTNejmkFOud3OFoVxb01Km\nCUEZwIi+8kXQZjnf/x2kS2LMNkVgf174j0o7qz2VzOTbVIRTyqMUSs+lEivk\nV3Vf2ZiwjWxrRsTcnL6PNR3lMxpvfmZ4jwiGOHnJlhqvBgGthwMFKTYTcbLI\n4otdO0tNwQJLaRPYM7SK2gMDQbyuI40eJMrJWvU3Pmcy775Gk1raMWOVzLpM\n20r0v8dIFl0Nm2GS7zMc9UCdWhC+/yHRH5eSXr1/eKQTwX2hU5xUGb9v5Dr/\nWrmEmI7YK4dPsgsYU38Ycj2i2GOXrux8GYK6E97WXLXSopEeBvRcqQTiUtEG\nzKU96nR7foAOapohyNZeWezbKrDR9TzWA6IHGjpzkme+8Pn14XKGP7hdde9c\nzl6gI54ba4wEKjlgQKSqOl6e0WINcGG4hERxWZTItzE/92ap+PYwE7sll3w6\nuyqf\r\n=7Tov\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-105d16f-1616643397076_1616643464577_0.9116500894964319","host":"s3://npm-registry-packages"}},"1.1.0-canary-751c1a4-1616663077877":{"name":"@iadvize-oss/store","version":"1.1.0-canary-751c1a4-1616663077877","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-751c1a4-1616663077877","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d035174526e99e4301e46f63623383128e12e84a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-751c1a4-1616663077877.tgz","fileCount":7,"integrity":"sha512-umduH7yDBp6vMAYU3U3EPkqPYFdNoc9z4Ca4ECeH7Ov4fhg3MuBfDqNt7XHqUrZnlzvhXmSlhZ3TcWH00MtMFA==","signatures":[{"sig":"MEYCIQD2/8yXtGVa6oDnIaBvqxX8yhm04GZKCxEUqRjY1eXjKwIhAOkdsvnco6v/5cWKdv7UrBbnNP4CQf5poM8SXDY6VV1I","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXFJXCRA9TVsSAnZWagAAyXsP/R3Z28GZG1PFMXGlZOWy\nG7+/Tq8c3V5JaV+Dje8sahddSTjaIweFvMs6bo8x0CogO4doPa/mkqLzL+FP\nxXXE2Mfr9x2D48904zgXbzjgYCpAY0Cy6klin+YAEuGltP7T0kDdzXfQpTU6\nyKg+4Oce6HIXuq/RMRAfOCVbT4jmkAjAlefFja71AMmGa09l9bGCsHcuSgTL\nJadgwZ82I0qjDj0x/Hd74og0X66vkDbk/ZTvzE1bm1dB/UTk0FCrWvOULkLJ\nS21e1XrdBhoEEKlwbGxddsX3ZBYeREAypeWktLcT+/J6C5/FxlB54pmFHUEq\nzRDk7qWnqO0EUFdl8ZWSHIId2nhXZLZBlVFR+NZ7JMAYKrgv1rlvxkdCPRyp\nIus2b5Y5s0h1GJT9CFqsTN0AYHcInsA8k7PX5gQJUsUfcMcPv97KrqfkETcG\n0tHSufIhEP7bEa58GBTfgUSM91p1jLqpHwNN4ujkUdGu0MuUn7F5g6/mpEkY\nC/0r3AnxWGDpMRAspLlOP/V15tYNXwQ4GN/a4JUp0rTMEXsHd44nYhwdQ/pc\n86snZCpWF8xETAgGmjHtoSocNq9iL6X13HgqYDMhFkmaUzw1GewZ5lp+uod6\nS+Yf8n8MvWY0LcLdPR+E6ENC/aNbEdZhDfJCz+QWwE0iVFtSQclsKakkw0lh\nfqxV\r\n=C9HN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-751c1a4-1616663077877_1616663126933_0.9853358971546236","host":"s3://npm-registry-packages"}},"1.1.0-canary-53d6f16-1616663267891":{"name":"@iadvize-oss/store","version":"1.1.0-canary-53d6f16-1616663267891","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-53d6f16-1616663267891","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f9d93d3cedd2e892c1225b0127e85c6d6670fea9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-53d6f16-1616663267891.tgz","fileCount":7,"integrity":"sha512-dQEJa+nW7jqq0zSI3uOvwSUPk/tDDy0jXqH4y7eDuqLKnCcFgsCv3hUQ8mmGJRF/PO2H+fNy9U0jN5rMCaCvqg==","signatures":[{"sig":"MEUCIADHtRur/RJl1IoJep8Q45OCXnv0WjtqVVbxkMvjGRapAiEAqd5EYvTyLtLvdZgJyH4DzPk49xS7GwjPlmujLy6SQNA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXFMfCRA9TVsSAnZWagAAoRQP/2EGBNpt8roPZ4bpM5QF\niGVhpmOyEoCo607SZW1T2ABOZFoaCz9s0RwswS/w3HZv0d5HcYsu6eHiWb3t\n8R7zTNBCeyYgCEmsr/EO247j95j47clT5nIoEY5O4eCN402YKpHUq3arlwyL\nJy/xCQlSq5koG6iGN1/7AbrLa+GMAgtCjrURc62X372K1mGZPjzjbtQI+blF\nk0hzIRIxLnnhfCwN4sipqul5PVXGqwoPVAQbFB6lYh/jwURv8mRCnINeAyxi\nua3uFJ0+zMGsRVS4pclxmxrKu7kT52nwDGC2GyP+KhCeHERiedf9g5cbNb1n\nAHhPSOx3zyfdTgTdhP6E8V5H3owJNjZ/zBFxiFyTuj4i6WQF0KNmPFsjPu7H\n0o+9pWzCJY8FuLtjs7DivZIVyylDXWnv6OEDvMXf2Fp/jiMQZ2oWj6WItj+p\nlhW/fa4OuiruoTXBFvbDfk09DbUc6D7KtJjYL3MYgg6mZWxyualM57uiuOm9\nBw1Yyg/F0Xi5E64vU3iOBzK6thQjLINcaptuvIFyE9ME16BdEt0sm0OUKO00\n60E0HDAbC8B2ZsMDlwFhcMVBJoSZzmHBLcVAJDgFq2jxW4NTzFAagYrQelX3\nTrOAMURVnDpyLTLJBFID3YcXLkIEmuBPb+UG7iKHD9mxFF9utqU0kHtO2ha/\nIkYn\r\n=Y2+S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-53d6f16-1616663267891_1616663326779_0.43585254852810484","host":"s3://npm-registry-packages"}},"1.1.0-canary-ee2093c-1616695686050":{"name":"@iadvize-oss/store","version":"1.1.0-canary-ee2093c-1616695686050","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-ee2093c-1616695686050","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"456f4a4a013e6aee6977957aeb4c6a9ad8bd2999","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-ee2093c-1616695686050.tgz","fileCount":7,"integrity":"sha512-xi5S3E2CSiDI8JBpbuer7YHUeKC3VdAGMRnXcFPPCgtAb9EG0XGWkgGFM6zOHZTrP/hRSWPDLNbPouD9tlVH5Q==","signatures":[{"sig":"MEUCIGjyhvAqe/8k+7UYXWSRgCn3U9xzpdJeXzSEaQ65fh7cAiEAp00Ay4HNcRw+or4gmVmXQc4d17z6sC53NFlcAqC/Vr0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXNG3CRA9TVsSAnZWagAApT8P/3JwUKYbt09aoueIRcYg\nZCh2+V391YiACsewZy0gLPzyW2g/vbFnKQ5i1JcCK5Qozg5Lw+/x/wOdD1tv\n6FcqJxOCUndSeMcKtHJ8aK3hqGn+2PNS41i5ePRoyy30LTmg7WXN5AGbQy0j\n3rruMlYiJs5GSbBdkPH07dIa3dJCtDAa85mriuHnGWktzYfSQ/MjrRcPizYM\niNPoeLgJ8a23u4ix0BV98mWQ9oSw/MAlJ6I5xUznO1Yc1wnvTiN29sCtX9T0\nhEtIRbLaqY/4haWxB6EKqWQBjh64rlJ8tn2JnSriL18wiiuCjtYrfOdQHITe\nhHmtsj1s87zDua6Pu3Qc1ZRChton+QXCMyXF3ksts0rxFR75kAWr7aZcU8rj\n22g+4CQlAd0wWUgY4M4aNaS4jBG4mi1q7ZiJ1rc5Rjenob/SVPG0iY7EO7dI\ntj6ctnImOyN8sU3ffQs0QfQaUh8RDVT1gLeY49blHxTtlfZVz/8wNGNxxF4W\ni38ossSDirtl88qyWjiHcEVIvdofmD0pFVobfiBp1iFL6xyy0ybUxcR7Yp/c\nRYye/r8QH6L/eflaAfr2JIlspTS4FCWjWFzRN8fOBBAKk786p3y3lCxwOYHa\ninw45BAVwcQGiYewLYYCddnj1sYMPNhEQR5wGtrmEBpUFwUP9QGJmcQ88Ee/\navuc\r\n=Dy6t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-ee2093c-1616695686050_1616695734681_0.44335315758745053","host":"s3://npm-registry-packages"}},"1.1.0-canary-ee2093c-1616695687737":{"name":"@iadvize-oss/store","version":"1.1.0-canary-ee2093c-1616695687737","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-ee2093c-1616695687737","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"37ff6f1fe93abfff2225c8886e2c695ec3771bbe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-ee2093c-1616695687737.tgz","fileCount":7,"integrity":"sha512-SJm2xR+epZEhEwfvgyxOMQLC8OZDLG52lJbRmclsKokhYOIUhkpuX5fn1Cr9MRrGDmb1n8iC5Viaj2TD23IXcQ==","signatures":[{"sig":"MEYCIQDP0BLOyKqMS6TgElhzaCK0XwRbEMoIYDUt31/wZzx04AIhAIgip5UJMGMnowbOQkmT+OhAQdcHCmsJP8cv+MzfygyP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXNG+CRA9TVsSAnZWagAA00MP/iyqJQgHlYco/GiuAnN7\n+lSf2LzWYtl9Lb7927xKDLf1A68E+h/mOBMB7CN5KiS1+HR1PIhXkgPWIG9P\noXYph/g7GqBSq2c1PDROTdB8Saer7gUvQeoqcYWIz8jYIt9GqvSQF+XrZ65H\nMSPpOxckJCjEMbAsajIjnkRFwMq/2XqBMC+SqpuMkQPIlznO/zo5V+34y2SR\nJSRxYU2svatGx9+Cpmaz+IFrtzfMv2JLTQFox7I07EA3IJkrpNDyzXvMfxCM\nYuaIEhH1uOBG6AS/8C0zIYwFThBYWdVp4I+id5NOyqC7CzhzKJr9jqAFL2Ft\nZm6Azq/xvvytrkef8WzyHBJzDyfQ8ZvU7mvr27RsOHUQlsnG35XcaU85E2BL\nlkC/W5V912w8y4ovk6vcWEzJXD1AK5cpeLLMGDZv9ZwvK9l/MAQPso282mec\nEhk2tnjkZ0nM3C8UnjYmylNcITJ9qvPnci08/UbmL0uiwUgf0w03gq87hVIX\nXhzkuBQ1hs10ftZskSioHy8woZ/059bB8wSYztCN3csiI4My2nMk+Lh+ndMJ\n0pLMVK63/gFf+eb8hwR0Y+R12i5iTZ4w3FIsKR0STUrsPKOk8r+OkTMRGiA9\n5Ec4FOCiAFmIG1kvQrFvLe9mRZy/+JJSTkB3Tne9V9LGSy41u5+WA6WrdDGX\nPnF2\r\n=RWlG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-ee2093c-1616695687737_1616695742355_0.005101192992848391","host":"s3://npm-registry-packages"}},"1.1.0-canary-73eb2f3-1616784610082":{"name":"@iadvize-oss/store","version":"1.1.0-canary-73eb2f3-1616784610082","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-73eb2f3-1616784610082","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e5f0cc09427f3a659d8c5dc787ede864f4a6b9ea","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-73eb2f3-1616784610082.tgz","fileCount":7,"integrity":"sha512-PgW5l2K8luFGvNWrwzmtwDtowAkMnZ2gxxubS7cfuOfjpmprBXcGkyLqCqScI74clVgz+3nF8c/eaOx1YHKLJg==","signatures":[{"sig":"MEQCIBiUBejfcvgngtWu0QrZtkm2MVEo13mM6oQ2c0luFGoxAiA5fTSDrgqRFcNcdrAleJ+ASa/vfGxqIJM2up0hULnQgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXi0dCRA9TVsSAnZWagAA9SgP/RIEphlM2qFSK9h+i+d3\nN0IxoLezRlhSzZyoCWF58OIrp7WwUqmsAv83OclkOeSuIFO8rUP1w9dpCQyn\nrU6ok0WBSRm0h14xc7cxyU5uxWWLKpy1DNeY+ZHEwLa9+3rcwb8UK7ekk0HU\nDtM5fIsojtDgPIBA26ooUWoSqFODkr912vB66WY1gjSKgDAXtPlndqrzOniX\nr+WXfy68E5x91mmVOWgicsMkEOmq9F0gwu2cb48/nLuQdeiem5NRnmx15ehq\nZx7QccbZpvjVdYHQ42OumOkt1+MgUBBtj5Eq/1NHLZt2bdkUjKyJPK5niqzq\nFoTdDlb8+imZ/XI7km7+8JpflI+MoKVLqxYOO3plPZFYFdls+t6C14QFeW5v\nxgL4HirqUirkKOXEAghZYgBtAGPF7Io9rMha+f6ViTWxlsMSMkhnn5Syl70w\nw60VpP2D6cGLcKPaYlUBdw3X1sILzWwxx+xzEufnG2QoPsA89xmEoxTkXOOL\nIWkTYR25cvjPj/b1YryPQHBmP5i7dQ9jXvyl/ZWSlgaqYZnltQq3Fzyxxra2\nif3DQqYDo7QZbbCZmAAwJwuicUS75oMtBl6JoPAJiww+WhX5rKGe4o7TYL/2\nf2gb/bPUgdzXrVpR7iZ3NwpuilC6hFmKx7OQQ3twKwr2dGnPoBzNt9YK3Ziq\nt3Kn\r\n=zsJU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-73eb2f3-1616784610082_1616784668880_0.6018147004420928","host":"s3://npm-registry-packages"}},"1.1.0-canary-73eb2f3-1616784608414":{"name":"@iadvize-oss/store","version":"1.1.0-canary-73eb2f3-1616784608414","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-73eb2f3-1616784608414","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"71b45439cd36a599ec7305c4d12dc94a0ab120fd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-73eb2f3-1616784608414.tgz","fileCount":7,"integrity":"sha512-Gvc3HCiip/cm2SDBKlIbhj2S0BbKGIMSbUZb2xx2SmQefC55taa0d6xPSgFRZjxFQVt+ZKQDQV0kP167W/8pBw==","signatures":[{"sig":"MEQCIDXtUHg06JvZDeEUk0PviAb7c/0dhJ61J7TZbsw8M9WOAiBkZA9BaNW8NEMjslNlID9imWWEIg2SjWXHYzXVhaidtA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXi0nCRA9TVsSAnZWagAAYBUQAIXj2e53JBYyeKp0rswG\nbWbJjhUHfLKouSRp4AtgYpzQ1JZqvT4p9L1zAMmMf3ECrctJ0xmkAElj9kns\nOtm3bwnAcHfzEnFZVkyx67jIkX4Odm/MoXmPjPJ9Jeo9SY+JZlY8Q2/3wcJz\nJRVlUKV5JHJe2nt/iRJIyoUoLWMeSSOrMp6n1KhHLmpnnBqLAKXee30TRv53\nPB8aPlQTO5EfQnmsAgjD3TMIypnlVoI0/o3oCp5y7/nCSh6ag8dlG6g8cdER\nu1pCstohoGUWN48Zqtf458Jq5HZcLmnDSpuYm+E2FSjJi/USkm1Sq0pSQ2bE\nOyv2V6tfsTocgV9JsagqbBFEKeyreq1KV/fSiJczmEx06CplHHDNcFMVCJPX\nlMz3Fy6hUQjbiN4OafzTB22FG6OM7/naE3llibobvSDRuRF3RHFRgz4LwgyR\n3PWUoBF8oENGe8Nxdyt5hDKbWcEhBHbnvBWjuoyLQsAKJCVrUHJrIHB7onTb\nd6EVXMDRw814SXlSGwQwhkzNi0ux4g1m3GXJyRgn7q+PdS8zvimdxNAeWV9d\nd64mYfGodKA9pz6p3ZTqGKrW+JY81Vkcta9tL4uBKRSlzYSHbRSvHbZVqWyz\n2hR7t2y5QfQj/CWWEGgORCv7UQE+AdEZ8N/u+R5l6E1d2WEE8BAx5+Rgnscd\n8Msk\r\n=kZjZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-73eb2f3-1616784608414_1616784678792_0.5523341435248625","host":"s3://npm-registry-packages"}},"1.1.0-canary-9be62ac-1616793443691":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9be62ac-1616793443691","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9be62ac-1616793443691","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a42787eb5de4c7169abeb77c7a3b76ddc26aa809","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9be62ac-1616793443691.tgz","fileCount":7,"integrity":"sha512-Rfh7zg2tBMh+WgIy1TFDerCfhhuWMcxlDFzevHE+VdvdBL9FSIOJl+g+qKCimjBi5n+GDbM4iurBuwfrxVt74w==","signatures":[{"sig":"MEQCIH8DDbZ/0xyJg4YB0gDRMb5qIUqWzHFsovA5bTNlQviqAiA4cSXXQUZUiDDKOe9jBL/I6duuIIuxllHkkorg5O1zOw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXk+cCRA9TVsSAnZWagAAtI4P/Ao0J6PZnxhUtVR2bDvT\nsbfxqOdfa2bALOs5slphCmjoPc979Dsg+/m/TJYyog3WrOmYMXynO9GabU1B\n7gCazbekjBWgvoQOWGyXP88XNTW1VGFpjKSQKqSdy/CqQ/lYrUSVb9PXyZUR\nY20TKrdz93xECc6E4H17kK1Ci/IR0f4NKCjajvNNcV9MBnY5YfydiYeaP7wN\nd4p0Ffo/RhUqlKxpxOsfFrhWLSA0ZSBYsxiQg52Sz/Jpcv9MgozA9D8UaLtY\nzDD+UVXpdvx8wlKkKX242exEhVesDK5FYebocBS2x07dayhcrKgX4OYUGqbX\nIOyVoUXmh6r2AtivKEALnP708x/kkljdsHxPlLcaS7leDrbjykj36MVAHkvl\nhvVsg1HRz18Wd2k0GZcaTAMcQIpMKmjfkHu+0cIn3KaGJ4fZF8KeVTexm4Zl\nTltdmUTm6lKnEV8aSu50+/8rbCMefUsBzUo9nk4DgBZ/iLpJJwpdWfR1awa+\nxsjgW/UPBLB3GtFDLGlyvpNkrvcD+6yxi83J0m6BMByQ2pSiOI7Icvcs9Dda\nUDyC5MrsWQQ4e3lCgZq5PiJ7Nn6QmD2zxwpTpz5XDFFgX5LXXomN+cp4tBfE\nL1LQIm5YeZq2o33e9ZonffrZFTqydAXnrZnyGbM3dcPcEf2vS7YPjPwBN9h1\nJVQ0\r\n=R0V4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9be62ac-1616793443691_1616793500264_0.5633181693861262","host":"s3://npm-registry-packages"}},"1.1.0-canary-9be62ac-1616793453518":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9be62ac-1616793453518","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9be62ac-1616793453518","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"48f4b069e5b91f0f2ac99ea6a381de0d85619bad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9be62ac-1616793453518.tgz","fileCount":7,"integrity":"sha512-k3lnG+BhNTODTjY+nF+33KYNNeV0w0EznEM2GB39532ENGa4Yvk4AomNRoNiNn6x+K1q34aQr8XcNbPCBxA1fQ==","signatures":[{"sig":"MEUCIHznMemGi7BOPNznUARFqu1sLI4xt1A/e2FNx0Gazts9AiEA3LAV9tPeKtHN5fbIb3corpeW9aF+TeHKa9UlyGUyiMA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXk+mCRA9TVsSAnZWagAAHa0QAJbNb/3QW5egbDT8Tboe\nhp44n+cxej6dUw6Mm3lLXXeBro7bhEMnaPBGQm+5rU966ZC4k30e4hrlr4Ww\nqK3pTzdCX9K65/Zfktms2XAdHX/5QPSSLDtNWdPEs/jeBbTBrcKmGihHAYuV\nqt2onwcnfZnzkpF9Tlm5yXtZbVqtdQXxw24+XfImH5HOJoMwT/2GHxL2ZJ06\nQO/6yRSOfJ0W/NQG24tpP6gF/y/uHGdghUEjQpc+LIDC0dEsTfktuL4LQlqY\nvzUJYxVW5qFCebAj4d9YK+v7+G3bQbr/OzUIosZvwnZvp4QMz8gBKuyB3Pa1\ncHdHHXZiwHwIDI2S4IdsUx6N/fLBS40NtEdYek0Uit2aqHr9uwq0anG8i7mg\nOVZUiyxkhvMOwG56SJO1nQ7/mNXNSLYIBWtt8f6+ivX0UAVr9KAp5aPdFCFD\ngowMYB4G2SsJCnEZP8nEth5aL2eB+JeQxbT99FUiZll8MAU7jJy0jqdNrqzr\n/tR40CPoFna7kz66ZmO5w5qhEs0P96uCn/4Da5nPe2ChDnSckl4flwlWXCVg\nZ9LLwdgVXeY5IlH1bQbIYl3j//HV0ETNdjLigqaI6xwfr/7LGe73+2oI0dnv\nM2q4d2bpJdAdLcs/fQDJqbYgcH7rSSFb7aiXCuvs4cru3dG1L5jkJOX44BMB\n4T+P\r\n=Ipbo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9be62ac-1616793453518_1616793509595_0.2608503876674022","host":"s3://npm-registry-packages"}},"1.1.0-canary-d1938e2-1616823812069":{"name":"@iadvize-oss/store","version":"1.1.0-canary-d1938e2-1616823812069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-d1938e2-1616823812069","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5ef298582aab1343b9a01ec6006ab44ce291db7c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-d1938e2-1616823812069.tgz","fileCount":7,"integrity":"sha512-muN3IV6aXabDpnWVn0/+IW7wKkYxgHyJ2uow790I1HC1yq8pRnqNnjIKXhtQ7E2YURjNLn/vPMU3B5wApB2oyg==","signatures":[{"sig":"MEUCIGfRpc0QAoqbB4kW+B5dDu0j7ERbbfW3Zmt2JXPUGYR/AiEAiQBk8sxZpgC5fyUqEHIVhXBx+4KRTQx9ZxG+Y0DYVlg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXsY7CRA9TVsSAnZWagAAj2AP/ilYRCfR5yyQ8Ojg+qHU\nWBO8DpkbIEG4oUvb6yPt/B1wdLVXxU/ax5tZRDGYOzySNa0pACe+t2geDkoZ\nEdWvoEOQSBqaVAk8dudYU8Br+n72WMHZSHxVJg0OpGcCeXFnNE+lOoaOptbG\nyqpAr+1cdarKwBvGPOm4zsPHzJC12ZjBX1AyBpdZmBYW8r8wB9rRzQEAVquG\nou+gzXsF/MrnKalfGQAWrO2O5cmyc2+cZq/JPRSRMrdKoa4Ueg3a7b6HC9Mi\nza+0S/Ffj6DH1BE6F0ed/f9kqunS2Wsg0CXfH45I0RJW/MJJNbAYwv/ebxpV\nsnGMpjuA4+MZfEtttV621RTPq5KhcxL1FHIr7ebTUEGC3h2n8xPBExGCFR07\nItOFvoNpv8rT9fKlQ1EMbB8an5Ba7A0+oOWRHHP/oEtx8ohmk1GrCQZwYoc2\nwhnkUwFLRu910JwXA1BAoHt94b1ozj+6UKYAXWWrE+CAIYewtksewnDKPWoH\n2ZIcn4jOUubxmWg/G1mPsfdmzOGzK61pojTHtFbe8KZec7z2Q131AjbLR4tN\nk4YwN1G4SXalFxzT1rHt3eTQdxUvPkYYq6rc/iXxr0vX6gegZLDYOSbel6j6\nsj2PE8Hk4585Koe4ScmpPlbAioX1FIpomjwHXSYygPvRG7B6PY0VTkww0GwI\neZDW\r\n=z8d1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.0","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-d1938e2-1616823812069_1616823866907_0.12078071010533309","host":"s3://npm-registry-packages"}},"1.1.0-canary-269053b-1616912548399":{"name":"@iadvize-oss/store","version":"1.1.0-canary-269053b-1616912548399","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-269053b-1616912548399","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3dc4c5524d1f7635fd0241e53147717f34aacb4f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-269053b-1616912548399.tgz","fileCount":7,"integrity":"sha512-QObDpf77rOKcaeLBXyoRP4vQi1ZWgMJRQnUDA+dc5JKlo8FMCLq1hHzmwDSvT45PEgKhcrT1CCrnANCsANQsbQ==","signatures":[{"sig":"MEUCIBMx+QLzo1ovScUF/ghYD9AyRRfQdB9j0IjNwUfjLUajAiEA3ag1fuTSxaEVPc69kJzbg+g7rWXaSbolbKWN/y0HXZY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYCDZCRA9TVsSAnZWagAAcWEQAJVy4ZK+vwVO2ggaD66B\nmwIiIY4JiTJNdlE7Lknrg0Ki5phZ5uObWp/EwPxHRvQsM/DmXaTQi2K0yf+d\nkwqoSRoTTAHgu+Pa4/XViYKPnev4wE3GWnC89gmCIt8C5dPkDCHGq3aV+d36\ntUaUzocUD++6DOXO2zrsnXJRZCPMSz+ocIMRPlTWmrOnLqyb2g7LZQwkcptv\nrOIrjaYi0/TXkRX+G3+hSJMjCJj11YLOnQwmnPVQRx6o2V2cw6yxLf63WCbP\nhagLB4NJKyXA+peAyyPYJM0uW/lX1EAIrVh/WBskBPOckHNral7+7ShabbX4\nviDH5ZzAp98yxkgIsl+91G2lpiKbJ9iIlJhCbpLMNsjcL7aZf/zepyQ2qHMg\nnNQtdfpC/vfOK88lXd1mChJIzJsr2yDDO8/bQnYfaIrySWB5D0TTaMqWHDoh\nagOhywZoEZlpEkNUGjcgSJNk8qB6zD68uPS5RalnoNsJ7UpW6qWJnUa+sx+0\njsI0w+az4f62FdeLZLpXkJXYsrKTkWhZyEnvkVhwD8pOooXI78wnCDRtuasd\nSmBVjyThgSwezFXx78aa9Fz0/MRTDrp7uKEuYJ5AH0ysJhWXlyseFoYLEjY1\n6R1k90N7POfnpGmknEqM8gwtaFbc6M/XIA8589ZH+uZc63nAJovwImTtVi2W\nVADL\r\n=spXP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.1","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-269053b-1616912548399_1616912600978_0.18882518368338008","host":"s3://npm-registry-packages"}},"1.1.0-canary-269053b-1616912553695":{"name":"@iadvize-oss/store","version":"1.1.0-canary-269053b-1616912553695","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-269053b-1616912553695","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8843847b5f0d1d507fcbc73602beb3fe97429157","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-269053b-1616912553695.tgz","fileCount":7,"integrity":"sha512-F9v0lPXRDXYqNvHkYcUBznQ4i61MI3BOT+n7Ni7AjOxQgFwSpjgU0OgJHc4RSQiofmC4quj5q8T2WVQgo+FhXg==","signatures":[{"sig":"MEUCIFxkZX+arYq0SYo3DKXOAg5fAjv71FmgEBB0/SjZ71/VAiEAgMo5UNj8i9F/nDLFzAxtDn73aAqLvfRiHHB2jGxWFU0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYCDgCRA9TVsSAnZWagAAAQ8P/irY/UcMTuuH4PNMrFZI\nRQb1HuK6adfNmCV1+eh4Sty18BNtVo0bqZoz5YO9rsk5tEDnh68Pev43BE+n\nJqHH6kkqtWwbBwledIChOp/zrky/42dgUgpzpz9Z2L4Mofnlhx8bs3501a6X\nAFSnlo+X3WbVXvdF9eJr7kS+M+fBjQ3Nxx2NgBRVN69uqYUy96IqNRpr62fX\nJBBBgMkVM4/V27jlpShO9xI8WVqnKcCGRONo21/BLPmW0fkUg8GvrOotM43K\nbxhBD2QZs0hUoaP29qq1YrH0C+G5LaCmaOT+u77/6PtAZR7Bh268jtR3PdOW\nQyfrK+QTKo26x//W7aYiaqKlL5ZKkke4RA9QiVg1fIvC5LB/u1+xGArDML1y\nETKlqcgA2UJVIOhHO9Gu8Vn3GTmFFU+VkMl41rdsXnQ9OzYPu6q83RHKq8TZ\nH21B/lCz0apC8NcborDlOL60hStfv3GBPKPFoLue2m5k7GaYowvgT0b3jR4A\nMZsUnO2c2AIZB6MHSX4UtQ+1+YA/ccr90J+Oi2YFP/pytD7/dMdtyU0nEH3v\nVIeOPtyUzz4mgopCVhte5pOMG/iXGzwIxMbcrPcB0gqtS1gOpaJlEXZpGkiv\n5AhfH08QhHW5w49EvLSHgcoI6dwDtebWkbfmi7t57y/w9j9/GRMOLYdDmvnv\nymH6\r\n=h7W0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.1","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^17.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-269053b-1616912553695_1616912608234_0.2789523118760733","host":"s3://npm-registry-packages"}},"1.1.0-canary-22ed9a6-1617008363456":{"name":"@iadvize-oss/store","version":"1.1.0-canary-22ed9a6-1617008363456","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-22ed9a6-1617008363456","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cdb1aa7ee9ee1b77d6e3d037030f02d893024aa3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-22ed9a6-1617008363456.tgz","fileCount":7,"integrity":"sha512-d8TRLnnfSsmWvmOMKyvNpcr/+SCS2z2uzOkU+DNV5uuGgUFiz/OB3oBABPLem7i/GFzCXL62xAD2C1hD/3MLKw==","signatures":[{"sig":"MEQCIDj7f5BYfUY2mIoHteVifYofsno0f0Nj8aisdSUrVQuSAiADaCRfbFJqYkhVDGuIb+z9xUdHUffduKWGjOV6tcnevA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYZcVCRA9TVsSAnZWagAAH/sP/0l09V0cEgvGGYGXxYZe\nKULEow6t1sIzCgSGrp4o/oTb+8ykPNRFPES2Diln6K3y2vLe+qsUBrC17Elu\nvK+Y60XuJbdxs71zh7En3LDui333GzwgxmpRFug7475tQAOS9IRtXas8b1vo\nRQD+VKQI0L60ZtovA0VafnqX6Yk1w8AyckaJ21tYcmLBK35SRIugVSSsWQIM\nrUIFWS/KBOjPR95HFHwazcpyoYk2j4OGzaM49re7FwSArnrKypOaJkiZivwL\nWcJm1qIqMJxhBKqwkhXw0IXzZyk3EB68ERoDdanJC+qG7XAleTK+c+9YXE7y\nm6bqWC/+nSnQg3sNmkgMb/SSiQ+ijTxovRSI3X1C5VvCLEuHLSA3+thjY9v2\nEPs3NgmgC+AE3HtFh1ORPYbZkrE68Mg3sqROrEcyrZ6I/SVCyf7sJ23RCqL4\nyOn1aLzTebbXXEvkZfz/WyO4k0+eAuK0Fnlb9NqBneYd9f1YKXBrWTJYqYxa\nT3IqdO78IlJiuNwIFilalgeo4V6e7B2BW/ZtAK+7qie6BQ51Ju44cxE5dR3E\nXM4UKdAUCfOCFzPhFba5aow2rgWkEn9Q5uWPPbACoBXtmltB7D6OpJaO+efh\nhbh9X+znROKbA5cOmIZ/yhWLw1v6v+vBAxaqBdqdPb9Y6yZ5EN4c3ebGnUqF\nQqxU\r\n=3cE+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.1","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-22ed9a6-1617008363456_1617008404906_0.09958001481771817","host":"s3://npm-registry-packages"}},"1.1.0-canary-9044414-1617031376057":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9044414-1617031376057","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9044414-1617031376057","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc598ca91e58e49030e053fe3b06afc5fdea7f71","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9044414-1617031376057.tgz","fileCount":7,"integrity":"sha512-TZmHM9MxOG8Z7HoBX+DIHJSbBa2FELxjNBRgrTiM83vhipzS5x4Lq7WH5d6Mbqsjt0FqXqg/C4NMSers6Tps3Q==","signatures":[{"sig":"MEQCIGdifw0WQ5r/opUyWmW2PjHkEJpnzz7Ka/XD8qH/5elpAiAjpQyEn3w9lYRIZRO5Kwo6VE3arO9kxkD47taT8WWeIg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYfERCRA9TVsSAnZWagAAPMYP/3bFHZnFpsGqoQHvfUrx\n9NTV2TVhHAgabF8SSoaPSezXzitvfR9EuSkqeQt5kUZBQkAhtOctI8t7wiUa\n4B+UK78Wyoc0ukSNkQPPzTQfdU2Opsm/v64YGMEi1/ZTb5k9GYegvmTMZv0v\nYEzjHh4k98Ej1+Y38q6xpgIlXHzN2+9aAtUv0/0qGzaWg/bH/qgfzD0ZZOk5\nYBXIg1Axg80aPdV+SKkRmG6ctgwi33gOz5C3mfsaywlsztANeCtewdlh7y4p\nSqd/IhRbDFggnQg9fEIKl0zaEgtmbfKDcYbEbS5k83d/5AiYXOupoZcRYqDZ\nbStPoiLEwrp+O8ElmId6cqpVFFGKCSH/p10NUKNYCsTmpKMHdX7zCczn4tJH\nFvSKpbp22bEzXS4G+oHrEMgIOPgKLqmIy05p/uBQ+VwZ9qKk4sTgB8voDDpU\niamRL4+NNjkGrYD4M8e7C/wdIFqvL5R9c17FfFtlCbFQ56+7cijgSI6BdECF\nZhLgQXsgwtIHuLDI6sli7TC6OloKlmkUT94xZAV8dUn7e/oWG3PplxCdPqpT\nFMJMynXesrIL6/FYBbHQz4lgIB2ZsGoeck5RgRWA4wn9q5+U3wTqht5FkpuO\n5etHAAJcSOQltfo2HBf1F5bRYMgQAFHWkig9/U3DxqiiQ6cj+WQ29by6ZjfT\nCq7K\r\n=hnPz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9044414-1617031376057_1617031440774_0.8963787190875583","host":"s3://npm-registry-packages"}},"1.1.0-canary-74d58f6-1617105479651":{"name":"@iadvize-oss/store","version":"1.1.0-canary-74d58f6-1617105479651","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-74d58f6-1617105479651","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"12e7ef8288a329c1126c0738b772834479b905fa","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-74d58f6-1617105479651.tgz","fileCount":7,"integrity":"sha512-TrCSOxKCGL1KHpNZkyd3E4z7TUUkcNK073Fgo9I4Hy7zXCAGnczk9PHB34j7o367DZaeF0seaoD5EcsU8xcn6Q==","signatures":[{"sig":"MEUCIQCuvYst7ACeSHiwyFjwMhYs/N0avqyANd5T9gXQjdnx+AIgFQCxR5QanSuHLpNNfrzt1ZefaIH9I/AKpkiWYoWK6GI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYxJ1CRA9TVsSAnZWagAA4lAP/AjdCULIHTgFVDWQ9N0R\n9PhhmpK7DOY+s/AeFbzEFyjij8MBphV8zycyGZXW3z+6760MmttwyUyBNlxo\nqRbj/tF19yYAwkKDawSfm+VG5Wi++ZHNjcKz1j/+y98e2XKUiiAr6nPAqxYI\ni6hk3/1Yv9hBtGkSbH7olFOjU85DR6cxltXvesZGKZUnJa72+k/kK4ZVlhmR\nWcadE35HDmOHYCUlZCxqNPRpsGdHiJDTzaR6fGW7WoeLaUEgyoKcdrXgyX+n\nopT7sG2PdA6o61Ux+JsukRkhPxZI4+L69QEL7Ekd0CNRUdFTS1FPiG+HGHwk\nO46uRDUGQUN58SV0qAL8JgHrTr8Z1XwOtEtD6qE5VAutGHBUZ9O1l3ePWtD3\n1GxtQPk47AWPXSnXo6fxYOStgEt93e48COdJmue0KXVPGCBAyIyXBptffQt/\n61+1gFXi1BeB1K3J0c4Ca8QgJpuQjYrSbIpuUvfldMiLgbS2oYBfFEuLbVJY\nPJygbpnOF1IZsUcA6LQJ2Lk6K/vg5ywpyUTD23TKQFLzyX0LUHMCs/GvHQY7\nY5R33QTTqWdTutz0Dv8MoXHvkC18+NAmTH2cCRjqWn8c8yg1JPJAgPcdwA2i\nKLrMl2hCV/1OSaHEIujjYMo4AA45nehgNoSbqv1nQc+k8zhCOZZkRXn1hPjB\nrSXC\r\n=raOX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-74d58f6-1617105479651_1617105524752_0.20404075147067235","host":"s3://npm-registry-packages"}},"1.1.0-canary-c81152d-1617480993069":{"name":"@iadvize-oss/store","version":"1.1.0-canary-c81152d-1617480993069","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-c81152d-1617480993069","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8b19400afa65a72cf67ef84f4324f0b46b9a2f84","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-c81152d-1617480993069.tgz","fileCount":7,"integrity":"sha512-995DGww1FKq/q6ztKSmPKcfqPfxsF7EmCQPsn0SwdVQgr60Z/K6z4TGmaUYKQtZF/U8t6QOjv8T86Emz5eqrOA==","signatures":[{"sig":"MEYCIQDLRWAnD8K+fADEMPo6cp6DaXk/cGtQNyGQH7HCHu2RpgIhALCMdkT+VVAzm+e8+pklBfSzZF7ynYb8FYnmGHZRKHku","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaM1WCRA9TVsSAnZWagAAsLUP/iH6Kt5aGycjRGzyZ7A5\nOvEvANKhf064OS3vAd+JIyA/0cKS4NNH29OovJEmQThnGCCT0ly2ZcHiBngY\nUZNraWJ5ISVBK1CmUdtskY2RlQGchJxegDdyw5D8DWJjo5tKLlRXJEzCp3/2\nwHrhnPSRwDwuPWIzdX0WiRi9Y4wvlS0sGD4A+nkTBSPDp/86eymXP3HM9sRI\nyHFZnfT4tKwutykxIrfIbMT4XEBbO80gQ/glYt4OUwiCL0O+xiw6r22iGqjz\nPNcoDQZG6yqoWzNZMrSFZNpCrCCINUY+fgIUX/PNyRRm23/REk1FiP8AEI2M\nmrSnth9immGGgzAWc9xMAXznCvHrymMDhqvhL4FW0S7FzOid0LpH3bunIdoo\nQLnYfwG7JEZLa23lC9kurGzveNo/Xu9U9/FU0/+aqRBNSvGkSv5TzS32ILSL\njTfTug7ofzf0JkskyWth9FoB7bcgrgoPU7s7OkI1LUCvl9/j+fGUrHw6Fj3Z\nAHF3cP368X4Xb50BlkjhXhJr4p7M3HUJ1K4T6EOpXLtDDK/2gE/cOFWTpKbl\nZLErTRtaWUo620iQccQf3/DOLTS4ZmiO/WnI0Jnhry5/OaHvXPkwBS4wvUTv\nkko+yDSmdwTCdpTrjsPmM3ffACyaI1MiJjgoos4OlbM3bS8F7J//omHoSQA5\nqJ+f\r\n=AXq/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-c81152d-1617480993069_1617481045671_0.704819154446537","host":"s3://npm-registry-packages"}},"1.1.0-canary-0453292-1617578067624":{"name":"@iadvize-oss/store","version":"1.1.0-canary-0453292-1617578067624","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-0453292-1617578067624","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7657f83fdbc40d1ade569487bf1eb3c90dc56346","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-0453292-1617578067624.tgz","fileCount":7,"integrity":"sha512-lDd/bACqQkhge1q6Q9dJ/Q5nz8rD2QbqQeS4gn2e43P1e8/FkycEP+xGYD7tFf2MDI0HseJvJTq+W/4gm3spnA==","signatures":[{"sig":"MEUCIFL7Hg/kp0UoIyUPio69KeYQ8u6Vt69XnBMPYLdTPro0AiEA+sSnKxIzbrf48wDYekH5TNwl9Mr/nvbo5TP8T55dS4I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgakiRCRA9TVsSAnZWagAAp8wP/RNYxGbGia+0TxH+Ecpz\n6a3IDHR0rKv0Z+rFeiJCeOwauLD/OtwGwr2z7M5k96DI2XdJGibb0UFXHhVv\n4BxgdfIPzeeQfdkOxQR3E7qUhffi5nxEv8MnHcEHu12N9xs1PpWmYsSs23d7\nGR70pzFIWSLcrExxYiW6jCHVYtfVedcFpDGVjyFiKynY8oVl4hRan+8sPk7Q\n164x21ohmwk4KCC2aUNW82yRCtpnHCoBXyEZmPJfrnMGNH37Nq3gsSjEKztw\nyq6+6+KOBb4CaCttgSQ7R2iuLX1SFgGWtq5aLmy/DMDwA48wwo3B0R0sHM90\nOJj3lT1qcSRA5WdkNEDHhkmKsvXpQMvGcdq7TvlLTZM2OQ8mqCNltqsMcJuI\nqCthEQhnY9YVyQYHnOrctCWyQmLe+jw1eu6rco+BFyfWkjOzxHnBP3isBNH+\ncqfHp5fV8uTtKhZJ5BgIsDOu0mG0kxeypM+FTo0yAcfCjzZwJzBOzPeSt2o2\nuxVRUVKUZuoPXo9itTMR0R4glh+m3ixIS4zlM+GOlqq3joAqb+0VJ6wduW2z\n8nlB7Jh2/q+V4hvO6WIo6ZohGMvTOLFyQNUv8rk0Pzk4vTz15TtLoXogoLMm\no58O5BpuztbKhZXdZU7swKq84r1LOHbL4luU0A64YN9WemkMWcL2Cq1aRuTs\nN0p8\r\n=D4WZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-0453292-1617578067624_1617578128891_0.12619391645589362","host":"s3://npm-registry-packages"}},"1.1.0-canary-0d0056b-1617647144564":{"name":"@iadvize-oss/store","version":"1.1.0-canary-0d0056b-1617647144564","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-0d0056b-1617647144564","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2f6dbd42eab2ead4d2b2646967aae4abf21acacf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-0d0056b-1617647144564.tgz","fileCount":7,"integrity":"sha512-fe4kiCd1CYs1E/ZP6qkK0bqKybUJ8k5keg6vxicVufa8rCl1TD4OO5wcNA0HepPsWMesUq8VLh5E/yseDdymFg==","signatures":[{"sig":"MEUCIQDLa4w76N21fvkp/2zN1UlPgFAUhI1RiYc0uDxsws0LmwIgetCb5sHNP2rXDPi44g4nlUDr3gdjq9EtXO26XigjyDw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJga1ZbCRA9TVsSAnZWagAAJgMP/RbaOxI7U6WGZgV7e5OG\nVdNa226/lS5ylwdvwBlIDuEs6pFLZ5LGxbV+YiLHwmQ7F+ig8R6JwdwdW1lL\ntOff0xf7DsGVB+E/WI1K0lE2KHO4Vk1zucaQ8YQlUwssnHk8x5TrSvAu5YHE\nAV8k8wJ5Rug47LVqV1G1U93RM9VKRgrd584DSTSLT38iBA7lgohQlCOOAH86\nBrSAXjF7J7SOSnmRfIPPLQYEzUkQAHvCMViS5bVehQgMwtMmVK/6qnJFIeUA\naGjPQJT3UgmZPpswruNqsbTM8W8X0e0oPAzRyInvNSP8QQasGJu5EKhYgWx5\noRdABI9RAZVF5P9BSDjaKdcW5vKhY90abtqrY5AnOtlb/Eqyji1FGko0xH1h\nxoxULe6hIqXpqrQRiVASgTs//2Jl1AREaVQTE7TBcZ6A5AMEAI8Z1it+5dDE\nNfmAcixo6fC9nrpfhdK5i5NvIFmOpxzNuXlnSrXmxkwn5NCQG+LrCwtQexNV\nEe2SdLwxhhVN0RqE08KyqqlMQs5AeOyxmd0GSsfoXHlsawE1gCKWNXI245zC\nxSsqg0NonzVkdj70msU44BSY9/BM9wu87/MsOzsLYdKOVm67/8RVi0bicz9Q\nMpyEkNWZ7sK45yNOGReiKeUXuA12KdhSu9qOLYXkvpFt6tBlhyrp2BSKO5cB\nJw0Q\r\n=swyW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-0d0056b-1617647144564_1617647195351_0.7291716556120138","host":"s3://npm-registry-packages"}},"1.1.0-canary-720b4ac-1617694405399":{"name":"@iadvize-oss/store","version":"1.1.0-canary-720b4ac-1617694405399","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-720b4ac-1617694405399","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0cbe20d092ecf952a7f7bed91bfb235f4ebbe55c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-720b4ac-1617694405399.tgz","fileCount":7,"integrity":"sha512-2JLdcGQGqoUeEtZiSs9n9C3ZOhU/NoiFDh6XYVHT/neUYEV7zSIV2Xc8f09vTFi3RDTSmKa6L4efHRK5UKN3yw==","signatures":[{"sig":"MEUCIBbK2sUjEOAV6qmPH266lMt538ARCeftoXCKuFLKtbjIAiEA6AVh41SWVcXPvS6FnAYvulZ6rSsOgs//6DhBImhx3kU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbA72CRA9TVsSAnZWagAARtYP/3ZVJVujxlNIIiek4H4r\n5FdgGiUcNc1j9kvGfiQRa7502Wbb1Qm98bsbrFZ2H1ys90B5yy2J6uTF3K8b\ntUeHEaN1if+QSg114cUbQALIy7gODVbx0J4lACZm4ZptIctx94t6ZlWbXwsQ\nnTwcl9WW64c+RnVyS+jp9GrBSDniZzkpN8aCyWbMR2jqztZkkB9CigqFSIs/\njuBYr8jiqBFMlvTY3vgWNUs+aIhKaVZ5/NTr75l/IXG848j4hhC8pRthYI16\ngrd7xMxZFR6IliT2joGOsMUOyf3fRwPg48MTvRY2LH+S1XX7Aj6FxIs/lgTc\nkiFyrqlO0GtAInGzXWdR7l+07w+m1QIjiEJS4SrdXJc0tP5E+PUone3IX5Ve\nI2XT2CdvEdHXmy0XjtFf2QQH+vwk0xGNCeXD3ce3IxUgrZKbvkFZS/lQeY3n\nWL0tb1lbQHAD9713xbYFxnX/3M7st17rlR5EoOTtm277qRcXzuklDKxxPPNT\nVwTR5qfQHtLLWOIr/IadALSRjSbN7ODOxYvr31bKC3kBNqY/LY6jX2V8lL6y\nmyQWuUe9AdgkAdip7Ajs8yfejRyC9imeCUa78nlKnm/GOREbpGoCRxO1ZC3B\nPKD9PTFwIn/mLzDQxyN+hMVtomv8arF1hk1yJZyriEPWRtAeyRWGuNr/D0ur\nE4zv\r\n=frdM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-720b4ac-1617694405399_1617694454093_0.8097647973746469","host":"s3://npm-registry-packages"}},"1.1.0-canary-a8c599f-1617697953962":{"name":"@iadvize-oss/store","version":"1.1.0-canary-a8c599f-1617697953962","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-a8c599f-1617697953962","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3123538e71349bb40f095426e6ed2ec0a0a982cd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-a8c599f-1617697953962.tgz","fileCount":7,"integrity":"sha512-PdIz5+fh1iZW2mSEQTERgYCISzBdUXtkptAvbLo2KoYxJS28bTRsFo+6/HsbPFY6mTaY+xKv79pChEJKUJnC/Q==","signatures":[{"sig":"MEYCIQD5Eo2xwes9ZSYoa8vujML7XMp2m+gu8G6fOFWvsbIJ0gIhAIe5TWKfz0LyXyKew5u1V3Y/mkmcYWc1hsL8VAYuprhN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbBzYCRA9TVsSAnZWagAAtSYP/io5BzeqHp0ewz7j7oTH\neWeBzs7QRmd5w2cF9fQkP1yA9J16qwnJfUCCvERcGPY4iiTXk+pfzdi6pQNJ\n+o/yePoYDfDnh+JdukxteRxsGWm8OHjyaBKJ5uIjoHrPblI7X3Asa51pJDaO\nM31GOeasnv9KiWuSJH9eO1PuOY0MIdyOsPpbe9kMeUtMFhsgVR4vUdwFZvW6\nDhPYjbjogzWceDIpdr/6AHbQIG2ZqDfwPSpQ5Jq8veFmaabMDSgRnHKorCmZ\nd8KkSycH+gCYGH7qBOABsgK6ffMc9SzYUwvktUiUcTlZool5hw/DEKuPDlhJ\nXcz/m3Bz0S1aDsT2Ekw3Pgya6hqGmgwb2UqIWeDNOQjXjMTXltRluEbCBVdf\nkLtMXNpbbQTESypqHP9I4Od2Cgi+58sqimaHnMX+UBQEJ2JbX2Yh6KVQCcSi\nIM1wZvC6A0lVYYZEwuDXMifxDw42tDy9VLi0jmS5TXrnUPyJm6LUQtZxWQuw\nMlHfCER66aZq1h2L/hnIFNQuCawwuz3pFdy/KhQd6eWcAorgJme4xOupYJ+z\nL5SZjZO+yRNWAyI9bn/6r8aks2+JxygfixXJCbA2SUMVZmrjI939VCxk7mfi\n5M3dch40lkCd/95govfwJfy37bi1OOVgibc/faJTiBDeqYRs0GRm1MsTRW6c\nWjIM\r\n=htyo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.3","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-a8c599f-1617697953962_1617698008044_0.9423932465929323","host":"s3://npm-registry-packages"}},"1.1.0-canary-4a974aa-1617821842815":{"name":"@iadvize-oss/store","version":"1.1.0-canary-4a974aa-1617821842815","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-4a974aa-1617821842815","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fb5e611826ccddd3cb2f5334f647086be33bc86c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-4a974aa-1617821842815.tgz","fileCount":7,"integrity":"sha512-iX7rGo4+iF2N7C7Hr0E792nvuSI2/02Kxg0/bQbbDgs+4wkJ9LnUmNgOGzf1w0cBRJ/RaUurwJyKlr6ZAxbwDw==","signatures":[{"sig":"MEQCICnWfr7bMwLg0OeMtREK00xTxvaieEHBtDPSfIftwFp8AiA6nMLSqd/ljCG//iG+AkzF5fhB920C+9EGWxq4el9gew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbgDNCRA9TVsSAnZWagAAc9EP/3xtSbYMRoFwuMjRD+Fq\nC5TEOnGtsOholZUugOfq8b8jo1riQPV+JqBeRohzNSp1cuap5DGIPhIgyQTh\n6bTOMaSIFdv7Qx4xUjDjyL2NUg9vP3NfVU4+tDyf27aNU6EpXAq3/s8QHm+4\njqtdQYUgKMzjBE82DcUQlswMyNY0pDolACXgUnTYodrQNTxK1hssOcw44lkN\nEKa9ITNXxxYevzhPW43tjXsuSCJ3b5RSURFFL6sp6tUtA8eCwEQH0XPun+4Z\nFv4sIHoMiptfJGgMTC3c9NUrBtzA4fCGR7SpFCLTB+74NDzU10dL3vsLEl/m\nOt9sOHq4KbTqg70MqZeYGdq/6DI4YA1j/YHYqaQuLc0VS9l8523sxxVctTJw\ntbjzzdw/Us8fRpn8j4MvLkneveCwf3W5GrttP/z7bvO+64ISBXKaQzu6RPdy\nK8aTpHA2ggmiH2AspfJkve5pQK+IQ+EdgCaSDK+Rlu193PjQfViNsm+zwo15\nMI/Q7+mYFurllBKFplTmAaLArIszggyU8VXAjS5ojQdevf8zTM6q0OHdWN2M\nmdV0xG8AB41Iqxl1VHsLrayXOV4DBUHAozgKgTGw+/CZt2fq+kbV0m6o0MNV\nuIJXoRXp9KJJZPu3fkn2Gednx4q9mhaHX2icLcnSqS5aMeiDA1/OCbUqTiq7\nY00N\r\n=LopT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-4a974aa-1617821842815_1617821901368_0.25685537814645243","host":"s3://npm-registry-packages"}},"1.1.0-canary-4a974aa-1617821842264":{"name":"@iadvize-oss/store","version":"1.1.0-canary-4a974aa-1617821842264","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-4a974aa-1617821842264","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7eb7d3ac97c978a170b04aa4b13396e9acd9f791","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-4a974aa-1617821842264.tgz","fileCount":7,"integrity":"sha512-B2UUgrQ9N5EotKK6llZMaelXg1M3CFQdXNGyglj1tagjO697Fvc0zj0xWuF9d0kpuYLv9pkcKSPNwZMkp10Fqw==","signatures":[{"sig":"MEYCIQCi3Gsfd+22CjePC071pRsuAnErhNBfFKl3uMTwRJKXywIhAKrHtV4EmzK4uZCAXIs1OwbC9YgCqi+Wc2LPmCG2RGE0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbgDVCRA9TVsSAnZWagAABZgP/0QqQGRKT9KNhMWvpXGf\ndESzL+tdGzrOMTOTevi/bz7Xa5oymTj4u5lEh13pMFJ4YeQmYqir3mPl+/e6\ncO9U9UONgkfQvbnNY/KHtsEi4HauHYBjMNgT4Cw/jclsE3ICI4JGrfGURtnM\nKjOYYFuO9Ogcpcb1JOpPIS0KY7WnZ5D71EAcouLqAAxMOQ5yW1Hoc6gLRZlf\nSdU5ipWL65VRV/rKNOjuhnUaDyWOXR5cfzImaPptfI0VFTEqmcvZzv/wDWtk\n0jzb0JKWxMJRf4gmh8pkcLKqbqmuGPet5rp1U7ZSmoUoLTqqWIRpsQ4oMAvG\nYYx98wHG35ltR9yUGWKzmt+WI2b8XtK4gKE82VuvaI8pyU3PTmJamH2eFHEB\nYzF2hmXJ+hY4JH9NuswoTJ+0p9AMdaKZdmDD3Qp6HrVTPM9X/ey87ziH4S9k\nDpTHr3dWS5oKSzoWHhVfPuXr7Rxxrn9h1cNZuoE+HLbI+JcvT1kOemUrNThe\nj2iXYu03Dtyamb4vX/PEmTfHcI+MgZI5nhM6D6SBJkqyxbJhUm+I1pSGf3cc\n2IM+zbTn3qSlIcsWP58GqoM7VcBCZZgUafJAH5EYNBdpNh7wZbkLN7sRC1Du\nhtm8v3y38XFaiyw9Abds7WUM3IOo8WFly1w/LMIHfXDCMNXE/QE9OOISMQ1q\nUIyd\r\n=tJsw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-4a974aa-1617821842264_1617821909347_0.38375960942374276","host":"s3://npm-registry-packages"}},"1.1.0-canary-04a6624-1617833675244":{"name":"@iadvize-oss/store","version":"1.1.0-canary-04a6624-1617833675244","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-04a6624-1617833675244","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9d1b6b61570625ee6d114c9b5805a21d7d4f2c95","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-04a6624-1617833675244.tgz","fileCount":7,"integrity":"sha512-77jy7Lw070tCcmyKo6Tl7OeGZ4sno0Enp0adZUOvNVnHTELm0PDAZM/nKuk4PyTneP7OmxaQweTg6SX5vQek/w==","signatures":[{"sig":"MEYCIQDKsCy2OSSnuxwibQtj0y0dowXJmRjoNS18LrD+0h5NbgIhAN1TsmqIfNiNqImpYylCcf7JDNVi8FBOmB9aV4ZWAdEt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbi8YCRA9TVsSAnZWagAANLQP/ilQ+ZXfeRCHzqeRU+kJ\npe714DZdimp6BiBhMuqYOnmAR7lu2Dq/Hijnk7G4AyvjqEwjukXuf4suZotq\n4PzE2TDbYG0YcgEnW2uIXBsm2gXa034UD8/NY91WlSw9CqkildR68/lZFPA7\np4d4PNxJTAhKsxMQX0rPpzVwZm076ISntANBs+fRlWvwkWjI2f7YMZakjcf8\nDDbDOETx7jLPgcAkVWrZfBi5OC/b0lmUueX9laz7hy3EpwkLuLXinZNsTtrz\nMtRXwNfZXbBSBP0ejLIIFpFAJ0XGThSdQt8M/JPxs4ItFDLouJcHRHYsYvTW\n4Obk/oDuEZie6iFNu43o1BQzE52ajEF4cmte/vSOHfLGlmZecbxtb9ppiUt2\ngURDbsfWEaauuotZFsWcg7aC6u+zdlSMeBdxTG655DdYvKirIx4L2Gqbojmv\nmPAwBori3ozIIrklE29Cp11Dxl49sH1Vcd6sJcol7J2NZCr3OGYhS8iLB0i1\nzToxUTSAYWjAinoUHYx0bz1i81+uEO/B+6PPRBAOTiw1ZW+8Y+YQ+veWCcdn\nBGoF5VIq6C7L9NsGOL7KsJnwOYvyjge0GUXffmgd0ivCNSjSXixCuDjvbAWJ\nNF4MkKM24Cz4PMFzyRqm0gc95sInYXDB8Xy0YcUx+BdnJUOx576uoOeKh0qX\nEICu\r\n=EcQW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-04a6624-1617833675244_1617833752100_0.3234674313614354","host":"s3://npm-registry-packages"}},"1.1.0-canary-52ab90e-1617946100671":{"name":"@iadvize-oss/store","version":"1.1.0-canary-52ab90e-1617946100671","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-52ab90e-1617946100671","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"93a7fa6cd9fe18cca2f3805e5c70c6d25c6455a9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-52ab90e-1617946100671.tgz","fileCount":7,"integrity":"sha512-2DbzxqFcD4wXO7GyyUKNaMGiMJzBEMB2qTkpdkeWSvYPTjajueroYmuEAnKyuu8Qm+Ek4R4r/4qocpXK+CRVrw==","signatures":[{"sig":"MEQCIBpEoKG2yq1cwpLMIEf8fNfLIy5gzb8aw6KWz5hd25irAiAQ7Wxmt/U2eUiZZ9+c+yRPxfZCvuwRY6/wFC3xAxSvMw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgb+YfCRA9TVsSAnZWagAAUmAQAKCug2crX97q2y6TFTgE\nMcbLILraTeQHpeoheBLo8fZHuWa6JsLLEFK2sYl/YL4z9JZqc/+xYj/o8HG+\nG3m21uQqpWutZdocXID/xy3Wgz9KAMDgG+ufGCYRl2PtfXBNynQSdvEG98P/\nARiBFAgxSmTcNgs9dTEt8u1ZJEqV7FWV8tsoLX17/wrAk3TfwP+JXH6ZuD1o\nSydU2NooNkFkMy6e/viRykPrhxSpvgU0O8/396i/njOdcYNG9kPlJ68b1UVl\nH0toAF26ezD7ghZ7/bMicF8LQx+PTDNimau5wWTbqSbOES9QMZysH7G0d7Ig\nDvcmdFml+JFPmxuz8ZCN5uXs/e5e2YvtmOHgoZ0v0RCn0b5D571/inHeVKNZ\n0W5jr0vKjCOA4XeHD9xEA0gemxK7sRjgyvA8GEvQ7klgjpvPrmnuj7Iycsy4\nmtp4VUDeXaqV8o6zrLDdHgyCzCFCL3dRJp+0lx43mnPR0Qd/pG63Wtg4iJ0x\nW2eew5/qwKrEqDlRMkRgBeKVmZIqXsLTAqPPDxNbFCaw3YDYz5VTa4H0Mugn\nv2NSafgb/NOpnvATE4W5W5Y1SXiNsGnmO9nH/OuKoRf+0QGclElNEBtoDFUh\ngsAg/RbEMs2qpEDxNV/17qUi+RfaC5ySE4kAaABx2SX0reW42WVLZLa0k9qw\nXuZS\r\n=jY4e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-52ab90e-1617946100671_1617946142739_0.886896453787287","host":"s3://npm-registry-packages"}},"1.1.0-canary-52ab90e-1617946100231":{"name":"@iadvize-oss/store","version":"1.1.0-canary-52ab90e-1617946100231","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-52ab90e-1617946100231","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"706e0eb69ab84d0ff99f6073b4a602cb16739fa6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-52ab90e-1617946100231.tgz","fileCount":7,"integrity":"sha512-G0SKtlrYMjc/xhgWXsDCWr1RmGaNh1Pj+BWlrC8DbPdjUoxLuHYQRa16ih/8poKVB2ZiNDsQda7ngXMjZO0t6g==","signatures":[{"sig":"MEUCICinQpkywRH4KLUot+dob/ECHnT8zKfsLJq3SJd3m9YLAiEA5PPSAEjyL/+3nfRX5sv9Sm3H2f00kJJmnMDsK7IBPSg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgb+YyCRA9TVsSAnZWagAAJjEP/RZaoResCr3oTYYhYEix\nU2Rc8uUbTGB9cGZwP54FAWPdPnEI1Gqn0Wcj7mF0CDTz8x8ixYAlpGq5Pr4Z\nzuRncCgQ0uTe3xukJL/nekXMJqa32PHprT3/i2OT1FaPLWhHtOkiReCM4s4E\ngObl7aNHuJbg1ndbRk1SSy1BgvzJnPQ914Rb8XlCzM12+C/2SDm9kF33Skz8\nSI2OuKeFzBRiemQPjLCgbSCYZz4FFKzGzG9sNimYastn4IQmXPli96zKJr94\nN7c6WVTwFlknf5Kt0nW5w9JsSBAnIZE2i0V1XmycwtRS1HIClsTrWiO/czae\nt65SMUcSGVwjWUHgO20gSE1yH2F9xapct3rHgXRlK6sF7poGXTryHBAGwQPs\nfbpWamuIV8JkegPgGO3QS6zMzae7QukdJiA1btKMafMi2LKo8TVUyobPzZyo\nZ3uPw26Lc5cZ8I5gr+Pjj/2rVWD2ze4y+ZUq0jCepVhNmIcsqKspmxdiSiQi\nphuUrC/RgSoxoSTJmN/Tcwh3kzOw6NsjY6Nnpd04ZGjT4V2+iu7/8D8ql4Pu\nkRtN0Uhz9GcFdVuxDIpqSjGyNlUvhsjzR2K9vh3CZMsJjDA1gjVSjEgxg4WY\ncIMB7F0RWQ30ZgCgpFoqcw2hoM1m/tvC8cMULVS/tQT+k4aa5OGtH/3Sq+/B\nPVua\r\n=CBmj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-52ab90e-1617946100231_1617946162100_0.7876446713018812","host":"s3://npm-registry-packages"}},"1.1.0-canary-b9190f1-1618006542651":{"name":"@iadvize-oss/store","version":"1.1.0-canary-b9190f1-1618006542651","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-b9190f1-1618006542651","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"63de0f1e96d510afecff481fcd43dc0c570ef006","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-b9190f1-1618006542651.tgz","fileCount":7,"integrity":"sha512-af6B74JeSZZ+J7C8wTPE5fpeyPoAjamJ3bV3NDKDGaAEFmNPlu4zhvy4PQ7h8otSRd9bQVvNXDrdFqkTf2jw0g==","signatures":[{"sig":"MEUCIQCdE+yYetXJXWeloa6Rl0A/2rgZnijXtFWTzDwXFEBiswIgGppX47QtfoVqaOHeOxk3lFO0gpeZMhb9M7AI0XX2oNg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcNI9CRA9TVsSAnZWagAAFRQP/AtAqZH0Kw9ORvtZ09DG\nNzyrka7TU+17qoEaZznKbN7+IIqMDNiNfTrO8rw9nmPOjGkXkxke0j0kBS7B\nb8+zbM4yeEoK8lyt1eZ7oexrBVotNU4aesB1E9rnLLcmWu/HEbEARuyIDt8s\nG9jvwNGbZfk3xTmdwZN63Vk9ncJHdHMCd6XCVgP7re2ne0O2hNvFj/nqPhNB\ntxzNtoX7iZ6HcXh3f0L0+GRNRMb/5posvuyU2ob5u1zQkZR16gKHlLMz6dyX\nGJVLOIl69c0rZWML6uNtUB4sVhVoE8LtU117rAuuZmOsd+MrLfv6fUaZ/IGG\nvn/Kq1ASbDy/R8uOAPZhBo2vRNymavaYMUOnfrCbevn/68UXzVbqD42OOXVC\nTVIEaStMvXS3LWRA9H8RqFIPly+XPyltEyrbu34cxYeUg8ftJ34OKcwhXUGL\nLTTO46C1nWBKxSmpZa6QTw/qBYFFUZE5FD4GjNTIbK7vktuDPzqm8fP79xC8\n9A2oWv5j2m5Ov1TtD6BuwPvlVAoZX2WsugF868M5J25S0ARH9fViEKcV0F/Y\nkzMZryVyFZFGYIv5M72oxnXrine59G08ptTCyxAFIhZo00rKPAzodR9E1EsF\ns2RzFOcfoYH1dCSceoHJi0CWdscOoneNkBwk4/odFg4mYNzV2kEn0sJHLI0g\nJykS\r\n=zVzF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-b9190f1-1618006542651_1618006589179_0.6895488213021055","host":"s3://npm-registry-packages"}},"1.1.0-canary-15c73d5-1618031944727":{"name":"@iadvize-oss/store","version":"1.1.0-canary-15c73d5-1618031944727","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-15c73d5-1618031944727","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d93628ccf7924f9919322b379cf24cf64abe983","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-15c73d5-1618031944727.tgz","fileCount":7,"integrity":"sha512-tHnLKg3SZ1IrEQ8J83VNq54XcZE53ezJBV7nkSUjmvO5jCrkFf568pnA46pivCoQGMPx9W4hoprV/XH+waK1xw==","signatures":[{"sig":"MEUCIF6I7N+LjfCv7xJGTM9d8pFz6yLxRTUy/qcy0sCVE8PxAiEAln6qD3v0qR655qYELESijzUDEy8ZuwQEvVXzaLWdGWg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcTWGCRA9TVsSAnZWagAAn/oP/0jsb2dfbMDOS28b+IG9\nvnnts4+2Us+eLoxMIEDGGpZE/hWO8Zhu5JzzmxKW5FjAscsYZqsa7KAHKpfW\nKI7Ri1bC+LW3NASFHeGZ5nQ6RU34O1G+mNMjVnQTCY11vHWpK4snTN6DYYml\nCMskbpT1ER/sxeLHgFuCaleZS4/sKRK0TlFTZqYDSZePLv3ItOyy1ZV1Rybg\n5XvX1JH/TG3vg6AF2SupVrlALMrk2bhHYQtDRiJCXIcU3VTHdy0Z88ppXy3g\nTDMt8UXspInaxq+dupbnEzrPjpOFLW/jS+h6Yj5N/wcny5Y4ZlQm/b9vGzst\nAJmNN2+YS/iFwVQ0FWldeM0RO8zRXvij8Aoem8plP5GtUqf2nV3BaR+XAjhv\nadyVTwpY6AqNXS4wKKJIDLSe78Pqop8DXsclvQvnVQ3DihL8aTfAqroYuB3A\nW+UoTp08hHZF7CaMtk3l8u7oyBiw1SBoUs5MuAdPCdqbukUCUoZjheDZVn5k\nl6tGtsNbl5nJM9SzLacERnkn91diQPztpKWE8zGM+CQ8YbBhrvescTgZT4CF\nrh7GhL+nH8GfJNS+iyogFCRkp7nch/btFzFrGbZxlvjmzI1Xy5iB5VDR7Z39\nkZnPw7Phy7PB3aCHXlpw2Sn9gVbnllrsmRa/uzBoDRLcyIP4c/c6CtIpnCVd\nnbKO\r\n=h2RZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-15c73d5-1618031944727_1618032005914_0.7217653430300204","host":"s3://npm-registry-packages"}},"1.1.0-canary-15c73d5-1618031944755":{"name":"@iadvize-oss/store","version":"1.1.0-canary-15c73d5-1618031944755","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-15c73d5-1618031944755","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ea52eb48f5db82abc0b8496b4cb907943687ae4c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-15c73d5-1618031944755.tgz","fileCount":7,"integrity":"sha512-N/KnxCs0HQmf4Hhvh4+hHTzAcnm1xY/NcrWa5ohanYSvLYBGX/s8otdXpTUtStv2fOhgmgPpM2xvrGMi70jxGg==","signatures":[{"sig":"MEUCIQCKnIIKMRUVZvDfGodUzyRIH66RYiYVJR5nnJ6B+1WspgIgQd4D+2nQMn/pmNiI+UVETF79jAFJwVwi/ysGXHU0Wro=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcTZhCRA9TVsSAnZWagAA05AP/RS34/vxDRF8uZPrnKIi\nOwqm6sA0Q7HqgEl8GQbvaTrwc7bKgijSmlTKpmeRw73pltx5hpJYpRZ0HrEg\nI68PjN4rmVF1kREWa8uSN/Fjf/NSmDjIYSTEMBQ6yY0fRd/AynSzd0zuD25N\nXQbZ5BzP9FEgoA4GrD1DfIzpPFKdtoJzwHLoGlh4pkTSgsbKG9bWYGs2ZrmP\n3v5XCNi69/0J7DEZZKsEirRf5UDicuSsP3qe0z/MEqi41XVOSx/KzM/EVbV0\ngThCrt2FNPf9uGMt7+O9xke77sZWqwXUaG+k++kLCvOGnnnSRPUYkXL7Q1FQ\nVXS3fg4gFANtzQ/qxCSb8eLb1zJcFLUD/xZ6AQoduT6Rjb1/jNwcox6J+bOI\nwU5B4c78KzP+IJfwXNYL1IXeihON1agyGLAVEnGMtsSm8Q9GFy2rwUqhL3HR\nwn/NskqFjeXRJbhJY8+3Xrfp276stLKtFfB7uJBkirKGLFAzThU22yDir0c2\niWZTAQ+9H0N6WrZ8FYAemDMJNx7N2ig020PqS8Drn0v1s5A+6uckW9CkokPa\nvVFQ9Z+RSlrucOnqNWT3gjJCh054DYniOz4rsLyyJyEgeKhEUeSE6FPZxAxA\nhDooZr92P3BV4SGskoXRh5JVpqoRNvxq1kiVtkAVj6sVHqfCWqGmZQl5giKw\nXg9R\r\n=ZnnU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-15c73d5-1618031944755_1618032224900_0.7822078598065381","host":"s3://npm-registry-packages"}},"1.1.0-canary-cdd329e-1618179831547":{"name":"@iadvize-oss/store","version":"1.1.0-canary-cdd329e-1618179831547","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-cdd329e-1618179831547","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ecbe24ae206c41954601e6df10eb5eba0795df91","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-cdd329e-1618179831547.tgz","fileCount":7,"integrity":"sha512-tk4L5ngorSa2ZAjDZ0YcJKp75mxbkQxPBuZxNhF2w7cEwYG62BykyB6zjn8HIBV9rNJvTVqPiW+mg51yCCPsYw==","signatures":[{"sig":"MEQCIHmLIssHi22j+uePIEJsmi0+lDYudaRwA7gXwwzN4J6AAiAlziXEt/b9V1zERvqVyxo95ZUL2o8ZZjtFl6Cfvh63mA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgc3cqCRA9TVsSAnZWagAAc70P/3ChNPbFLMPkQlE1tDl/\nEVT8HvOd+d5VYEOLBDQpUbZXJ0YCbwRJATHx2JZEuE7ttfRGfQ2ztLJ70Mkv\nk9n437Czx0nXT+l062yR/nuuB6NEhEQHkpP4Fh5wnSGYEiCnAPolnJGvi+w1\nrAFWMF8H3BCpJz7AnyJS+G4GVWMhvqJTH6PWPvS3J1tozkmEokebeLznAQ5L\nlxd6gCJriBwwTW4xeQNEoEnsyC74MRe8AayETJntFnO8oSAi/JbxlIecQnLB\nwXPEuYzh0SbOoSdVkYREKq+JMazlCgMu7lR+B7LpqKOrAEnx7ejchhbt974i\n0w2FckMGGPMFJpRGKeSH/3iNJSQ42P36IjBGnlf6R4UZOwDmdwPijPDTgwi0\nyWK/5c8BOLSQHYjio8tV9J/a9/sK9QV+rpTNKei/bupCR/fptXmBHrwibVrf\nIuaYIX9tpsESVtCaMHWOlLzVSnpEPEUn38jo+Q+8zdPRqHPbCtN+djTOxImh\nZVM/sNbOp6xIF4baLdpKOay3eKusR3I/JHdrFjI5q0qyjGrw13IqI3IVGEqL\npqjL/apkbnAFAbnAXTJNbgH3cNHz7kGbyp2eNItl6I067hmo6J74HwTTnhpV\nH5eyy96LE9fePssXVc+PXxUZp4JZdh4Mug/QwOts7HFXyNwoTTE7PVSQ2mhQ\nl8Gk\r\n=siEm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-cdd329e-1618179831547_1618179882064_0.13914693113285503","host":"s3://npm-registry-packages"}},"1.1.0-canary-e745550-1618265732891":{"name":"@iadvize-oss/store","version":"1.1.0-canary-e745550-1618265732891","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-e745550-1618265732891","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e811668e72537740b5627621ba28ecd467b32df0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-e745550-1618265732891.tgz","fileCount":7,"integrity":"sha512-DeIuQk1m2sX0UgGcTqYxYlSmi5RB8SGIdpnKO7uRt38XLp9B8rTp05BkydIAOQ/3o/jLHsX2JyMKPUgbYOF9aw==","signatures":[{"sig":"MEUCIQCpOED37QaJ/2s99ePkTlHNf1zxl1cczCvZoSFQD5q6uAIgWywpOj6rvCR5mIPDh7kVm0Z//yVQLAqp+F7rIL7nNQ0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdMa7CRA9TVsSAnZWagAAb3QP/3pvFYkqjTFNmv9dAhTX\ngZJfjegDoAJZNWlzbyPKUg3Ud4QeUkdV6ImDbKnabxC+6NqiNU21kvx6BYo6\nDORlGua10keLtSe62dxoCfXECeKkTUOp2abs08Kjup4TC8UwuMkM4aTADvZ1\nPUNmQBTB1oMAV4jEKEWp/2rVBjRvXY0YkVTDyYCXV6aqGyR2ZdOgdNhQa0Ta\no1L3hx1AZa9vH1rpzaMFfCpGKOg5b7t4CwliQKjQ/82i5+NFLzKJBXt4z8b2\ntuYbjr7ao5S2vswOzEcZ3vtQaueGpQtmGGn8rFs4odew0ol9CXmIeSle+vkh\nWFlaNpqZW16lGgR+B1EyXeq9HY+be73wIOit/R9gxrffj1EFziR+P55U3xIC\nmgbDB2s71RQ+8th7+t4Yc/TXcDRKqCzpZcLmBmKvIHFF9b8W39BvUXEtuKMZ\nIVEUXcJ1VETFq8kxR34O0xUHpHR4JrbE68vhmA/feoCLbeUWKRhDVcP98y62\njHodKvag3RNu8+f3YedN/gHjd51DQ6Opky0EpE9IzlAc1s1ItJupJPaEiZ92\nD+ql9rfKBlBntdjrSdagI4KtpH0lYedp1Rs3jDVsbZl571OJa50MmHhXGt9t\nLJKFnIS2z7AFWSjh7DRhy008/bOSg8wwGQ/ITXzzkAcUctFGwCjCQgrcLVYo\nD2I4\r\n=q4tN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-e745550-1618265732891_1618265787283_0.3423165901200296","host":"s3://npm-registry-packages"}},"1.1.0-canary-5fcff19-1618291962592":{"name":"@iadvize-oss/store","version":"1.1.0-canary-5fcff19-1618291962592","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-5fcff19-1618291962592","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"121982415903dc5c895d09c2adaddffd4da4b35b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-5fcff19-1618291962592.tgz","fileCount":7,"integrity":"sha512-96EbMnnzCbNfEx0B0IypI41U/0s+9F+27bMAUgODIEmuTGgsRngsNKifKfglVq7ny86Cu2Vvsdk/uRLC90h4cg==","signatures":[{"sig":"MEMCIEtM/olssHV1QpLn1qn4XvC/eTw9aAaGqMwgSkpncgA5Ah8xwEIu2vkGyCTfR+n8JOjQLZlG3TKYoJDKw3+ywmJe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdS0qCRA9TVsSAnZWagAAk7sP/28rHIVqL81wTakEPCyI\nm1KVUBhbT0/2STikifUxmezP4CkonXAP4amX7OLXEc+ePLCHMziXa7NuyT2K\nvGKW6Kccy0acu9ovnhPWbaN3b6upNktF1zbRXty7vRghXcZTZXrMFIX6hfrJ\nBq0A8cDd5fdZsFltraCvAd7Boj572DcKBVJdzf8888ZZMQSrh8bljrub4QwF\n4DEzjfpbAtnf7AtI78HnZikm1S0Ffss3iCVkLljflfEIG1Bi2LEB6BoacqLa\nPrOEA2OuDwNvKnjXdu5SkYPtrw5MQXmAKQEquFczXx+OHCt8VwiTwNBHIwBE\nwrANabKKPDjN5qAz0rFTxs+S4QEKLq8k7VIGSOF+xjp5WosL6D/OuYKLOeO+\nrAx6tvGYX8QwOnidoGU1/HaxAz0CtH6K0pe4XNSFBadSm0YkKPBvaua/K12w\nbOkUvLfbbSsmfiO0V1RndoCoY0QWguf0BGOUAWownmWXhiAJWPga8urhV0FU\nYbaylp+04PibU0rgXxExrfrp/GI7XCAVZeXjaQptqidBbn3LgYcPbjWBWnok\nDSRpQhrk6r0vFBwFY1YqlL9NgMI7zyoPI1kv+tVnE8dyRyyoxChea2eL45HA\nMdIWRHVh0Ee/BzS79uogLRb0qXWErfmvUXVPLCxaSHwEZs98oRcNQTkVAVV0\nKdHM\r\n=A0oj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-5fcff19-1618291962592_1618292009894_0.3226791258316193","host":"s3://npm-registry-packages"}},"1.1.0-canary-5fcff19-1618291961213":{"name":"@iadvize-oss/store","version":"1.1.0-canary-5fcff19-1618291961213","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-5fcff19-1618291961213","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dae21772d1f919348ddb98b2447ea5ebf0a0fdf7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-5fcff19-1618291961213.tgz","fileCount":7,"integrity":"sha512-HQzkMLTrgfrTfDZanIsc/iS4CzDB1flRgjf9YSz8FP5QFCu3dxTaFKPoYYUC2xOgAFN7mk41Xz0amtLylnoi9g==","signatures":[{"sig":"MEQCICGpbqRqDh8B9jTniInTvAz+O11hBnQzgDISPSpC46pHAiBhdD1NmfroF19YheVOWdssSSNwwezTorj5ZYQCqlfbmA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdS02CRA9TVsSAnZWagAAdK4P/2m3NYPJbHe/ieXF/4sZ\nmz5Z4FtF7p0r/H0n3wq1Vzd82Kld7VBQ1TUyNaZ4+IOiN4Eqo86uxf6TWV+m\nYPa2IDGCDF04y/5MDnz9Pf5wy4nhKuOXIg4QmSFM9aA5K/bCXwlepjWxyoM6\no8uN4S+MUBsTEJ46JHTv/Kw9lgjUKV3eFaSDeLL11wq0U3EHKECQtW28SUpo\nn7bUm+gwdcD4olzu/jTUf4xwgzLCYIyYNRB+hR8gV8eBK4tw0I/d8WXdlfPh\nCvQhX8Bow3y2eqQNO9JNZh6j6MHMsOeWGgiBnwlTBf0HatMtVRWNuFHFwixK\nTGx+k0iZ/vPX/ylhGSg/FlxshFjXIWpPcxRY7VT1xozICFmvjtrbdrtIrHdQ\nYoPuTP4eIEd9JXOfgoH/KzTBurhB21lu4G5ZhRDHoytY8ZOK+1B/b4+v21Zy\n8LLYb3UYN7rJ2rhs9mRhP/YEq9Wwig5D0HXeZcRGVhH+oQwBOk4omeXCrQ3c\nFBUevkRuCWoT6vLBIF0cueXQ5EA8G/Jd3iPcqp1Sq+/ZfRuxFgtCoAcYDxlQ\n/XlOoasjGZcizRLFFtwiioZLFPIw4vI44cIP6HYYKKcdHGjiz0wr0H3/aj4q\nShs78O6DJmZDrA7uuoyShqjuZ5TcFm8rPWVn72KDUqwRG6jsjTGlHis6xLjP\nCKFK\r\n=wjfm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-5fcff19-1618291961213_1618292022348_0.11892438733400401","host":"s3://npm-registry-packages"}},"1.1.0-canary-2244745-1618352161584":{"name":"@iadvize-oss/store","version":"1.1.0-canary-2244745-1618352161584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-2244745-1618352161584","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bdfcbe798a3b9a7108190ff7da0a0d981476c80e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-2244745-1618352161584.tgz","fileCount":7,"integrity":"sha512-c80C1v3CbUcccZslIbR92SH5st+yIBVmxBo5EFRt9e4ufphzN4APhJu6gkCSaxRGFNdCRfUSlOP+hYvcIhE21g==","signatures":[{"sig":"MEYCIQCQPGvm+3dy68iHckDRitgIBhxztBBghqOxBvOgI6ARzgIhAO7QkU3l7EXYOXitbv0fnfzBBgLbDBbpwoZqtkMCep+8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdhhyCRA9TVsSAnZWagAAVmIP/RU0I0XBwseTaAMaQGSM\nVbhj77KF5V33ybueh7V8jnLYi/0t5hmrQooW4GWqxxhnyoCIyjDAn8il+b55\ngijRzIuMl2j6JymGBGOFMY/5DDsgzWhHP1QkH62FjGKfsT7GDx+lb3m+J7O8\nLckrwlPpWwobUJ8DKQZuX1DpVWYnkBQ6oH2eV3lWJ4CsjNKgVbW2n762mjWN\noTX2Q8J64tx2mmc+x1ZjQRWzgKt5xjIu+2U7siG8xjDoPqclfWfKPqQL8yGx\nmfE9tx0eNp/ezjanlz7Qi07eS/V1KzScCdtJknKMwhsZLRrADLfrhj/L4OQc\nA9S9lfj+ENy4+3KLw9pkoBtgW7c8zBma9/RU2wPz2c1NAvc4hSG/0jKu3EYQ\nEWJ4MngDBC86h55hmEvoMeCEWWc0NVbNnnP7qgqrhSLW5kvGD5MiAKMF9FU6\nzE5H9ZajOoIM2A6HqlqCCUuVQRYAFFXUh/JKa3Fq631J63p+N8pF92LnZYSd\nKRqzuh64ecIsm3iI+ECe9WAbAs5pFaRjqu6UFh07W5/sbbRf+T1u1bObsAtZ\nO/OBDFwB3t5VK7UowUh8jAPSAOY75uhjngr/iuEpNdRqB75sWaZIXGxSs8Xv\nsEdK8qntwag7YzCOOdVHwOtyhdMyJ/Sq3ci2QaGF6VJax4ohRtqtaBysojOc\nHrY+\r\n=lIBz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-2244745-1618352161584_1618352242236_0.3343262973998655","host":"s3://npm-registry-packages"}},"1.1.0-canary-8b6a3c9-1618438570775":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8b6a3c9-1618438570775","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8b6a3c9-1618438570775","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e1c9e2af90f4f83a19c7e75c3241c91da630762d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8b6a3c9-1618438570775.tgz","fileCount":7,"integrity":"sha512-0TbHY6xzETKao2RYmmlic1MQ3WJPq2WnkqglLPEk5YagQXJ1nHZSRfbmpt2Ow2677u3InEFMaW7IDzoHTHg/Sw==","signatures":[{"sig":"MEQCIEHhRymnIMtOhJrzhhxmkqO8l+0nyUUDTcFB10OBP+FdAiA8NeeaC/1UQscja/0ZZ4vJE0XBL6Hsc2HTtxNR2ZwTIA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgd2nWCRA9TVsSAnZWagAAwJIQAIbQk2iraaYco/Rllk7O\nIMi7BvfZDD9yzxHwHUoubgVKMOC6aVbsimRLuqYDqQ/hXjqOuz2ToviPk14g\n5cerKS+k/fv5C0SztPPaO55A6rRXqCDi+fURNUk5/9zIZhfIt4duoy4fLvgF\nHr0n7c9hyClbrAtk39agSI7E2VZXd5fI9nilkuIuBKaGLT9Ks92176vfmM0b\nZrykUnDCySXcSsZ4w/4OOTr1M1xykvG2T1iMIB3zbcdAXNjZrytk+1+FPD+n\nIKX9uHTa4jbAKS6rZRInSS8o5DL+ykgiPAzf1CiagRtbYch9KVyeMEXWeMGu\nV3NEJO1A5I+iszGRlN2zbh2wmbQ58Lxuft69ScO0aJWXxoVlLQkbcTHIUFw9\nKsAzg+9tiuA0dEy/oiknCcvkbV6coEglb2x8/JC73aYaTF8hyDaXRftw7eLR\nDLMlb+cr3B1Yl90bAdRswo/wTHYFgoxkquXhwcEonobgghWrgj4+tMlQrX4G\nG+krNp0j36HOhnsjjdmhFz7UphjheqrL3NEVhRkQvhKsg+3XMwlf4XTKbnYW\nI/nywdBcu0bLtLa0NEZJt8KuzUjPHmi9JWVthSpqi/Y5SYMHpFT0Xdd2CT2V\nR0ibE6TAYapxyorLYtY87vzSZ+hpvBH/cSV39o4NGJ1XlKTUnzZuOWyfBaR/\nYgUJ\r\n=2DBZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8b6a3c9-1618438570775_1618438614356_0.6394505447752874","host":"s3://npm-registry-packages"}},"1.1.0-canary-43e64cd-1618524862711":{"name":"@iadvize-oss/store","version":"1.1.0-canary-43e64cd-1618524862711","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-43e64cd-1618524862711","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e4a244ea0a5cf241d851ac1f42de24d3acfabdad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-43e64cd-1618524862711.tgz","fileCount":7,"integrity":"sha512-mEbh4wOmdZd7IWU0zFt/O8DEnL/Sy1uW+D5LZRzxsfjHm8SDHJdvgif3NUodw3JCVi8UXiQ+oBevZtpiO9zYlQ==","signatures":[{"sig":"MEUCIHqFxZXQMKdXDai+8MDBI1kNwko1I1M2gUQks0BMixpRAiEApU7+yKSI4t/9d1va/XHHrn9sNGBMMbU3fkXD0Jc3cqs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeLrsCRA9TVsSAnZWagAAXrQP/0bwSiVFnCGJbDE2uun0\njVsmgPYWuJdEyG9bg9jk8IGFM88xivSG1okHbWm3GzHkZd/Z8saDEBPitLui\nG/wKv8Foo7vXiktYYgxZ4M4aYVHsb8rI2bBmj5cqAeVckKQENaGVsHVUCF7y\nlXs50zcmncaV3By/5trmFItTCI+FQtUSZP0rE1jQlRMy050Cf2gFXXEMXoYc\ntA9DXQuTF3UOGOKmiGLg6D/w+W/igB3kor/2k4vAfxhjWPOgNhZES2ZbxN8U\naKFfcHM8zG//yDLoc7y9X2F9uz7TPbpVHQjQMhg/XFlHD6dnl0CFjCXPV4a0\nQbMlAvm3DN+vDaGlP5Z27fXmCCOEmm4LiwArEvuwBgCb3u6c3lOa1sSIXw4M\n62zCsNc9IycldkWp79C4DoH7QjuqMJNU1nQz1LQ4s5VLi6BYFOhybDCPgq1w\nvCrrtvoapGQU3SFQtAZHc6VqT75qPVgs+Hm/MjA+f1R12INbVd4/II89nG4S\ngfPWwxLmGQ1awKApAE3NrK6lC//X6bNs9JqdLtEZlyd+QvYHjyqWF3PGgi6y\n0wSjMYg01Q82XRmMCXL0lIe4b1et25O3cYkCWDwmx4cszWBXJKcR8lFGRnhO\n8658ha2bAUCzHvO1xN2hm080/IlaC2/SoGljLY7s4qN3c+4uHYpu+8ApVElv\nmkNG\r\n=c6ef\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-43e64cd-1618524862711_1618524907816_0.8428001564480228","host":"s3://npm-registry-packages"}},"1.1.0-canary-f44badc-1618784025354":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f44badc-1618784025354","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f44badc-1618784025354","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"57654bc264cb88d99ae5f4b290fcf8970e9ca0bf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f44badc-1618784025354.tgz","fileCount":7,"integrity":"sha512-qsPhDKBIEb30lVZSFADO9rnCQTjr909oESKvoeSsXb+i9zBzmrLBg89mp1yKoCSnIloRPJJ3FLNDr5EQr9u/wQ==","signatures":[{"sig":"MEQCID7npD8ZnK74XcJcVYBFdaWCMajjgLWqHCu2UQIn5OU9AiBqaL6iP1G+I7mQri95L2VPKruxin3FznEyMEoCpFm62A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfK9PCRA9TVsSAnZWagAAY6UQAIoQYYq+8zO75epGEAQW\nIDDAmSU0ha65CIv6/1oqnNn65IdY3aUHq78kXifU3v8kwdC3uGJZzpjCcr1i\nXTWvvo5ihwfXKCGfK7dlryI4F4Mu743EbpW1IZADwy93OWjtdbOniZEbQvBK\nPM0o+EuzuCbLj4NuflsvgghTF8WBdDe5UQtx6yem3ziFkDb3eXrMJgh6p3TP\n3RCStVGZ+dtsqx0vIYKKLap+t/pseBGqrJzwhxlvLehzb0fHtXaouSGmqyJc\nau6vECp1XpJjje5XtwTcxhDGOyAwfSYLVGzowQmx3F2Hk7tJrf++XKZMHTRS\ngGXliHFTzEC3VHifWTKkmuK1ehyCdOtfurLBqCk9pUJTG/tcJx2AEQuO6s/v\novdJ6hqw07k8YeFoUptL1O8SFaOQDGUWqbvnaKnxUJHKSUDASplO4SPrlBk3\nJk6VuEE7Zoc7qDJRymJf3xBilD6SugPi/VhfciwEd3bw17m39qk47AW0/KUD\nK+L2cgYzHEekiA+DnE+BZgb7iM87yxmCNfPpsudDg7CcbAhXPF/a8zgFHoHw\npCDgGV8jBzAxD1B5l/K2A6fZs6pZugPdkIGu2wfeEOLlBT1HY7C26xryLt3n\nsoLgh2c0KueuLEFZDKcz+ngN5EGwi+ZM4uEshHSL19YnoPmS6pc4I0EFhNLt\nKIUs\r\n=tqJT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f44badc-1618784025354_1618784078706_0.2967608567136206","host":"s3://npm-registry-packages"}},"1.1.0-canary-8e37ddd-1619122888360":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8e37ddd-1619122888360","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8e37ddd-1619122888360","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cf15568b2e2ad9dd2e290535c5b475fd7674b41d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8e37ddd-1619122888360.tgz","fileCount":7,"integrity":"sha512-/lpPjqhm0D+li6U3juMdQxNSv8nZI02CNdn38E4LkEfVPylakKKrwx2bpGJkg5RrWlCM5s8NonLxM5uAUw2HLw==","signatures":[{"sig":"MEQCIE45A1cErZxFngpxMTXlgpW5JF7DcaZfnCwpHjtbgmPsAiBvGFWwImhtCPR/b8apOAz70XxkyZ/8ZqfSrwi/v6CX0Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggdr4CRA9TVsSAnZWagAA9xIP/RqFD1LGFnIts88l3Mxz\nBxpwy+hWuBA0DhG/ZfXXOpAjnPY+jmZvU7Ujz6aKjZ2lOKIbSSulpzu98ENc\nWxSRkIm+vK8ki+g9CiUxc4Z+nzoaEeWmF5kp40sUTzr2IGXq0ivHj+8vc6MI\nYxKu/QpWe+ahVLmBznS3ELUX4WeOSidPG+OuWI5eVlOLZpVM8fsP297nuKix\nwNpH/iO7btcjyA25Clp1ONIoL5sK779EN3yY8jE/tx7p81yocpzo6LLC3srs\nZhQ2V54pTy+GkL+R7BGJtjg/bJPBSJ91vbZ3o82ofa/KjzRNYjPLBAuzfoGd\ngVQDHMH+7fya2uolMC0v9l7mvaz+Ov0HCJQzP+SLPb6GEhkcD5aIb/WXGlgx\nOv8DIkk/DRmsMCGJd2Y65oCuEn+6wkFSAXY01NnTN7NxleJo2z3Qac2FfMUx\nT9EIGbCVb+ipAn+7ZXvO49XQ31fgKgaoHVAQp+8aXkFT127HArh1pcPMhXUS\nSdiwoSkwTElDmBfBYxy1DWJxgfM1e2Orevyyg62l9U5rJKmMNur4ieohIBdB\nTzFR/4pExoUrmgoAPDLpj/L8R7DU2lmgsRaYS5qEDWhoJhYiU9XJz8+7wnFf\nXuSdtMI1/WiX0JJ57+FVDdPw1/jJ2IielU9jS+SxIgOy3dJ3F8Y8n9uweWCe\nlTyk\r\n=ngSZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8e37ddd-1619122888360_1619122935573_0.10342132307687146","host":"s3://npm-registry-packages"}},"1.1.0-canary-f69cb96-1619129641478":{"name":"@iadvize-oss/store","version":"1.1.0-canary-f69cb96-1619129641478","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-f69cb96-1619129641478","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a3de4bc140b55edbd21c61cd2d72d1e58b7bc7ce","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-f69cb96-1619129641478.tgz","fileCount":7,"integrity":"sha512-6L1I89XtwMjO763u5pYgQ1mPqwdcOynUfIZh+urv545A8IWKqUd1XZK9LhOH989hTkaKT4Rp4uLjbfNtC4c2Sw==","signatures":[{"sig":"MEYCIQDeyRQ08EITl4SeVVmxodD1cNahzlPjloUr0qztUoi/wAIhAJN7LGZ+OcXRxbH5tTUYWdCDr/U8fUb6vuVhW2QB4++Y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggfVsCRA9TVsSAnZWagAAhTgP+gIHGeSj5VTlqENM+t1X\nJZ/21kQeB2k9tb4BE8TxgygPOeE/yhwyhONlv0TqLBGhrJwf6yaw7rVRaLTe\n2ejjhhFNQTQCCaFLOk23ZWBGeIoiax+VuVX2bvSrfcTaM6PtXi0jOkEWdeYC\nj9+eFnsKSc29A2E8gfsewCEg9DY2nqqVchTKNm4xU1gzy0c9k4Is4JbeOO7q\nbjim+0JKd0ciVyH1navfnfaQNdxyR2TmhvSiEePjiHEZaq5FUKH1LYaTCV2N\nmEGWP5eDSKubcK2BQOGCDzbHAzWO/VZfsEqnSn8G86LAMpuyAwQK5ITdRAVs\nfwF2r+cw/Wg+gziAiSM6AWMjOfIX7WyF4eJ2VEEscbtK+MSorbdre/pETVPU\nOBELyJiTqL/DSnxydJJY6nDBk0VrnjCbTM+Fa+XXrQhJWXXpvjdIp5o4gfxX\njXjcSH16eWj01bIBsWQEJyynbmQt7rA6qScJx81wIEPrntGS/6aPjfWosr5U\nZIQvfu0C0WMWVRI+eDANULd0KJg4bvNFxS7t+if8cNh7IJx1Dg+EprvF1iZb\nsmEr0oDcpzOcWM1s7lRFC5rZKmMnqTfSd22+1Dp885sDYKAGj+/gcNoDMjc5\nDxDGf0Y98gNxrRkVuIRz2iA3GzjUqL4Vtj170xyDfFHwJOFoEhDl788kOw9n\nnP8Z\r\n=8uD/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.35","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-f69cb96-1619129641478_1619129705797_0.899518352420545","host":"s3://npm-registry-packages"}},"1.1.0-canary-bb9f2a8-1619146228005":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bb9f2a8-1619146228005","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bb9f2a8-1619146228005","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e4f12f1657999e4fc109d2b30cee5ba5ec3ef0e9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bb9f2a8-1619146228005.tgz","fileCount":7,"integrity":"sha512-eHK7vry+QKKLJUYjqIgvj1a/VPbparfu1fEOfJMX+4WEFkBLHjPC6kMF44McvP8uUmE8QCeJz4F1eKL8x1CRug==","signatures":[{"sig":"MEUCIHTyplr9p7ZUX9TbhfWS3t6p5Pm7c64UAnF113NomuvzAiEAnM4mDldf8V4IwYrqkUCgWRXxDV/RxUfqGYjWeSTPO1g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggjYgCRA9TVsSAnZWagAAgBIP/1lh6YTzLwodoLxRpbQa\noTuMQTLaNuAAgQjjgOdARpWjvnGpe4214fiQswvodYVzmcb/W7lgbFAubQoa\nJly4xg87y7DZ6I0hutSE/w8FodQ+MMK6maTSCOsiWez/xJgaaffx6jWwTyVw\ni9JrgGnE2IAzDjc+A0A0HYHdr9ntANdht6kInEcYzy5599QUO3lIw8SC4tK7\nCVDubq+doAtMNVSKUXXGGODjCmFr8QjhbzsB1EKYBvYJrBeWriQnv3f3UlQg\n62eWgDBTNq0ku27TcWONEjHRKSPwjiuViv6KQ9vaQSfwXZcijBSH40GJ1Ehi\nQPkaNjKxGUDrgEJE9Ep+QWno2ZCxiEHIelAHeGiqJ0zr3xWMz0EAVO/IqNgA\nGJPgBHCvyGCkZaPg8j5Kb7wcNQve+L0mjTWjXFXWOtGaI7vW62MVFIJbiE+k\nUrsl2z6+BIwRNrGtSMv1KuzekBoZen1+gntOhAfQ6zNVsAej0QL6usxAxXgn\nArccAf6oxsF853AeP+VqQAGyNhnYlRCsj6bDj6Wu5W/tmJhfxlsoiLNhnE2X\nLbYHLVe9doxone+IZ42K2HGb4q+j9nH/4vuCxPhAhSPFxzWz6U7eMuxnkkl+\n5TR8Cs0krEGh28hU9aCtlqcls8rfvDflt3Bq9IK99RDIQqmWJrpkFVDxPrqf\nAUC8\r\n=EO6q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bb9f2a8-1619146228005_1619146271442_0.7886007230695882","host":"s3://npm-registry-packages"}},"1.1.0-canary-bb9f2a8-1619146233977":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bb9f2a8-1619146233977","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bb9f2a8-1619146233977","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3f30bca26b3718ca25d2e20eb4fee75bb7db0d26","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bb9f2a8-1619146233977.tgz","fileCount":7,"integrity":"sha512-p1UQLvsLXCRnDdSldbrE7jGQqxXqH6UBJ8iZeFrc+AYiLeu7Rj2jtdN/Es0f0KwQ3+IvrFb5NMnt836PVUP7sg==","signatures":[{"sig":"MEYCIQDiL970SJdGJYCkrvZFSlTIXULmED49PfSl4e4a+k0xkwIhAJ1Cnn1gAwniI0ZTOyCb3e7MXW8Lr1D6Ymvox4mLnxkA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggjY2CRA9TVsSAnZWagAANeIP/Ra42PhGAV3yfjEfVzrv\n9L0iRF5R5M1zjzigm89tJ1vOVn4gPbVYBZpcSEafs/rGrIM/G09O226l684E\nXeaTvq8sKThUBYmbacFWi4PSPWZ/vZfsDzbm/a5iU6WHEkZsOAI6sOuEuptk\njhZ2p1MQB+OjwW7AkQi+KjtsWl7WwTHnT5c+vlj/0NXALnnCsf0sPGSIxi5t\nwY/b6O/WDI/fWaKZe1injcKFHh+tFVArzV9RA7JEJ0dyxCzAwoRp4kmixOHj\nRTO8WHf9oDxtBp9Hcu0qU2aqlrmlykgk7iSvpnkWVt/ok6qx69Z8JSNlwl7u\nxpzdU1WvoLhMdsANu/99VTkqt4+r3+gelXLU3cb8uSSFJP6Bzlnte6GMd4S8\ncPSAs5U+EC7Dj6porIwlGhZ7rjzPO2BjMOMtZdbjAC67mvnlCyY9UarNIOU2\nX8/xZxbLy9wysZEW2NPKFnxxQN687iG7gCXKLQPOTc8wb1LJBn11RHKNY3ts\nN8DEQbvGxYzVQ7Tyy1f8qMq5n5lNNHWMZRj7OBosNMePpWd41hpENthBFVbw\nCkiYPF4gIo7xVRFRTh8De43K+2oTpirXhXLGuBJzokp0poF857+91EdJF2aP\nVciobac4NVlmtthV9UZFpeUGSbsI4dSDBq4LFtO/K6M+o1oVPew4ynLKkD6B\nXPKL\r\n=x6gV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bb9f2a8-1619146233977_1619146293892_0.18718224256834493","host":"s3://npm-registry-packages"}},"1.1.0-canary-1d54d8f-1619164071224":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1d54d8f-1619164071224","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1d54d8f-1619164071224","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6c676dbee600e9a0c4afea34ebce24b5c9125a8a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1d54d8f-1619164071224.tgz","fileCount":7,"integrity":"sha512-uIWH8nSmrv8dkqGRHCHJKzBy9fGA6vEGEfSzChFh2pZM71UNNWVF8lynqRyMaTFCuvzf44dwPujKI6YLFA/png==","signatures":[{"sig":"MEUCIQCjjyR6YvdSu9JbdhaIHPZAsXgQFqTHJu1vdMsYZhXbXQIgA6llQwgDsrNRQm1xbO8I3TQCKpCK+aPEywtz5a/+jic=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggnvYCRA9TVsSAnZWagAAsbsP/19w57mLysoqzy++n7xy\nTMReaPTR5e4wFV49y8oF7eMM9oR2d5gDeH0XHV1REuJX7wPjL/kp9mBpNQ1K\nYu2Eq5JtyeBV2uhCbC/Q3B2disauYaX1/kjZm9GXoGA1UvvGnopy3TKa/l/I\no7QjPXolMGrRhaB08otlAtV4oNH0Pv+z1c+9daRy+Xe4S92RH+h2tF8qg0kB\nhSIbBSxvh9ohWO0YIsjYQxaxssze78arV0tOl8H4r94xqC5WIrwOntzX7m4J\ntO5l9zx58qKXA6VDMRVGwMxicShkmC0RVHQgq3DXafjDSUu5ci84Jd1qD5S0\n1/GuxM0ZvuzX3wNzxHMzq9XU55Wz0VdX/jvysK5QiuJ/FyQFXyrbRhM+HJHV\nnaVZjCog8nTwr++w497bdpeclzTtxAJ47M47BHd92RN940TjzmjAEa8XENjp\ncNchh+bo2wyKWX9YIlPxuvGF0bt98L2Guz3EB2S9QMfV9Nf/zVGhy31Iokps\nTeF53nPQkM+FqFv9+Hb+aRP0T3McH0/+N6Sf1UULsCK81zFpHlALgtEjENo2\nAdF+LRdwCLz7xUOdgTXDxvrEU4HflgP+CVGnAI3xtzqG/JP3r8teykHT3fTu\n6/nmlxWX7uQCTv0qQX1RfbEN9v6qN8UzuQM0a6RKvyeWZu70gyRqcmx0xST1\n20yZ\r\n=VR2T\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1d54d8f-1619164071224_1619164119455_0.6729889021516273","host":"s3://npm-registry-packages"}},"1.1.0-canary-62023b8-1619218135049":{"name":"@iadvize-oss/store","version":"1.1.0-canary-62023b8-1619218135049","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-62023b8-1619218135049","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b0f7315ea14b2ba739935ecea8c3a2837dffff62","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-62023b8-1619218135049.tgz","fileCount":7,"integrity":"sha512-irqet20G9seoPg17umnBsMs3lJ+Lz+H2Um98gJH68VXLIELijWKL4onWh9eh4xMHH+//mev809XKfsBnbz42mg==","signatures":[{"sig":"MEQCIBGp/Qm05tMALib3G6QivLXLlIPC9Jz62gR7EsHcYQmYAiB2CDeks4oWPnltBfITueaKtAlrVtGihroSqjgG4AEPvQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgg08HCRA9TVsSAnZWagAAiZcQAJ1wXXZAZzw8JxcMZUj/\nygTv74SrMbxRzihNU/8Q859tOpz5ssye7xeGdIx6A/0+bgM1uCyS7gRnkNev\nPeZfcIcNipXs+awJzyGsrJVnGcwM5iZZ+rfMRxHj+h3MDsDFtqEHF3Cc4sxg\nm21OIzRA9N18gkvA/MykAR6G8nBrxW3UK8QH+DgnZBe4HTRdumRvIGF+7sz5\nEP7JS2NFb8ZaELtNMRNwObsCUIXEY+s8+RaByci48m4TAXT5tnICCkfwM9RF\nx7Osi45tMV3SbgMfw9PU2C5oBAQXEww/rGW1ajm/DFnRESxrWtrZ7zOoRGih\n2eIkKZM4Jy9Ps58lLU2iejoXt+YyfCvgQ5XH1jxrm7koKhvQVhgDupfRM/IN\nZUipjXPjoiPI30bzXG2lcuT+E6gSvn+i8GkNJwB1iM57XgviNIoYNA7ntaRY\nKVf8pd/7zP9I0evdbE0r9ytgqH3kbtIeHOccom6AJuLmefPCohzseAhpI5wj\nM4geHGuTcXey7+yToWihjuWxq4vodChhjani7r3ZpWOeH6KZFHRoZOqsnM+B\nR75eJN4nJqdT7OlNZDlOy9oN1loSVVTVi1nCz7dMO4sxo4p6giZk+XeXnM5j\nsQnYg/EXdbh4joanij2woDykulkT82DEVRK1PmQEuoHC2pokh1FmjoBaDV1W\nIwvJ\r\n=qMsC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-62023b8-1619218135049_1619218182479_0.9008629617440194","host":"s3://npm-registry-packages"}},"1.1.0-canary-9c02e36-1619392987083":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9c02e36-1619392987083","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9c02e36-1619392987083","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e6b4bf85bbe6e9438d85a5fe39e5a3f744eb5a0a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9c02e36-1619392987083.tgz","fileCount":7,"integrity":"sha512-wIRX2QlUdolLnBz8C9MXENDImv2Lyrqlko8T937Edew2KccpKmO7n0+cU37qh+jU/Jf0beNVEVrmVkbLUgaMbA==","signatures":[{"sig":"MEUCIQDtFyVtJiupk+pt2mp+2jA7h+6BA3J22VdsexC1ULCbLwIgWvjoXg/jVyIswsuHfUgREOlqzkKic2ly9gf7PImPp68=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghfoJCRA9TVsSAnZWagAAB7AP/jpdE4e3Rz5XoDwgSwId\n2tgQHSXrn+/Xhmzw3bfOsDp6oDmYC/9LPzg6SBnqVHXS6Iv/tAQNVF6ZcU7w\nf1rKgww75tGTGTgpetUbeZ2BXS+tO53yElTTWb2L6rEh4FHB3txgye9i3zCp\nPnHogIId0UfZ6hSTCgmewkL3/txDBOauRxO1lCDt9u+b7GcJc3MXNNcTvwbr\nLkwLMrDyiA7l0Za3VCfKIP9IYlSaKHO0btnbTp5sts77uNSLJErENls7h/h/\nnA9gZAXoaFSPVtr/L/6/7S7CHeVEiXAq6lrtKXLlSw7wYQ1ZDd36MPz/bEr+\n9FIUHkK84GoN2FxWjb7dgCWAA2QgqFblFaUqCrVt/UZVMksub5+UxBXlxkpe\naOOF6gET5kSRzV1/ErMgq8LCUQ4AqbWB67lbuG6q/am8NgemzPx2w7h8lW/j\nG/WiBnlgt2Htecjm9I0laylV5oHThyBfkdQSGXn1fo2jHVwt2TvbSejHh513\nJJa6PdqBix0JM67WPubL9LiKD1ErZaSbhotPdTtJn87d78hMSklOFTDkj1YF\nG/s+7EFS12g37h7a8sXux/RQGIgY19/SLrh55SeVxjdAxT28cGT6TVEyJplY\nYtCARkVqLnV0c+eeDoreDvfOWQboZsl81QKABrsI57Q+LcKBpwxaNlbIHfJj\nLDGd\r\n=EXka\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9c02e36-1619392987083_1619393032908_0.7632261070705111","host":"s3://npm-registry-packages"}},"1.1.0-canary-dac043b-1619552677205":{"name":"@iadvize-oss/store","version":"1.1.0-canary-dac043b-1619552677205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-dac043b-1619552677205","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0cada2c365789e9ae8a4db5b24ab1fa9900f4d15","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-dac043b-1619552677205.tgz","fileCount":7,"integrity":"sha512-erf/rs6T0LYXK7fJLNOIYD+WSo39gvla4VglHa0tIFQULDF+VzVHpNmfKOaQnng2SqWG5XjGptF4uhuRb7fjvg==","signatures":[{"sig":"MEYCIQCN64JwZR9xHIoHS8G38tKssZQuHksf9xm1V4GjJIfgzwIhAJqFQZzTy2ouTnAQIz++4SHl80Vb1wDJbGfC5/SlrGuS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgiGnaCRA9TVsSAnZWagAAioEQAI9ZMCnvrioUNXLzDWsu\n/eZP2j+wiSKfPumG7lnAaX5rmrp2QnhIOaaoqsgZgtoq1gHNF/dgW1vkrvCy\nTNe0tN4uy1k++W66Z3MLH8I3nXyzu+5AhdCrYK7mxtj+S53vGnuOFUTrZwkg\n/fyxg7fXITxaj9HvwrEv9Xck5GsmC8uKs4i6wjztmwkYAb5hSzHi/jKbnASM\nnfaDs0eH/0ohhsBiYx9f3Um7qIdeDf1NqTdUvZL9C13hzfzoGaojnRUTsdSa\naM9CqZBGffvGBKvzq9qgnzWIsgjO2W3jqBRn8pr/Rs7YA8X602yunmIo4sKe\nUGh9QnUGRljAHY3lD8pMWDfBsVBoD4U5XgxhD5x5fzv7O3kXW4E1gjjm+311\nh0NbLU+0rQBVt5XMlB2hPK6SSf1PoT4vXT1NL9dDYPksPhp+c7zKNsMdhDum\n1SWS38qI9wRzZ4SGBpRIWKzp/4u1bwC4rZKLgDsSY7BhKzkgz9RdYfZKnvwt\nk7+OcaNm+odi0MGVGrSQ5P8PnhltLtaEcGrMxaUWWL6SxflkmbylMGSZu4/1\nhvUpdfmLWq9BfnxR7WKsyFQjn3Pkyw/OOkfPU7FS3pinP0yTV72Lg7tmut6N\nTE+EXP+8+civ/A02L8crq5zkxKMIXc78ggeg64VablvKIzGb8Xac/pwHwpb0\nRsLk\r\n=ykWp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-dac043b-1619552677205_1619552730059_0.7504978305833074","host":"s3://npm-registry-packages"}},"1.1.0-canary-dac043b-1619552675331":{"name":"@iadvize-oss/store","version":"1.1.0-canary-dac043b-1619552675331","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-dac043b-1619552675331","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"faebaf4d0bb391dfaf5bc3877741b2ac4c4e417d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-dac043b-1619552675331.tgz","fileCount":7,"integrity":"sha512-Qexgxbjh+ilJINnlL1BJxvtm2K2YdU+nfERkalyDhVcxScWN5zb3Oz+qptPmhuwu+h0fYvtPxI28J+SjLTjm1w==","signatures":[{"sig":"MEYCIQDUM7jRS5Xw2v64Y/ItEtUlmkYdwo7g7KJr0Q+4xUgh9wIhAJxttwFR3xi/fut26/mwRNytPhpMnF8nKnfC97j1RAAe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgiGnjCRA9TVsSAnZWagAASksP/R1qyrDroBc7HjuhwUTe\nyZaB+hbRgfwsu3TiM4FPm79+YEWV3XvJEd/X4GZlkJqUz5OWm/2ICpMd66yg\nAzMzXT0V6vaW9zzU/ViXC4IMZ9OywOJSpDkEguJS/8lvHdA8oJZT3Gse48o3\npoq1ZEwROEKA7Vtn1PTf91RuZF8QHEtTcVZa15IA+C6o3clK7jslrXgGdFAL\nzRR+BV9AlA2e1HHKBmpsXkQVbxevpbiPZzwd4W2Jn2t0v57A6ExCn57mcRlL\nLjkKHbjjsI9zcgm0QIVfOHH8VNCq5UmC7rRwM7r4NsyOH3yRTF+6CN2SPU91\nqjE+HooKcoSQkbuzOxXcCFx9v78t8WdDeEpAZLjOaLS13zKusOzqxPhJ/F8f\n2B6s5CBeMbVEMEcNJhsREo4I6B1WqTTnUzDOvdbBKa/YfcY0EVXKWnqEAk0z\nx/JLPPxN+t+nHZ2NDexMFqTb9xh3CYPyQXPU9dFdsBM5+kEIG7kGAWS7VaJ8\nf4RyweftCjRU2Uyxm4FrFVsbthmlHQz/jWJfB40U2IBXh4GqD1jzKbY/zen+\nItK7QGowbYbLKhcs6vpnHGUVsOVwrAUxVFAK3ln64bC1UmISZz9DJi9bYyQ+\nz5AaY7ygUqiuB3e7ENwsCHWhk7Ae3XhJ4eXlW+lBWrg0G+ACW5suXruzHlYF\npYNk\r\n=FSGP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-dac043b-1619552675331_1619552738853_0.07654183511810086","host":"s3://npm-registry-packages"}},"1.1.0-canary-6e93133-1619674769250":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6e93133-1619674769250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6e93133-1619674769250","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3178d27d84210c19d432ae2180b29d156aaa60d6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6e93133-1619674769250.tgz","fileCount":7,"integrity":"sha512-GRxQPlRsHfmhS+Eqnv7lNtoay+MBtEjNJb22AJjyPM/xgRyPTTcPWLjgjtmG7AfJRO9Bf6vDFhEyEcNB1Pb91w==","signatures":[{"sig":"MEQCIG4TS+G6WlM2NnKdu00o1EBfNJ6UqKlnFMPBWQi5dHRxAiAbt4s+tWrqXafNUF7OUqQ4Z5MEnIf1y+rNM378ClhtfQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgikbKCRA9TVsSAnZWagAAjikP/jvWnMtKdJCk6b+vZJxO\n0LxlaWOh99367/DbaZ38LcWYk3/P1PfWVX83FlHYheg/q1OrHYlhsPaD92km\nAzod49ICkenEvKXP1l+hoqQRsttdclHcCFSPlUcWSdnBa7JTVP8T++mpWWHy\nQG/QoPTpKILhmadYDlBDLVSHm0B+D60V4rpDxn2P93krpV8ND0J4OtG8qr1J\nkL/MHRCT+hUVGLI6pCLkXBlJXM6dIVi2rDJJKRBYLFGmCooD9ELVW3jwonf0\nb2DjS3dOZMvLch044UxU8EdlTCm1QDkqjltB8ijVRYhHdny0TIx0zOY2kkMj\ncEzv8pcV0GlQD9mWSR0HyNTnuy+xzOHxJ7itkv4EXiKU/w9RNr+cyvAqaPDf\nychc0kGYcB1UY0JrGCrxv1psCBNV6hVckC+u+s9zqlrQVWx9anun7rjv3U8n\ntRU3JI2vk5t3p1+jHU1vS3elOTiz/FRHJkfEihjoDLLEyjkZXQ3XFfBeM0rO\n267skNE+ZQmmomOIernTCFMvROJDUvVOjZW5ULAnrI13YwnTtH76SmmtgajP\nBE6g3C9C6b23wEFO0voxStQZK8QDck6NdY8Y6JN2yXoIEXyw/C0lgAaAIY8H\nufgwalw+Fv4fSBcw7oBgRl5kUzFG5bIT6B6gL22Y9zzAzxbQiuRdgGA+YdpD\nCcbX\r\n=Mz44\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.46.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6e93133-1619674769250_1619674825680_0.3860747654019727","host":"s3://npm-registry-packages"}},"1.1.0-canary-44a7887-1619683171224":{"name":"@iadvize-oss/store","version":"1.1.0-canary-44a7887-1619683171224","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-44a7887-1619683171224","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4e175ba6241a8d2d040afaf5d1b1c93e97c40470","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-44a7887-1619683171224.tgz","fileCount":7,"integrity":"sha512-/j1xNBSEh2FwtvsB0ymNl0PINpfhTYevLzZuSa8X48o3L/FLF2W1EwNKr0J56GV4BKm5gJxPVrzsclXP/cNDGw==","signatures":[{"sig":"MEYCIQCzQn6BzTqbylzkHMvMKH7TcnrGpXFmN41xezng98vK2AIhAOdPzam5Tr00RR5qFSFRs4ssJifIx3vxpP0VByR/GbqH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgimeaCRA9TVsSAnZWagAAJCkP/1sl6EgoTGeTVvQTOODT\nRzSRr/8x74/U+sgtyBURD1DJLEV6MkAAfMhF/AeY0bPn5G2gvM8gc5TQJnY4\nTsG70UYSKNKhQyff87YQP2zhnbbUoVFw3xR9029Twz9XZ9ljBRtQkaOSjqSS\nGBoPtJQcHvfr7/Nc7dlUex1ApSsX8/kQkWX3KoTkEeVl5mLJVKkdiGAZvswi\nrpGVG0YLmjexVXM4I7qLcDLCOL9vce9Qecu6fyey506EfYBnKYDuh7G6WgJC\n1IyHYywIW+9yoRCy7gyRK9bhmbI4PFz2Ho8uWC90SpnOLOZrHxHIDIovgzxW\ngpMF1ubwwmQZ/9Bf/tWovXYg9T2sGGcZb7sFY3uISddAf2dvlz7UBzX0vim8\n4W21pFJoQLTfVBLiyvOjBEXS/hZPr+ih6IvYlYGbjASUgiKLfpCFN8pUIN2r\nVrLOtrAcy1DttBrY5FUu7Cck8J8o7m/5ZgwCbKlXzgQhYPj6pqxG2Blby2HH\n+9y42KvbwDpecOM70MveyBO+wTHkc4rApxW8h1x+Gc+sUjtYte6/CYxB7Gb+\n8w8iumkw7nVPbFgTkG8kVW99ZWRn9REWwUanFyKb1FtOnPs5o3aVAlr5acfQ\n27QaGNXnduBr6uWysjuL5HnzrKybh+XrJ8sx4X5rrhf6aBvgXlmfp4bxzg/R\nTMte\r\n=xjHH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.46.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-44a7887-1619683171224_1619683226236_0.41321377293358763","host":"s3://npm-registry-packages"}},"1.1.0-canary-542a692-1620106044529":{"name":"@iadvize-oss/store","version":"1.1.0-canary-542a692-1620106044529","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-542a692-1620106044529","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"47c0ff8941103c96f0e13c719a127afdd3defcbd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-542a692-1620106044529.tgz","fileCount":7,"integrity":"sha512-8qjrvfzxm5o4gE5jFWolN853tD6InsSYy+zaDIu2/F3TwCo0B8nXm8dbkC6qDmkf1iBrDz/Zp+8bji2ya23ZxA==","signatures":[{"sig":"MEYCIQCZz+sWby0+PbuAPsTHFW12UH0m3vjcPmMVMMDECqXyxwIhAKEZdRdQ0pglAT/A1mToH6FE+fXT1xnFAdbo7aNgPsuG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkNtoCRA9TVsSAnZWagAA6hcP/3bJF0UzCul1FaQaXCzW\nneMcPFPxb5SXvM8RCySfcxxVr/O450amYLF7ri2oSnB9KdmK4VCgTwnkZQhU\nTNU1JxcDkWLtZ7nurWBkaLXVTXzYRjHDlZ4mFqxpQ/x+H6wqWSLQBMbb1fMA\n/CxtJJbF2vrZTRjO93VflvcasJ8O983eCuZdxUQmq3wecbAlqXl61atOgkOS\ner9g+G/wLTw8mpkfz3f6+RZg/haCJ61v92JKu/XSrUCy+jDiMjFG1GSYHKTE\n7dcPDq5oHADnVzuafZMKLGRia3VPA0Cf6AXeFgRB4Iin1jJS3rwNAB0RzdLN\nzAAJ7EnlVf/LtMPlU3uy70YTuP8TPnlzzhPPXda69TjtIR0uXJqPebtFYyyY\nEmjNWiRBEZfFWQCzaBMAAP98WiizquFfF00GMGWRYWwR6hrpHD3rswmvpvW5\nHbaMSsnZd49ltH0CkDyS0gqK080aAu7j/IpBOz5SMSbkGNuAbzw7QXiwaUEV\nV/fLS4YxEoFVKjTRe1RYtZbjd1zdcz7o7zBE0WoKaf6rotJ/VOTJ95aqV6Uj\n2OnhRN3NFFeXsNR7UdJidHdACZ3OZxncHi7QpFH4/N5CSIw98zBcO2bZBwz7\nvDLTTMgeah/LarajEX+dvnTKbWm5jXon8u/LgLsRfdDikuxmUOVWGQOK/4Rh\nhzFr\r\n=MPCt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-542a692-1620106044529_1620106087983_0.27614318213496625","host":"s3://npm-registry-packages"}},"1.1.0-canary-542a692-1620106048019":{"name":"@iadvize-oss/store","version":"1.1.0-canary-542a692-1620106048019","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-542a692-1620106048019","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"65a8c8766135c38e149970f01bc3eed3fe9e581d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-542a692-1620106048019.tgz","fileCount":7,"integrity":"sha512-8NjzovF2akJ+F3iBQyWg31/H8k5HiW+3RXryPd858mQUNGRt57PBt++TC2gT9FKX0xL2mrif++uAY/YiiIcakQ==","signatures":[{"sig":"MEQCICpvArKaLwk5qvWkHMmhBSdqdYWofWI1XEM7PiVhmRCEAiB2XhITW5jaI9OoSrAl9c+vzR6G30R6c8A3OdZ/qAPXug==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkNtwCRA9TVsSAnZWagAAvGUP/2YlDEm/Y2ea129M3JAc\n1MOX2yK3580+ioHBwRgZAj3l+MqVRITufKYnVxHnHy19crZeqWBzHIfh8rNQ\naOMRUms9ZrkW+atWewqSJpD2P6QiWOncdQmMSlw++MqmeFVfpOXZWsIZ/63P\npX35xN4xQpQSZsrtcF1Tnxk9YV0j9fBwH8/L4M8sVMj3h6AjAsQukaSQdXZ7\nyRsDT5qPcqNvfd+fGtV1YyW1nh+7jFv+96nRZku6QpuInwNJjKuJCFyj2DjL\nEaR2ivZ3+KGmlazyGot5kcH18+Lq9t34XbZ7+sPuwXVmRq6u7iHVzz0s3Ar4\nqhJ00mMGD4cjTHtT01eByzRq8FQJrU0+rDBBGMo8w5q3eWpVVth78c+ex8m7\naeUH7aJ/u7OSwTIiVmxAm0Gg/1JCuyAutgBblq7cOdz6NYs1Orjdv3DpA1en\nZFxfwMHg150kGIsw+ji15izDfvus4SDxLnqHrGDNzQN8W6nQB8GZBJ6priu2\nevkLC+dXvvGUb+jjeyL4QWL9bcWXDQ0S5faVZ+iU7mwPCBk/nLxF7mwvr6gk\njEj9D89guH/ygfd9nzp4hG1tq2iWyMb6xSRtgztkKlvtavSXDicnUHQ802eM\n33lqpOfUNjIuSaqR5YFf/sEI5/Ffr9aVOf3Ydv+UnRbH3NNtxbrczGfN8NnW\n1j86\r\n=yBPr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-542a692-1620106048019_1620106095719_0.6276944945763092","host":"s3://npm-registry-packages"}},"1.1.0-canary-bea75f5-1620137385745":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bea75f5-1620137385745","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bea75f5-1620137385745","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6662eade81b01483edf6375072b57020bea227e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bea75f5-1620137385745.tgz","fileCount":7,"integrity":"sha512-k18tiQeKRREXp6SPCNCfRW7AozvkJdkS/saHbRtM/Gm6LizUZzrrqfiGaEBMW2qsLnRCvsHSLe1ehocJ7LbTZw==","signatures":[{"sig":"MEUCIQCf87hCItlMi1qNH5wi0p1U3z13J4YVB8YM6a27NN+QYwIgB84veNFHCwbXCg+7tBJjrS2vmDkWMmCzVd8xGqjn7lg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkVX9CRA9TVsSAnZWagAAlFAP/1/5KC1YF31PEhy3YcCo\nz0l+nxiFRNQunrTficz2FaO29P8l/9AaUX72iqzfAvEyva9UXfgtIryhWFwV\n0IaYQTv3nDHe+qC36/NpHZ0n0q4uS8QwxLqrJF4qboesDSfbGDflUrQakfsX\nPcuRI0WrmqsPa5bOB5Q4Rwd+TtKOD6v6s5DTug7t/nnAZ0tDWcpFCZldIuvz\nyZln1yJOk06FO3b2hjBCeTfZHle9aq5aqKtBZJwYGGVrAcidOq3PwCckVn+p\n3uHvlZ/DUL2RD2Y1OJzK+urTs65zlga9O+VKuCLgTi/vijk4T6WFDo/NjeV8\nRBwhdmrFKWI4R6XuaIa3kU9f31VJUc01SmZ7Jy/yoWsEzPj4KehjB2WSfGyX\nQGslosMhixykDMrYm3x/x57MAbegdFgIcGwy7BZqjoH+uoK/P8opAwasG+C6\nRgYV0OrCxB3FyZDo8BBun2965LQF0XLjQfOuLQWAHBueO+zLUJlqw+4MDiuW\n+jCkoMZbK/8PyMKQl301WQ0dCneXBA+ZpJ2EhPjx2ZbjxwEbxjucCHI768n5\ntR7CigsAB2IpTujakRc6keHR84BBvvZFd026gGioqU6Z+rsqqSPvhalEmcfx\n5F/W4MZyqAymYqaDl+L7LKP8VTnpAAkldzG2bv61MKz36igCdqveSB4YINj6\n9ddY\r\n=3Iw/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bea75f5-1620137385745_1620137469131_0.8752120044024847","host":"s3://npm-registry-packages"}},"1.1.0-canary-bea75f5-1620137385828":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bea75f5-1620137385828","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bea75f5-1620137385828","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f5b29ce4b69c9629ee0585c4ea06723ba767923d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bea75f5-1620137385828.tgz","fileCount":7,"integrity":"sha512-9r3LspNW3luCNw+HZuYjolRYFckQwjLrYWPjQXB/Zr3nO8ZHvATvMNFXgV2+DxRqdLhozlztZQcIWaKBfe7wlg==","signatures":[{"sig":"MEUCIQDvVrU4zt0ATEOZyeOQH8mscd+yQGx5juhiwEv/cGpUHAIgZSCS2qUX6BxiVMwjFSIAQs4GTK/SRfvspJ3lmkyNET4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkVYdCRA9TVsSAnZWagAA5ysP/3056WxD1vFwuW4T0hIo\nCU7cuEMhvXTY94s+NKu+xKSDYcECOV/Zq4GJmDZiihWLs3soxt1cxO2byxbX\nsiOUALW2bLipv/W0UYLwv2BHL5FdIsQVyDrEhqNAQmS3wiZkOfn7E/Revei0\ngsIebz7QIckQOlVzwx4teFAVpZbWNmsL5yfZslIImuL+7GlRuHpXhA/JFYxB\nZ3yjnfHvG46y1XHKTvWpUWYpULvKnUW/4rqj2TQpsVNrW279Vry/aLOjl9y9\nXWFhhn+jkGkGrKfIeiH7NkuRDTPqXt70/GlfaJW3nzMSpCDYF11m0uF/8XGB\nfWb7ekvzS1woXwUfyt8wg3JHtYwS1+QxzH3sEab9gtrz7nNf8uMabp1Uti02\nfQoCHqRB4yEXo9j/j3VPh5W/5yULmk6drUwmCzK0rE3WOBY9RpJjl6NWdPYU\nDpQxkFq8x/tTB84vvegeLnRInpo8gBY0CaEMho2DlJZ90XffN3n9pdc7nmQ6\nA+redxbT1Ou0OPPl+Kn2aiyM1sc75OfSvLzgi32o7ojMqNYqJB/Y1+ZPG4tl\n9JXNR7oSugmU6TdReIWUy0IiGIpNRX6sakwWdwyJU0hDekzo2XBM2K7oIY1T\nl6x+dkRMudJsDYbdZAQsr8mV+DJ+H9HMnBzJKCGSx33gfI1EpCT7CN51x08r\nLXFI\r\n=aKAv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bea75f5-1620137385828_1620137501132_0.8057743545837406","host":"s3://npm-registry-packages"}},"1.1.0-canary-9e3d2d3-1620166550486":{"name":"@iadvize-oss/store","version":"1.1.0-canary-9e3d2d3-1620166550486","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-9e3d2d3-1620166550486","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fcba4740eadba43383c0b8b148b853d08916daa0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-9e3d2d3-1620166550486.tgz","fileCount":7,"integrity":"sha512-SkY8NoVlE3lADbU4bDaXKz1n4PiAjMr4A1eCHKbdzH49psG9oGyEk3bmeqE8WtfjelCEnUsWhkJEZsyH1Fs0TQ==","signatures":[{"sig":"MEUCIEYBH2k5kdrthyEMVgJcEYmkB8KHa9a6p1yEOJwWKiZnAiEAu8rxpBUnfl7P2T3bXueotwMpFd4OAxcqgp2Hw9y9TfI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkcfHCRA9TVsSAnZWagAAi20P/3CuT+YEDUIEYlVepAlk\ntILEDeIbjwdbioucWmF4DrIMkDhqwQZS/JKPt8XER1GEdsppolHy3GeLQYQz\nHLCy+Qn9SiVx/UL5ZbMuauAsBN3k2D8/gNNi/7Q1GHGsnDgYhQRkQJVE3FOK\nTtsBbmiMsb3DpMZFD01QYtSdnfMzlWRojxvmjnmnRLYSE3XPLT/bMJd2god9\nqkqdWT5NazA/JNMQ+DaXob+eg0jTw1QsT0RFWC/t368vraqFIoet6t1AjqiK\n3r56XiFfEov3yNvcsMjQWxk1KpjW9MlNv/p+kHSz1eH0p3Ucn5yqguP7wlN8\nW7T+WhIvITHlaNGn9TiKtunpH2/n1IBg6ZmzfG0FW/69lS43YMCeiCXASR4E\n7otDkxUQl0zLUxtlPcWX/siso+4PwPVfGoewWlq+T1kGDSCP3VU8Qd/MeOeP\nJqYwt3lAD1noPfUyQgTgX909Crx7gTdh6swWLxZkxcJLlKOSz+ENMRog8D3F\nVshsivU+CH9OPUbpFxYr9+zfFBvWYBVD3Np19crjPilvJDf13V08ygaRBKIv\nJyMwNqfgGwG/7tAafIPzQJ8clbNNVSGOH3lUhFogGaQKrqNrvQiA1qUnQLk9\nQi2AAbRaFyCDS3o/72q2LCzpc7Xhnhhf1MZKk0F1NcMhN0AePd9LVpz+xnVr\n2HM3\r\n=i9Rf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-9e3d2d3-1620166550486_1620166598297_0.2960293054060974","host":"s3://npm-registry-packages"}},"1.1.0-canary-739172b-1620252842400":{"name":"@iadvize-oss/store","version":"1.1.0-canary-739172b-1620252842400","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-739172b-1620252842400","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc156a5fe851cbb01b1177f2769628b8c9f6234c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-739172b-1620252842400.tgz","fileCount":7,"integrity":"sha512-OzwCzcSySbSX2vRw/buwcnkcBCqeKtX/bWJrFZbs3A9FIpN94TuUHYkcMPeP7uTJLMUCct54dKasOd6ExxWvwg==","signatures":[{"sig":"MEUCIQCUaRB53sqz242cZPm3P0c3P4mItv+6qPvAx67214aduAIgN7KQiflNcz7E4lOF0TSJsZJpC4p22/EOoGaRTA+BB7M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkxjbCRA9TVsSAnZWagAAGqgP/j0L2wCK8oD9QyVKVpx+\nOabaJG2w3AzLqqQcoZioSI3D6blQ2ekT6TLPMTB7NKoCvXuBPCsQVOxF+DHt\n05l7hVCLOZzbSNzax0JzPPjdcLVAsznV1DcRm3Gfh/r0i19pcSOCA6IRMAzY\nKVIQjhlMqpLn890BvtTWrTOtZxcgTEzi9gDtZM4Vl0H4bBWZ8/+w2eeF/TJv\nSjlVG++UuOoMscESvXrkouwvXHjNw5YC8j//GSyRh4GFJWEFB+lMtL+s1iPV\nUVXamWOH9bOxhB86p0++1xb/tGcV9/qL9rZQS5Ke5qRhJdknetlLYf86mOn2\nAPWOJ3k1m3S8pw4UJ+8SAjCN+VZ3uQrg6qhvIKbX/j0hZriYlNPMVQPMj97l\nRfYhZQH2ws/ZcXngMfA97YKMMrAM5Hq7LWQFWMTtEpy2639IXct9Vp4dwuvp\nOUyOtsLAaMGr7Z6LqwwbK8rSZQl8QzRcXOcxwIzA0uf5y2DHpF1OrO0Y92Of\no2TqP5rAJogyTTaCKNOu4ctPfBvZK2yF36zpUS8C4Oe76W7CjF9n3LCuANOX\n26rB4Uw1ZtfcLnzNyaRQQrowD6Op70CoSZgkaxT0XFR0BfBUWdQ2uvPHyOs6\ncNSDw5xpjBNuGDoU++rH0+ESY6770xXUfrnLp5HBQ/HG5RC5kzFeQp/G56K9\n+2Fm\r\n=ANJa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^18.1.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-739172b-1620252842400_1620252890567_0.3182941076398611","host":"s3://npm-registry-packages"}},"1.1.0-canary-d9588bf-1620396375462":{"name":"@iadvize-oss/store","version":"1.1.0-canary-d9588bf-1620396375462","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-d9588bf-1620396375462","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a5168c570c219f61df24d677769639d7fef23347","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-d9588bf-1620396375462.tgz","fileCount":7,"integrity":"sha512-2T6yQ4whEFEk/Su0KkI4o48O/TDlTdjNWaobuqaQRKP6jgcMNhxKLh1bnfF18beeCY4k2kS29CzTBbJMm6KXbw==","signatures":[{"sig":"MEUCIBO3jAmEWrlqK5lr8bHv0sGPBcHJjDyM2n2kFZmu/HjkAiEAiIz3os9owlPE0rIvvIxDorQnE/GR7i2aG262KYQABYo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglUmaCRA9TVsSAnZWagAAy8QQAIvdkR7xfrp/td4/utNb\nC7ek8KwxnHdxwyPK8vKQBU3iMpoqUHtWwyXPf3+xC/D/Y2MLknIFBAsigjI1\nXOPL2Llzd79YGRcrmXtvJjFGsFKQovEHQj6wU5LUAM/m9HaF6HKPPZh6JgEa\nHD3O+ckxZ88iZKXTu/EeI1WQZ6gXKHVU1oi35n8PwyL//7dgJCSdBu8kdAFl\nY7a2iWsvVe0SsEicUyUYn5TrwG8iEOG0SRoDen5XINjt9plc0Awth9eGDE9O\n9OgCi5gfvwvvWQkbJSiLyefQUwATdM5MXusbJeX2r8XgRG2jmGQnuVkqjFG6\nU9bFcSzVY+oeDWMvzd29DiUuyqj5nsuf1Lz5x3hQpfshRyu6SbKlGaJ1YaXh\nVp0MbgHJSOjGVk2QU5vSbgyYqa0p0owN3w1kYxLm7bDTi62/Wxk3mzZaeSvV\ng5dybWBt4vDUazKwErF6UU8/hMw5XTOcbfhf1IWNlB0fJVGfjp+C8lsb1Q0F\nWG4radfAqIR6NgweBfiPoTlgK/PbA/9vGcSKeecMOybNZl92EpZHdwYfPnHR\nJG5ud+ob6nQxk/6bfhjaB/be3Eh7uIRYuQwoBCYlX5adnmZB565l6Lgke+Sb\npI1lfgqbb5XXNPw1E55wKjQ1aePzp93Tb6fu6XSCODDBtx4h4Qq9Rr/N1W9a\ntAuy\r\n=jZDR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-d9588bf-1620396375462_1620396442501_0.5466020060812458","host":"s3://npm-registry-packages"}},"1.1.0-canary-11a2d7c-1620399290226":{"name":"@iadvize-oss/store","version":"1.1.0-canary-11a2d7c-1620399290226","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-11a2d7c-1620399290226","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8e53c06150b2f8f289ee29fd2457fc3f650bde52","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-11a2d7c-1620399290226.tgz","fileCount":7,"integrity":"sha512-b9vK8ZyZmkZ8VKgBtJJ5HgDWjhAkyhY35SNVk71KRdLy1uvmC5ZbZH8oy9rw2D55mJlbXxK1yujUzvPoNczBIg==","signatures":[{"sig":"MEQCIG52M6aKcJs7gZVJLB+i5uqMhT73+zZBuBMP0e+gmLKdAiAml73uxcrYUVO13bHeFqVoa9llYz53ovo3gQK/P7KOag==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglVT0CRA9TVsSAnZWagAAGXsP/jT1iVJI0i+j0B7OUi/N\n0VIcUi3deR4yoantOcHHNweTPGggUn9hkf2JJN4D2X4VnBr3IqFcLcYbq/4G\nROU2SAbU3+IBwLhrljHaC8v0dAACibRNu8fxDzMN4jtnKXJ8TdM+iwOHTTlp\ntIZRSk0xDiAc3X9e4mhip1DYnvahbWd6XvN0hEueS0OOmObIP9nN4BBhs97R\nkzAOHyDpq8hEM9Ek/4nHL+I2AaWXc+AbZw6NDzPRbWnjQYf23f5ACtB5HCbN\nelmKOe28qrPCZWvMG5UT2FXhAAWsXLUNa1S2/T5i3LyAV5LDMxBecmPOTkQV\nhui1eW4CjaocGCkqAQ3171bAecz0YB+v5qCQygrP/oVydZvpgc5g4xW7chGs\nqeuDs6frSXko9kJf8tz7TcLylMPo2dCbHG9SSjR/Z70GJrpo1a+9dZV7vtYb\n7tCM41O3XMejKx5uTjK1AqhsolLiRnrWSPpopERAAzWXWSDFIEb2AEKcxi5N\nuH+6UMRC3PMUtbyTK+LPTn5xo7+YxzTsxSQe+WU+nTCNHi/gQ0i5Wkm8+HEj\n2NNmrR2Sx3GbIfVm5R4lQw6hb9iGb6fViLd6LxKfsDTw/pFOPKiYGTAk83g2\nKgwOjNzt+tRAHaQXNewsAMDym2v4oyr7uQpGZJDsI7cbEogNLyVlKYpbE1Rg\n/jXm\r\n=29h4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-11a2d7c-1620399290226_1620399348280_0.8482562831814857","host":"s3://npm-registry-packages"}},"1.1.0-canary-1d872da-1620442292227":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1d872da-1620442292227","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1d872da-1620442292227","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0af6f2e2539b04a46651aa7776bfb4523cde3193","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1d872da-1620442292227.tgz","fileCount":7,"integrity":"sha512-rNUB0K0m8JGM2J8wwl6xWMhyx9chJD4OQAFUtiazmydGvQKYhx33a8SOoHXcVn/fwAbVIDF4wKO1TCVGtiGzgw==","signatures":[{"sig":"MEUCIH4bduOrQnhWc6d5AzdCaB38B0pVTpb3g+3IRi182GmKAiEAlYXEmnm+QAJ7CJ/CXnLomR1EN+vIP6xIXzAXN59C4hE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglfzlCRA9TVsSAnZWagAAnrYP/249G2nC8U0A7EtAOikO\nWYOKlTPPMI/Wvx3cCQyy+gBoKCzy70lKdMIv1UAY5agW/+13INtdgkrJgGWH\nuqu3Ps8quDejDEFiEMw0bxuJv+iIwMPbvl3hwadm5s1eJ0deMlK/+ueEyPre\nN7SiSZcnACnHwzHc/RxjyiaT76Dp0++YC0WOXPn0ImOPJqhTMf/7ifBTMoHe\nnD6BYE/CRPxOgY74uILVlRBJcit/kVT/k0WH7eOnbPipS2pcintSOGxIVh8W\nMMoUUFdU84LC/STmq7XYdpEdcymgw1Dze77FDkWQkJV1E+LhN+mqeCI083eh\nENKhDMLOptTWGSq3RZDLMyHPb74vnAKqd1EtFaoBpqXV3SGoJka4XCSTRy6/\nTaXvD+ysLkwrotzJHwXNX9N6Cr2RGbKV/WAh44xzgP7HX1hxwcipFBFvb8cX\n2ceQQrBOOZ8i5eX1gQiQhtiFOorx6BdbqZRrg0cfrh9ih9o6//2f1fTdhtnq\nMJgpmbw/8EBT5tv/qvGolPSlFTYCw/ZoB+kMZe+6zoNlmrUx4cOpkKY5GDOE\n5CQCydkMEYB+ladEXg0RErP2nIrLSs2pGMOrIyUrRdb6OMomQTb+5eD8PSa0\nGxK/ZS88FNCO7+cfz0t/+z/FjC3h7EOksFu39i9JFBwj0rNQO5F1BF/0ZLT/\nT0H/\r\n=pdBn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.47.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1d872da-1620442292227_1620442341149_0.5097989626437718","host":"s3://npm-registry-packages"}},"1.1.0-canary-91f2951-1620599066954":{"name":"@iadvize-oss/store","version":"1.1.0-canary-91f2951-1620599066954","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-91f2951-1620599066954","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"20d11adcec6ade7b34ca7b6b072fdc6833e0d7c6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-91f2951-1620599066954.tgz","fileCount":7,"integrity":"sha512-pfaz2sO577s1tHK4eBbM2NhKfnej0gKC6pqmSMljiEtHH94WY7vC3uJmw+5pAfaooM73xl1Fdr+2oA5MYNAEoQ==","signatures":[{"sig":"MEUCIEnm71bM4VsS8hRcxdHVmVtdql5VXZzGaPebi2eO7os5AiEA6/nw1mq+HiBeIdBzVHj+/b9RkCn1Du8nojcckqWeYK8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgmGFUCRA9TVsSAnZWagAAw8YP/jT1MtIJxITuAouJ6FXo\nw02We50imXBWaF316oxedFJ17k++rFLoCo6aFEghP/OxT6BRj1tWdMpU/tgX\nHI3r3d8jaWKrxUKG001Mfn/qQRl/1aBqSXNTY++JNPtypuSWteHOKTh642+R\nNa+5gVfhSnk+SP/mPZ1RgnTUSD8mOhoXZjedFsz1D+tDXAfyWd+lYWfG7My7\n37tJzjDm2dj0ecu8oPf6sJ4v7vunLs1qCeigTP+iUaK2kXuB+Dqv+ywMFRTh\nHK7nPUoYSdRmm4MNdyS3XzvX9TFNt7RZtRJRtLOphxB548IcuzXG8X+CeLGd\nMTL4eYSgmW8zMfnb7EtwSUQTSRNUFMrkRwTGyIahS/iMgT0QLbjt4t8IizBB\n1QU54VuD3D8dr4kvuh1tN7a49gQXecoOPZCTRulu2uTJjd3aY40GeRLxOmpH\n8GhVhi8/k9NxUtW6TKjAwEmLxo41mDBqgcSLwK8XeyEdtn43e+a0r9W8zWw3\ncbTSRzp5U6CiBLc8SDxdjbjykn9QWRF5ewXostfeKyVUkKZoeLexO8o/UDRK\nr/SbgeL5iEhNOywN1u4+eDxvVDYx+MmOfzPExJ9PVNFQ/bSP4PAEZsVjNSbQ\nddkGqsvnaxxMGv2YgB15L2j4B1/HikwQ75E9Cfdr7vFqOX+ScSEQ9r7iQwPX\n1sWy\r\n=FNRp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.47.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-91f2951-1620599066954_1620599123685_0.2977279035650089","host":"s3://npm-registry-packages"}},"1.1.0-canary-1a9ef9a-1621054540158":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1a9ef9a-1621054540158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1a9ef9a-1621054540158","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"38a5f0e209c4145a3be0f4516b572da6507bf4b7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1a9ef9a-1621054540158.tgz","fileCount":7,"integrity":"sha512-ZLgeAHhByqkvZHBJRfCpef32xZQeY0Yg3IIYGDAHL0oH5ptwg9fuf81ZCfJKi+RGqaw2Aiu7kFrLOppcQ9NtrA==","signatures":[{"sig":"MEUCID/w/b/RTvjyw98EH2j7oTDECZ8mUf9CA+3cdkrf/MejAiEAha6sihrLUNzlPj5ei8x0E62kh82MbhEKAi5rCv3RZMo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgn1SPCRA9TVsSAnZWagAAkugP/ROLUHmjHsSQ9pipGaD/\n9Ip3TyhEGf1CNDd1c6e+VeeJajr64Kx/qn+uVN4CH0gM1nb6WVH4NuemT9T/\nl0SFWe74WjQCZJ40u/ksYZCaokvcG9VJyG9Ol20Gd39f5qJMoV0Sok5WkHIJ\nSiGp1yQTQW+bPz2jVRXRZVqHjppC72b0MN3/kmvn48c7uFSSMyR5WDtpovHo\naKpfgJ5z7yRGvnTRt6sP5uuLRLWd+WytSXDjhU/zuBPTjiVfaelJaZhlLlBa\nZ0FVaoO2UpA3v+ujL+eWrZOX/jwSep3tYeOcO7/2pna94ViwjFbkxtCNj8Mv\n1yr9UpZbWJon1ttQmgF1WuSbMVO+iiY7lcAvWHbXQqc65KMa5sI/E+YCzd6d\nQ7jx5dJzEOTrDaA6GqZhEWwWUkJLcYiEUEFJoyQApBlucVdJrzryeMhLtE+n\nY8eZvAqnDiEMn1tzznjeAC13OIL5Cd8P8y3Zgkb9iLObRlzxhceoM6hTAVt5\nHk1V8ElgMclaJPMlv9q6LQoC6U3QsYxKfFldja2+YMYqR/sIHS2w61Msiads\nDtDbnCgxqOH3J4Kttq8HlWuQGwbtvY5OIVDq3gR9F8ARVCm5sbRagb/jqpT0\nRxOYVgCJwzzuoG+gTexLKWX6YNbRhSlaevbxoQ9fwJXN5R5Rngt58J/G8puT\nglvb\r\n=NAWn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1a9ef9a-1621054540158_1621054607328_0.6360119473816102","host":"s3://npm-registry-packages"}},"1.1.0-canary-6ceae53-1621206639549":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6ceae53-1621206639549","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6ceae53-1621206639549","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9c160816d516b030fa7f53e91f5901f32b939aab","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6ceae53-1621206639549.tgz","fileCount":7,"integrity":"sha512-8Ns7MmgzG5gQ1GVcy7w6EHNd0FR3S5Gcg4yVxR5irlEBXeR0ubX/mluQJMhL8Cb/nf4m5hYqOe3/UN0k3LguWg==","signatures":[{"sig":"MEYCIQDBTtS75aD7+8rt/1SI9AmTrJT7FVB6N07TCKy0Dkzx6gIhANPMDS7sscozybnGxHd8g6/+e6c52lN3mgl88l0ID4Wc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgoaajCRA9TVsSAnZWagAAWBgP/jSI212nu3gcGHnwrykZ\nwT3iluM7A4r3rymff8N7eodUb9EJp9jxvip1KuEilc5gHm0cM/7dM0XP1/SJ\nLDllwrC/OpCod/gTjutFHBkpJCL8/a4/0I1a7NTbOpvpxyAw7NW+Ku5fWD9M\nWC+1KiuUfdu6PT8EEW1kTdfsqDV598Rw0TCM9SqgyAzTY2V82NdoA5JDoc2l\nipSbwKn8mFq9F+8UCDjZrpDNCC6PwuTuBSRCWiR6j+MwKVMhL1zkuIOALNyE\nTRKwZrj70xTFG/nK0vlaNnnQe6lduI7HsDbt1dtPURSDgcV+SbDO+U1Haipp\nWonMu5/jTuvHlDU/2EvBqqRrCCj/xz9qLcSgyKP2gdksdkG9E09Kgb9tlAqv\nq1vIGD/my6i5bCIH+jtDTnJz2rjrrbBJrGRERJjEcT3wsfga6ZhofLAJlwyf\n+Qx95Q3m294i9sPdwBzZVhzYGu4OJlfGtCgH3NDpneXCFHN88zPYoxjaxnM5\nzGawZKAvIyBqI4qPBbTzRktMjwzwmctQs/26gzcEF2eZybC299hilDogrgPO\nrGGsN3HD62yWQQHFDoRVk3CNO+GQvdUwGULPHuziu6R9Pcvu+aLZjXTFJoRP\nFBhj5tig4/+90FZf/grJN7BI1v6wAb44EGfSxJ/JFzRONxnJbeawFhxS8Bq5\nPyjy\r\n=rQn9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.2.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6ceae53-1621206639549_1621206690896_0.04025039580945422","host":"s3://npm-registry-packages"}},"1.1.0-canary-b8ca634-1621454103168":{"name":"@iadvize-oss/store","version":"1.1.0-canary-b8ca634-1621454103168","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-b8ca634-1621454103168","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2b4f00c1ba0b878df5421afafed8a23a4682c2b0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-b8ca634-1621454103168.tgz","fileCount":7,"integrity":"sha512-n2gp7oKEj0ai6EGHfXmdpJ6W+Z6leN1b1waLQqfGtvp1PKKf7lWakr13p11FxLEXURETb+taM7Wgyx32VSPbOA==","signatures":[{"sig":"MEYCIQDnFy3GuLYkvTcMDjC7XUHrsAYJtjcxFfNVUHEvMUbrYgIhAIbW5m4Mb+P63J1GeRrpoZ5ubTNYP4RgmcyVP+vscD1m","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpW1UCRA9TVsSAnZWagAAMksP/A4CYt1Y0gKWitUY7oIQ\n0h8IdyH6CyXtodRF10oOeNDk7s4DZ/MFu4RzZpNgnLKoOGRrz3gO2XH0SscD\nO1k6rtICOm9zyH4ch1E7NJoBIcWDSNxqf1hScQJTGB3PmS783xBKYhUpbeQp\nfZeVstPLvw6LbqQgjQIMuV+xGRlhUklok7tc830IqMMO+OInK6oLMiij9HPF\n0GoDIAykX9seDxr++iNW5kwxTh71SEdJyrE10mv7CNZN10JVb2TJ1Oyu/yZI\n/WBNSO3p9mGFKD5hd40TA+DBSbVvvuIWGS8RH+yxenz1I/B+LBoy9M3aML+t\ni1hdcItec2TSv9n5MEBHfS/rOI/LOeSlnNJCa2LpWaFdcVvDem5riu0Zm0u7\n2FWfl+zdx2qdw54rmCPh6nuQotf0pBx2P4GtYXY04dsHwd87Pt46/lN7u2no\nU1EUnD4ZqjD0m/nqHMbh84vMejpcuBlgBox+aPLoU5N1MvedYJ7lRk7b8CBN\nsBK3A6SQrsEKoeXU8v80caCvJhpw92U3qQWC9QHydSM0MQzSuGIz5LonNTTK\n8xSec6t+Ou6tMvYNulMq2e4d4a9LB441QbFJRgS32s0PW7/MtbFKPlvy9HRL\nry8lhclolxIJiufUAQy6O7z150tjq4ZPH9NT5TnbxzP59KndIsYHcyob4+jm\ndlcx\r\n=6zVi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-b8ca634-1621454103168_1621454164128_0.74307566440034","host":"s3://npm-registry-packages"}},"1.1.0-canary-b8ca634-1621454104949":{"name":"@iadvize-oss/store","version":"1.1.0-canary-b8ca634-1621454104949","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-b8ca634-1621454104949","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"28143a5601d38a1d7f8a2a10d1b14969078e5e99","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-b8ca634-1621454104949.tgz","fileCount":7,"integrity":"sha512-Be7M+MXcbnoGoUQbdHmIDWi1ohbXLoPb+kYbWk1MV4irP+uSqgaH0wSoi7xnYM4dt+2dz4a5+++1kB+CpSK8Cg==","signatures":[{"sig":"MEMCHzacqAQV5h0BxdofSS1yoE3IRVo9AlF1a6JP5kgKqFcCIHR2NX5B/2r33zsRZJipLubM4EMOkIYYOAP0WYS5xUwe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpW1eCRA9TVsSAnZWagAAb4EP/iRfZnPacxW/zLbCfOWh\nYo+eTSKFcKENJlHM1sKO6fxsDhCe90ic6qBjUx1s0uwnm6sx8slSUVt6CjtZ\nwWK7F1m3Ai4t2anFHZmidBeT4WGptRJPBcsth3ybMDimaMsT0P2wi6y24l9v\nJWHrUrvEgPIiOPVVhkeM1HbkyPFl2FFUHeOHv1LTgrl0/3xAmjXCMXIQTPJV\nB5cKocv/DbNoufI8YpiFFzyJmdYW++7Pj9OStZdTw1SbLziURwBlvCX4mCzw\nmBJtE/D/cPZqgbWA8K3z4nvn2LWkso+R25yBB6R7fbRf4IFpC5BfGFS2TU3i\nVQc5bCFLqNUmCL4jgzTzGMMt6NFec9AEbhOg1WMeL1IbV9HXJpoyLRHfdFVW\nVJlM29CIDX4wm/gjSe1kvQP6eelHpbpEwC3homOcKlug+7umb1mnYHtXDs5S\nuzyNaf0FjZpFh/S7iMQCEoNiaWoVvpvDv7KlfuKAC5qiT+wk5SiLnZmK63PP\nRhzdHsrzYahhGbCU1uSM7v2bpefs65hTzpMN1ZLXw6PIq5dltI9GFaFptLSV\nM0Qq7uVJtiauoVZesIcGdw0TNlBynCuGtLILM8UKnzVgwZdsuWPZ/ZDdK/VC\n83oN7Q++P5w/R3IlJUX75WTy4D3ihuhGWaAKi8aP1UU22lUZv6swvOM9C36O\n++kC\r\n=/BFr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-b8ca634-1621454104949_1621454174274_0.8959293965184967","host":"s3://npm-registry-packages"}},"1.1.0-canary-15aae89-1621462509245":{"name":"@iadvize-oss/store","version":"1.1.0-canary-15aae89-1621462509245","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-15aae89-1621462509245","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"68c1a01a89d4c30c588d6d9d3f54fb92f8793108","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-15aae89-1621462509245.tgz","fileCount":7,"integrity":"sha512-T6bOb5WoGQO4FcmrK2ABaIxdRcXhdhfujIrmLkOBx17swguJ/ISKAo9XjI/qLln+PjvCexkhMDaBDOIo0uWMSg==","signatures":[{"sig":"MEUCIC3ibFEnLOSWpuvZtUFo4rP/y34vl6Di3cn7Mym5R2SgAiEA1hCEY1D1GphyzA6xj2hlSjKBiCJWUaE8fon/WC3iR2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpY4aCRA9TVsSAnZWagAAiZcP/2YLx06+tIkmT3YWj1c+\n2YkgItyrq5FZrv6xIbF8zc56ovcwapbAKq0YWk1vgMszN3hmeMOrJsUPmW13\nFd4eBTja6dGNVNVEIWHjVScgYEcwsZ8veiQYKxC4reSy2kmK8hO5X+DRxyEV\nGU7mizBRiNDY5LQsAA6XA6pernYcMi+iL5trKdLre2EdnJm2mx8Bluc07Xew\nSuH25u/1UijHSB74MDa57B3M60yjyrEyn8cHZ8x51KgNKHFHnkVwWbOAwwn3\ndpob92r7TMpxx3bqTmfSazPOB6mjlUQ/Bb5M30bo/snxWQ97kaoNt/ksz0D7\nsrM01LIJfvYB1YV52gLRqlcuuHDfEEHEOMZtwZb7jY9rygg1HOfG3m3FlJ0L\nQK0qe9X40GiMarHbkXcinhXCfu+gQGe/EWLFw1wJsJsrzICuYKudDGA0HhB3\nhHav8cucdwGAoLP1yBevauzh8fhv4ZU+sWrGcCtrtBPmtaH+QHCixEMGXbKR\ntxp3ZfWjDWar/QdwX61DaekC6pmXNdmffClJKX+wUNGhKeojBdCQFlT6QFmY\nWEbopKPprjQZ1Dwn20m99Hkz7Ckx4DmoXmxbI0ih876u+PEs2OYZ+eSUq1Pf\nGKuSVISGYNOiID+HljUVKLKkb/luSwN3D0HyVncs2UH6cIKAqnjzDHzqoUAW\nIWWi\r\n=NA9f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.16.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-15aae89-1621462509245_1621462553742_0.470154223716746","host":"s3://npm-registry-packages"}},"1.1.0-canary-41332ae-1621647037855":{"name":"@iadvize-oss/store","version":"1.1.0-canary-41332ae-1621647037855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-41332ae-1621647037855","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"460b53cf3d43ad2b38cb57c23b926e78b1d475bf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-41332ae-1621647037855.tgz","fileCount":7,"integrity":"sha512-5NoMNAaKjSga/BonnZeQ84C0gG8ZRXab2sZkbLd4uS4HnYy5e1eOih243+LWMwrQSo5Rz2NQ+DnPwnZpcUgZ9A==","signatures":[{"sig":"MEUCIQDtoD8z+QCMd03tMs9afCbyw+1b4SdsiPQ69bozfoV1wgIgf9UN9CuNHh56/AoRrWXEucOjtTMY2C8GatVx5UXe7co=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgqF7uCRA9TVsSAnZWagAAMsAP/3oFkCtYnjVb/W8pspsz\nrtC9NWuEHXSdQR6PTXT0awTdMSHydLizxSKXmgK8sHZYyGj3Xb7/+MCgUg7c\nW8hXHkw2TMqOCeDTyblbShl9Vq0gTpkXD3Lz+OqabsgoShgkwHcRNM+dZfNQ\nKTMt/Lb5XNt1ONS0lCDHmOlgcn2qGvSWtXBhLG63ZAKWqgDy/QFRtz30w3oN\n6TAQL30tImMpXiAjZFhRrwKaLWKk7uZ2ymiVGL+4sIXga31XlaloRAUT8nLx\ng0Gs9CCd2C41BgFEqGzPv0lBCYn72Wj+nvJFCtNPCshNpIvgSR6MQBlmPyIb\npQzh5HuYefG0iPqZRrztovEDbPokJ//rAHWx8FnQwo3pEET37zWu9oB3YFKe\noKWKSmGU07kZzW0v0/x/CZ3fmbkmTYjrQQTECgW4D6LFR9E27Q92MtgrXfCl\nsddXZEhTdZnybpYaIJ+Ngq485G86E2uDPVadK/oJLes+QHawQStu5nKmdxqR\nHmbHB4wtJF+IHOktMwe5vrwfqC316UskCzPd+r45lfVd4dKwqUqwWUNrKc/r\nZ7nMpd2eoMBP8GuXMU2yuVexwgDS84sqgUy6oejVONQioe7OFpG5ravkKi0S\nkVax/3+KUUpmp2f2P23mnIClLEUD4Rtly4+3AO/M9aA/hgBD2pJWCbcxx63t\nGI2L\r\n=8Eyl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-41332ae-1621647037855_1621647086150_0.8032785552583639","host":"s3://npm-registry-packages"}},"1.1.0-canary-41332ae-1621647037269":{"name":"@iadvize-oss/store","version":"1.1.0-canary-41332ae-1621647037269","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-41332ae-1621647037269","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"29ff4e3bf34c04f3ef0d678b1d4f89ba60a167c8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-41332ae-1621647037269.tgz","fileCount":7,"integrity":"sha512-kcCn5edmmmA7DiZk9YjnkhBWna0EP6LW5oQiixI8xnLPhArbN5ppFrd4gaDvjOXrYYfY+ghtD2VKK4ltkmky4w==","signatures":[{"sig":"MEUCIQCfAD1EhigsMla/Pkfb+XOzIJ9OSZTZugGcAtkBjjFbGgIgASTuwO0clAwiL/8yy/BfNBLPPnrHDfLmzDcn3cSk+Kc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgqF74CRA9TVsSAnZWagAAAicP+wWxiMJ27dpErvhW/S96\ns9KoBx/rQkiPLbCqcSMdr+cAfVybQPFn2IqtlR9YdD8Xjb8cE8HKOyxFaBaI\nuPbJIVe3THby4UPZKGY69sqF8PuuRlKhXlOkL5OT/tTgEdGCcRq9N4kPdUjJ\nxN87D2uRkCdhvfU3T4fYKLyYxWCJnrl2yEHlk0Of8IFSrlJVgCptxe7GK13s\n6MpRgds7iQOLpl8xZxhrwAApolaYH/4NK2e6CQqty3FWBr4/dymYysyn5QN6\nhYc0jHcOFRXc1FEVuGNjh37VKQ5Hph34bJX7mlPPnCXhntBIQtlDz/R30XmD\nBF4dUpkw1j9UVcpS/FGIbG7uhBMc3nYRibekus3cf004ipSbTcT7HAREHv5t\nYz13EVxA2/WSlRbyr0Ku8V+kAU4Et5IDI3u9fIMVli/X/8hZlUjcY2so2JPj\nfzyVFetSH3kXlddy2IR4YRQvRvR9wdY+dbHz3GAP2VRQ3YmfMom4QS+nQvh6\nCPwfsElUxtaFXsngVWTwmoFFMC54rzPu7rYDEnrDLxA3KIzc91fMC4rYqPJv\nBQTGMV8HSiF83FYy8Z6gdx+eVZ8L5rAfmdYa1aqVk9BPB393o3Zkda2p/R1o\nPRq6Pf5GOU8HufflGOi4SW3vsVStEPX+zDR4S7xGhsFPikmyksg7ZkyHoEc1\nzH0Z\r\n=XjSH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-41332ae-1621647037269_1621647095738_0.8614607054899048","host":"s3://npm-registry-packages"}},"1.1.0-canary-4e797d6-1621747453538":{"name":"@iadvize-oss/store","version":"1.1.0-canary-4e797d6-1621747453538","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-4e797d6-1621747453538","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"acc18fad586f5c76add10dbc9fbd682076659df3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-4e797d6-1621747453538.tgz","fileCount":7,"integrity":"sha512-77FhwfgZcJIb4AhWHcNbn7XOAEYQITrlOMQ/uKTPLO3j4u071PGVjA6R5YptSwvB+CGpxloilJpfwvKnBMgdrw==","signatures":[{"sig":"MEQCIFWzG4PNskVSH2lOteCH99yFH27PulaBL09Uv+2KyYMgAiA8Pd7LNJbunH7o3k02SfdQ6E78atpDJXvXWcKntwE1gA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgqecxCRA9TVsSAnZWagAAIVIQAJrWD3+SGxKH6cqdLf2C\nu3KWZU6jcxrK+61ulcl3AbVU+0zB/8M1k7K+Cfb3RYgIxYPG5BTrnM1mYfwA\n8z1NR8udZBFWGTqbdlORZ3IMhVvDI7uHQTV/ACpRgtBWgpvAdUI5fBkT7gDX\nnfLxTr1Bw6Z5iXbN80YqZkf7FN2Xldonahw5i3TpaQl/7caVHm0KAltCOHib\nRJeO0vIKRKZ+podpS/ty5S+efr1TxnasfOom+82ckbkZhQnaNEw2wh+v5Xm+\n7FKUKk64LbWqMSOVuUyt86iqGBNi7PcwHziVdP4UMvRkpcYFNY7XBm6XarbJ\nFP1mJLegjl3bYVeXKvLegc7k5rqG8xnJRfY14aT1q+/eTqCj3SRAqZo/gfhx\n+mQC4RDQWQEIKx274KX4W2HVtPXDTZXjYxLyZWrB4CwaPxx8NVoFXZ76LTFh\nCHYk4G2N8l+67r0jv1h8ZNm77zCQR/Wo+Uj3CdaVoxprfzd/uLXkNoqyf4Gp\n2DcIfcIXgrfRiBJ0s+xV/vNifJvFS2pl0tdHQlAshTAAi1ukXS93KUJsvyrE\nYl7wGYWIIju1cU7E+JlgseIaN0BT5w1RI0q2/jla7Ea615JONRpGedNpQva8\n6fnVpowJCHTijo1qpQLMTshZICIUoGwNVw6fIpQ4YewVk5rxF6mjpCj+BnKN\nprrS\r\n=m9NT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-4e797d6-1621747453538_1621747504431_0.06586543368024222","host":"s3://npm-registry-packages"}},"1.1.0-canary-230590b-1621812251395":{"name":"@iadvize-oss/store","version":"1.1.0-canary-230590b-1621812251395","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-230590b-1621812251395","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0768e3419a627fe52ae9fdd5f37a286aa0799cc3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-230590b-1621812251395.tgz","fileCount":7,"integrity":"sha512-KcCqv5XTX549Wmxjr86ZtiocwjbFslCgJw+oJ81woZArGCKGGmKam0riJpR3ncl+MsHEEcD7gm1aTTGfrFuzyg==","signatures":[{"sig":"MEUCICKzUM+Gt+GLRuNSQjoTARMceWR3NLCkMiNPgwrkjpzIAiEAkFIL2Xk39Ys5pfuA9UoQe6BJGq6sMNtclJa2lBbgzbs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgquRVCRA9TVsSAnZWagAAkD8QAKTlGiDgJ7xJRJ9+HaOD\nJxvqr6wiYDMeXjCaqv3h6MdyF+l4jcgFOWDBwlzlwG0+Vzp/ACFhTy2jc60j\nBfJR2WxeYFC4lt7wUB8B1j40C5xpUS4t0MBJKsePDmxoB/txgsncvczntxSB\nM3GC9UgpiM9zpJBaiiQLy41bedzUKuAaonbZReY7T0lM9unMCpI9m5Y6JJ6t\nKM/JpPhxYvsadlwhZ3vjjX1hGs4dB+h7gjwY8RPBprs5k8nLcaKITwcp2ojU\nkAFKV5BILmZxoCq929InIxAq1+pWBXPgMI0p1OJNSrsxKawxpzQdsi0tv286\nKB/eC3EQR1sah1fY0t0PilOcsDEwQKawlHj3B5Fr+ti09ljndgJe5TMiw6rk\n4ynJHviBD85NjrCZpkwtlvn5jHeOGLYTdNQy2TCJuUTEkDRggQTyv78Qmiwj\nukPcrTXzfD4T+28geN9/H1r/mgffp8PN026I6OlwvxnQyPUJ3HoHV0+K+NZI\n5JiFG1ujApgU9jHAyeQa2q0MMVGW625pTBgrrTIrKPe1JFFNnqBHo0YdFuqF\n81uk0uh+2Q2QRbsBLMTPPWGXKVlSyZhyFOFhV2WZLtEIeQQHHJTKEyNxmIs2\nSLqd18M7h/TbPHd+3LIJ3Z5chrwh0eo6U8ZEUhpttXVmfXzguOxuT2cpW/Tx\nRI2t\r\n=79OU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.26.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-230590b-1621812251395_1621812308753_0.9804446725785303","host":"s3://npm-registry-packages"}},"1.1.0-canary-8bff5d7-1621812284309":{"name":"@iadvize-oss/store","version":"1.1.0-canary-8bff5d7-1621812284309","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-8bff5d7-1621812284309","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dcc7a22938c191971b45edb56a14beece070d64f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-8bff5d7-1621812284309.tgz","fileCount":7,"integrity":"sha512-4aI8bDUy9omh8FLWrFcT3K09OEOMlaZsdgf/uXLH3SvF2wMn546woybEUKM2n1DDRT+duB9IKTGJAnE9vHau0A==","signatures":[{"sig":"MEQCIBgPMMeeimASaogWWnQw5rJC7xzRljDyvExBnb4BpsX1AiAgThvzVFtu1xJ7SJFiLf4GdoaTeaigYJ9tfdJ1iwsW+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgquRtCRA9TVsSAnZWagAAL6EP/1fyPIoHz/hrPjgrolIE\nEY+0Q2l9n5TwZwtkfTkrpr5pG0+xR8HYXQBvEVwVmIy5tbjYBXQm8HcxgwgE\nwyuAzh2BsAwl1WC1Gs9ybl+T1ozigtvr7mA5p9GckfrDS3L4k3iY/JY6zEoD\n5MgVftrF/ZJPTZI4+IqZ+qDS0fKgnltnxKx6cFJCtY8RRJGpxNdS6ZPUsShH\nmfkFTjwYESmJVSQcZsoQ1/rM1pk7WEqyaTnp94oYKYZ7fK7URZQWHFMqvvYx\ndWz4jqdUCHGVJ8TZ69MWj+430UaQ4rDSZKvQVTiKqEOw3qOX5iC/mwtouPYG\nF61gtaADLwW5zFXKZbnAF/iXruhm8wS0E+sxFecR85AMzYKYMswdtm0vCYfQ\n0dQFU8jd7gjXW2DDJnI0Qmp/LTqFnyZHf2tARW2zL7/GYBfk9C+/ekNVeVdw\n8tqLKmnaUFf1a1GKULv5wpFUTxHizezPI9rcc+Xfl3Ar6vDXvN9BpZoJ4L5J\n5WR4EqsykPs1JWShVbnemh2s61KPX/zbvGVJuKyZBsFzKf5WCGnYVb19bDaB\nmtrsaWs653VFGGvRv+NJh74qalHjOD2GYHLJXsOzgwh0crrtb4/5s/3zfbyd\nB8+FWRd3pJ9lz0J5rF62L6PGMuhDb97AcATahdJvtIs7caTfx+B5hSxA7E9i\nckbi\r\n=EFfH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.48.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-8bff5d7-1621812284309_1621812332915_0.03910779198026337","host":"s3://npm-registry-packages"}},"1.1.0-canary-6b47da6-1621847774214":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6b47da6-1621847774214","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6b47da6-1621847774214","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"962eeb5215a80f3dc0d5c2b39484781f2b1ce10a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6b47da6-1621847774214.tgz","fileCount":7,"integrity":"sha512-U8Pfm2/Pnu9yB5puBowwBgE5Jn8V2EpM0ES8KRbmSl5QjDKAuTHEgPYiCCMK1g3vnzuwW9LffUXFZE2N0Q5avg==","signatures":[{"sig":"MEQCIAcXHnHyA3+cDvSJjDm6sm9nNNN3daC8GTGz6CKkJQ5uAiA6ZQYrZX4d88cFQuWZllk5ZuXK2A6f728544RmDGN27A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgq28JCRA9TVsSAnZWagAAjxIP/RroeGQxc4foW2IIeWu3\nmvgSlApgLK29TCkT4vUr9mcPoNx6+2JkwFQDuXxRSP44/0Lrbc7YymqveTtS\n96ocYEIPE7/Ub5e8mvCIwu0PekOi6r4KAh3kCpS1I/JdHL3P/+OxUng57TWB\ni5j00bSXBMlOEqLqURMPqBi8w+QJeDGZQrNCcLVdaegclMzFRKaz5deUU21j\nGx8+hq1nkMBMIrm2g6A6jsesDq53MZ1PyUevfrCYN33lhOLS2rv7AIzL4jVx\nHAb2ZM5kLpnjIl0Keb8jgNd7VaSazBpMGkoyyu18BahWELJAXOYhvbfZDIps\ndtNx+1t2qE2+gEG6R9g7PfrPXenYekpaXyiW/Pi/GRy6plnDoebvHckjiiby\nNnubksLsbwMSDB3bmyYvpHAhrqx7KtRNgNfzT4Dv0Tlz0KQX+jsixu91mxvO\ndN2QHrFkCAJlx/5iwrIeLJIDF/t37vfrp2hYcriIFP6KFbQso0G2WfkpA36e\nCczZIsvuoOyCZQQmmjOPJsgzbtRPF6PyXfe71iYHP30IXd9Lb6i+YAYiSwjT\nhly58hlJyLSpo/2PqxCKAqjPQjBd+08qwb7towixUA65Hgqag6C/e/01iTuv\nl4LBNU6c2EZyuN7usGqUXzMFh5Vry6bXAkBt0CQcAGsrFwEq+5vGUhHUOWrc\n1cEX\r\n=4N0t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6b47da6-1621847774214_1621847817515_0.25835192032437804","host":"s3://npm-registry-packages"}},"1.1.0-canary-706e2bb-1621933802760":{"name":"@iadvize-oss/store","version":"1.1.0-canary-706e2bb-1621933802760","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-706e2bb-1621933802760","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f89709b4d8fbae3821a69ddedbc76c593595abc1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-706e2bb-1621933802760.tgz","fileCount":7,"integrity":"sha512-96WNoOy9dvdG2ZSSRFsgyKyw3MgFf9arzrBslEtnCJYsACo6HGPM3JeMPreHyky0C3OFVew/vgu2tgBxWRRppA==","signatures":[{"sig":"MEYCIQChdqvTpWthJwFqrTgX/p2uxhLKeSUtOpOSoyoJBXNnaQIhAP2A2ilE7T+4QGaE6TwLcIwABIvq78+RAsFO+vwUOOxA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrL8dCRA9TVsSAnZWagAAEfsP/ilONJ4ePIxYb7OWQgCj\npD1CeJEKe9APTsADJ0YOm3QLyBriHvQ5onmQg0kRqOnikB9nV3ACNY7iNvoj\ny+l79GJvTCWCE9U3ndTxDZ7LIzXYu1FpLeHRL5A0hnM8JBsRFO9V2J33Q4TH\nYMO2WG+VBHUs10txtlTLDyxNPGX8dZfsR0McI1fp97Ym/tp3tXH4vpFTjoI/\nPR32IyLYVW36nyAXW9K99RsTughEcjyvnQcpTr2EJum/B9MP4+6HH4zj4vWL\nBGvvhzQUfnnVSv89pjtPj8L5D6ymj2hWTMlFlCj+fBS8VVlrXpfvGDvWSVEA\ngxoIvjGRdl7wSKaC2i9FWGaI1CLrHEG7KDVzP1jrXjdW5Dah/AgEzIetzmAs\nQAD+ujzmYYM/58rpgOFGjGsi49VpogBg2COXJV4wjscZEQ/dWWByLZyhOzIl\nSlaNLNhv2wdYD5RH0s8MnYWTNtJ8N2bI32KQm/oaR7HZQcg7YPN90a0cORxp\nUXEtX+RgqcAj4xKCRmonNfB0mTyH8xG+NuQ0txIL5w34ZgGEUHyiX4Nzt3D3\nUIeRjRWIZCDCZwZEJ7sW/DQcEIxRqBmRXemFynLC50l/NhcJYoDFsejBCrPq\n/glSWc5vSeLn9lqQB2lOoKwbl9db1cayI89mvyMxoMBq84NquFqXuK8vcWEY\nTiea\r\n=yhl8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-706e2bb-1621933802760_1621933852892_0.7134364769980535","host":"s3://npm-registry-packages"}},"1.1.0-canary-09f7513-1621934485417":{"name":"@iadvize-oss/store","version":"1.1.0-canary-09f7513-1621934485417","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-09f7513-1621934485417","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"af96a6eb78f0e564677b293a438b959c59add09c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-09f7513-1621934485417.tgz","fileCount":7,"integrity":"sha512-wewscwlUWKzjl5c7ey93nMHZ/kmw8yG1dHz75B6JwrPEQ8mtPYRXzCKszrWyxVSv+C/F0/TsyvB/U19nlrimyg==","signatures":[{"sig":"MEQCIHG9ToHUl6sJl839Zuo9BA9WSe75Cj26RELu7Vf7w58gAiBNDUhpXzgsANE7ldJj4nQR6Gp41LOOVkUsrb8TlNyfPw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrMHECRA9TVsSAnZWagAAV+gP/j2oCsMyXB7zb3dW8X5U\noizCzIy8t5NFWv78+xRLYuNqqH0e+sqKpRf7JQRCqREerw6cuE8xL1IH1df6\ndMOKt1rCgs/5IiENyA4K/HQx2sJ/tdYUBW5LzVxKDy6GUAsHn0q9seq9IEst\n1sDoBBCVp7aYKWikZ+sAlUvH0EW0ReN0P76tYHsJcUbKLb5lsCq90cqTN2o7\n5WGlBDneVJbb0I6A11imPIdcCSIwja0y305UOroHQ6bbg68JBijOGQ7XW63Y\nlGTHTgT3MfwxJxfkXslgKPbkjjda+iEY8MwMGYrBsSaRpx5lXVKl+7fKqk8i\nGKblWsb9v6LLe2Yq7Maf0AHpUF4mX5o+Pbpox7we/mgf2QdbsFv5coQNCg2s\nOdptOlcYUGTKHJYcCq+56T2jj/S9+EqUlHXUTajwG9l46GMkY+KOX7e50gZX\ni6BjwNZRGDzRE3GL4RBB0ZqLLNTbZ12ss+rxgfrMWpdew9nfqxJKvB2mLiCc\nm+ED08k+3RJqKJSfRYxBB95MpwSMljYiGHfWN95uMziLuPgRfAHvMkAIH6C0\nVuVnx0RovmJLmNJW10YkacwnKe3dzXRCDxtPVhNLUW3YL6Vtz7smxvlS6wyf\nwHyh/qKG23JHoQkmTdInrybF8i/6WpWv2t/9uH2r0VI+NeE9g0WGjXECzF02\nAVBm\r\n=ImaM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-09f7513-1621934485417_1621934532259_0.1174040865818502","host":"s3://npm-registry-packages"}},"1.1.0-canary-623b193-1621938473734":{"name":"@iadvize-oss/store","version":"1.1.0-canary-623b193-1621938473734","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-623b193-1621938473734","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"83930d4b282008eb29e265114d551b9366730700","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-623b193-1621938473734.tgz","fileCount":7,"integrity":"sha512-3bz8BsKpSH89EJ7Jyw5hq0MTL3U7k4yHckdRkBAbOxAftCmkAnw23BxFkHEjCuTElZsDj63ZPs865aEqWMXG4Q==","signatures":[{"sig":"MEYCIQCChGoc8KJICdmc3roT8pooqmqrChTBWZACwCUggxI7swIhAI2yALbMA2N/qg5f8dkSXq5bsqvyRVCJdF+XVN6wLbY3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrNFRCRA9TVsSAnZWagAA6BQQAJIKId92IHVxU8yG4jXM\nQlMZJMmSozb+2Qt0g/kNcMGOghv2arDTfxTYahqlWqNtw+Ll6Qx718Uc0qA1\n8iw4ttqJTjz1h0G2YHEMguG4nHb1iD+mUA1eFmndi6OA3XEJfEONw9Cpy/X6\npi6NwpKeVy6uAZy2RdiQcVWvdw+b/G9Opk/HZiGvyzNRsTxMSo9seKSArWlz\nnQnALiVlYVpoWhv/6vbvnNt+eexrrs1kwm/lJ+HSeBRXpB6UAUV2YnQCi+kD\nF1/IMWfApGo6hLNSEJbQuaWrlbw+SrB3SpHOrbvrq+ff6fX0P5pdZJfN03px\nDbbCf0cKAcPw8whdlHomr7LxxggOfR7xlrlD424V1QvO/123fda4lzkfQXnk\nWOJCBf9EcuURGMSZiGw3sGHo0Dlqh2DiVuNBckqypNtzHmgwhehVfKspjhPF\n4x7Hs/VfoRCcHlOjJXpRuoHAfVgTEZTJch8HbcqYN9loIpGcT4mE3b77yqS1\n9ZfCzluBlHOfoQqzIPSCTRpuGnUth3blhruo+370mVbjS2RWv7mrh/w53yY3\nmw6WqOii9hZ3QC/QU7Jl7NnU0oV7KCkVqxzQOzu6lTP+fEP4xys09hgJqRgJ\nkf7S3hXCtjBUtEqMhmAck5qKyYWtEvBmHybcO6QQLfmHohjw0HAWD+mgFju4\nQBUO\r\n=h/MP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.1","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.49.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-623b193-1621938473734_1621938513427_0.3705917773909655","host":"s3://npm-registry-packages"}},"1.1.0-canary-fdd2ddd-1621940616250":{"name":"@iadvize-oss/store","version":"1.1.0-canary-fdd2ddd-1621940616250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-fdd2ddd-1621940616250","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b2c0f9cc274122cc801ae226e478d105e8c9058f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-fdd2ddd-1621940616250.tgz","fileCount":7,"integrity":"sha512-V57Ox9Qx5qPGBc8HxWkJm2ZgricefByJGsADCuZVoZIe3GN3UJzqwr/EzmXmnxlNkJVILn1wOBDHvoejci1l/w==","signatures":[{"sig":"MEYCIQD7asixDHkcFrh7CXxIEjqpPWRpbIl6G19V5vdPzdASTAIhAKKALGPm9MtTORvDcnrkZ15v2xD963YT+bsUXg7FAy8g","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrNnHCRA9TVsSAnZWagAAXz4QAJFasekA5LccL1YopRQC\npxfgcuIdEIPFBkOd9El3XGM26HsYX3iDf5fAei7CoFippynkYifKiRhYibF/\nvVbiPAyQNAbKDlean+SdTH9ldVtwO0HC4fN2jJe1F47SNcu1AeHqaI0JTA4v\nGxaRyHp+ODbhVzuE0SAM0PhZ0bqcFhMvBO6U/mBEJ/kPwhsinAeRcIaeVFBU\nUyapsPnFgGUYhJBkMAV02d5Mjv9k7xwD6abKWwkKAK2eR40wgyIuWSJBlI56\n07xZG9PauWaVA9iO209gqQv8y9wMxjcHgEe53gOmVcegpJZFgEnsSm5brX4V\nYXg7dxJizHNJtFpvns9yFWZga0EsKEIqeG4Sd7cOdhDz5CdkMkPEB1OqzUBk\nGFs6fKViVT1MiDVgcfhNPZEi71RC6YN9LOlBJ61OrAyoOxebb6xx7KHVSxdR\n4c8uFdvk+V1PWy1CWOtpu+PdcMUGuxvrdAK4P3OefCQ/8Np9lwWP86ZqYIGb\nmFPTTm9fWGpUJWwDQ8gopKqS2AheFTAvu9W2n+Xj4K0swm7RCj7joASG6X1d\nS9gD0IH4Ea7JP/sfJ+/mshkA7/vxAi6uZZ9Ozj981vGN1X+MTCYlqginLjNu\nsKfPU/mSPOAejw/PNwiwz59oyFjBHobdm2ORZWEAq/49PkJyek9DXorxrc78\njkw6\r\n=81d9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.0","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-fdd2ddd-1621940616250_1621940679235_0.34564308290390966","host":"s3://npm-registry-packages"}},"1.1.0-canary-6da7e94-1622017589981":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6da7e94-1622017589981","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6da7e94-1622017589981","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1390e432b7ac1576e39c8a34f0e0f84be0b4cad8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6da7e94-1622017589981.tgz","fileCount":7,"integrity":"sha512-b+HVhqjdSXgPJDLBVj5vkK3OnQJCSLpm5HN6ZfibANLkHMFykBMgy3ujVl/GcurXWBOxroMjhnquXoe3v4d00A==","signatures":[{"sig":"MEYCIQCAx0zZ7YzJHYg3h8ScKjR85IW41sFnqoJ1h0YVigFl/AIhAKk5kZR5HS5gwTLXBvP4rbQpBNpDcK30Yfl3Mxa+EZki","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrgZnCRA9TVsSAnZWagAAJGEP/i0iAjdC/ggV4XODE+A3\nlU2Mlxx798RdWKMusWCtsGp/vXpvqllK7634GWq0S5AHtvBgM7JtdS5RlHCW\n599QNV9Pkc6eT7UWduQGxwYzzn6AYivfFPcqRkfe9TboLY6S8ZJ1p/IE+MWm\nIikqjw+h5K71vxowh/yRl1HWtX6eukrDVbNUSI6wcNuUzx9YOqcF4c+sk3QV\nF1IK5QJubCq1wULjqAHIqUttpBd3XReyY7P3tbx7YZL+YJK+UxQbQkZ9cjSh\nTXfTUADDaIB9I34MQ8S5DPgpcTg+1On6HvzjeQXyIu9Lwbwjk5c/Tj5it2RD\nM7He5Jxpx6hx5KTT66oliEw5VlyJ9qRBduhVtj7gifqnhLwH5xlDi1XqSHCC\nFK/ACj4v/OcMB21PLcQIGp+270ln8WuDTDBY3Er/0wYWVJ44o4uNFbOltFFB\nFDiMTI62KFAjdysrp2QMWE0QWvwU2lkjcmCPpfM3N+wTQkQm9pcpC8wtd30/\nNHyF1BnkRvChAUfFDxyqtn52msPiupDWZv67xsrelKA3cJKicqDT9MBjaKlv\nueukeH/aC/CukHYWRunFE2peQ7Q0Swc3CUkk6RHuJv8bLKy8oebJDcQBe5TW\nT9xAG5jbHqVyjZgz9qyv5xHRQoQPnckoQSspArFFj6l9I8qFtn4reUqBTZVY\nkZgy\r\n=qei/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6da7e94-1622017589981_1622017638882_0.4037426538893245","host":"s3://npm-registry-packages"}},"1.1.0-canary-a9aa0b4-1622031121648":{"name":"@iadvize-oss/store","version":"1.1.0-canary-a9aa0b4-1622031121648","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-a9aa0b4-1622031121648","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c98f35066ce064f557f6749d306cf82e5bedc5e3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-a9aa0b4-1622031121648.tgz","fileCount":7,"integrity":"sha512-cOem0yDT5J/CtIHOiDjt206z55jlWVUVB1w7dONHbDctTLEuLcPGDS8qi+rQkQOgD8kqMg/71gCVUI86cHbKpQ==","signatures":[{"sig":"MEYCIQDajTBYBxTe8Ughj/TnQdHnJwi1JW0dakulMvevdAj26wIhAJi7MHqnnr7q1P7kHNud3YpW3CtkcOX7OBPnFdRgpdrL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrjs+CRA9TVsSAnZWagAAF6gP+wbE+g9dEE5HgI8ICsAR\nVkUhi/ph5XyK3oWu8w21xO5X8xhWSb7F69rAawEGW7KmVQc9TKXyZorPbQnY\ndKhbw0EnwLB0xY25kzLdP1uZofdm1j9NaA+ta9MhT6PjuenxuIUervNy/qIV\nHcrBlo3XY1M54Dr9ZMvuFC0F881JpnC/8df7SQkrBvO9Ot8esikBE8kX4u4K\nX1e84XhkICCLaO6B6+xgIuOlpeXY93welMRBC2wnIbyElnAZbSXhO4m3+ABX\n+mNVG0jFtnhH+nwaKwdHO42FW6IqVM0X6ii6Yx0HMXM/m7cQw1U4x/GfH4Xq\nkpYjngdHDeH1x/JbhtO40DWhO1cgIIM7q0IShChXmatuOzpbXLIxG2vTfvzE\nGIaKtvqdd66ywXgEyGcEtWs65Kc+H/Nl0KJ8P1fO+YFF4ifBqC7wg2wHrjst\nOZGaoGJPnKNTbhnlcymkpjIL1X7qR7WVCc2AJS/y4MiPFReV1zTPLoCYDK61\nQm37NtrNx/n1Iv08d8T6XckjbUHDnBQzZzhFGmsa3BoL3uqCtIB/FR+t5BeG\n5XMpMZIkxaNveidDG+8sgth3IewWzt1YSMIarBeTohbxZGnyAQNQ+/lWKHp+\nfbC8LIBQasmoScW38eq1a9CSkfphN72mRQblUyIx1GSJiX9pZU8h/WvimhC2\noaSC\r\n=vVDy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-a9aa0b4-1622031121648_1622031166319_0.9012794760179454","host":"s3://npm-registry-packages"}},"1.1.0-canary-6dcf744-1622050575653":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6dcf744-1622050575653","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6dcf744-1622050575653","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0377adf5e13345595eaebd70c9718e6e935dcfc9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6dcf744-1622050575653.tgz","fileCount":7,"integrity":"sha512-2gamhjLX68vPvm7FAY54NLKDwaazwR//pE6o4TDB/feCFA5w6LmI5W+rVORsqqmhuDbm9yKOb44HXUj/FvNzEw==","signatures":[{"sig":"MEUCIEAVwE2O0SikA0mDCyK01subuP+ZJe2Oajit2BeUg2EjAiEAhdqW1nbsDydiPliwZg4p29V7cbQfLJcPSEi0HyMzxqc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrodHCRA9TVsSAnZWagAAY7IP/1GRQB24ijxISjNBZxeU\nHS+O0XZBha4iRARuT6Q12wZHkTLc4x4yJOrG7a9m4fOsBoztRJwTV2umy+x/\n3LV+8HdjHR10YiJhmHu0s6ECrO+aT04ste/pVbqBB/WBg3EC7UC2zNTKZU9+\noBmycYGTAqFZUn2eZZufXMyVZoqqU6R3NUX5ZShFy4XmNenkXUYaiHnz1hyh\nV3seNARK+hdATHrnds9Jz28KY7ixuNUkOlB6jD0oMfIawv2q28LtmMgcE/m9\nK29VJ88fIv3dCmGv43UYkGL5FWfdpVfdaNDUO7NFVVfypyMbZ1rR6mYi5Tvw\nQIkaqBGxJ0Ad3SgNGAw6dhZY7RAyoGxQngJMNJDISdnlSQ5++K+jJzVltTV1\nwb4wd/VZyz9Glxa4/gSjMw1Api/DiZ7kikL7P7Mj3vNS0OE2+14TRlrIcJZG\nfTt/sSxSLHx6vl9c+2phrvYEWCIkx0451lyZwNriGeW6R1uBRdB52lh02H2M\nl1ac4pQqtUXS5eiVToio1db5T2MY9aO74eg9uU/bOrKXgYXA+a9RLzn7Pudy\nfJkDtCEdct3HQ6Q77TSvLx/Zn/UxX1VYv00FEq2POK2Xo2fX25BBTys5WIcr\n+y6eCyfHjhUmjvZgvxCW4JVJYuuxU/GPxLj9QJADxDmBwEd36DePT9cm36sS\nqKHN\r\n=eKAA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6dcf744-1622050575653_1622050631173_0.38896549859064633","host":"s3://npm-registry-packages"}},"1.1.0-canary-6dcf744-1622050579042":{"name":"@iadvize-oss/store","version":"1.1.0-canary-6dcf744-1622050579042","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-6dcf744-1622050579042","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f0a7a3f53de94a8817e3233c0aa02384225bb061","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-6dcf744-1622050579042.tgz","fileCount":7,"integrity":"sha512-3pPJffwVA1pbpQLfnfDnzcFzAwCClD6lav/QXVaSDeJ3Z3yVffL3Q3nXENhq7QLXUVRrW1lvipcTOvlsKNoHAg==","signatures":[{"sig":"MEQCIB8zCVl8hdddwY+2Kr5MRrL8aOy8CQy96j2S+Uc9prB0AiBN46B9H6OH36fRIA2z7hfUlhQr4pFasBdZBP6kb17a6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrodXCRA9TVsSAnZWagAAKl0P/i92qPYLTyzzc9KhPkl7\n0WAp7yvoDgfB42PSepIaUSjglc6AMM40s5q+ZLk3c2/62xvYfFbzo4E2HFyN\nTBBogai6TjhVUovweu2jUo4pMUrz5rj1sZ/ZMUX6Lo3tSpS7If4h+ywlEW2f\n3/ixB7eR6IhkJNsmTerakPwTGIWBIGYGG2QTogICM+T/6jnJKlBY3vJeV5hK\ntj0zE/Sd8kXyho+tRBo97Y27/qhYni6/fDQfmqNLtiPAYm9QEBspROu05uDo\nbM8ibFzg4R9MYlPPdVEI5O3L0Of2IujSn5TGWjDVn3mpv/gdO2e1dpZswUuT\nLcKulC8LfWz/IcBtRVPYvpbWQ1YnqRpsZp3KEXlyihVlpJcAcyW+e6m470bH\nn7aBrrVoTOzfNQ5M4tXXt15o98KWvziXGGpfrwLCF1D90BcRzl2OLUGTicPj\nSButJGRn10DfKqj5HsurFfPM/WRKmtYJvqfrPe4uE0W0GlPNfKq9wgY+DNaD\n4+RIVlDwV9tppD2gVjvzJxFRNPmoBOhF99iI5i4FJgF+5zPoNbMiWVLJFNCw\nggktXV45X4DUubeII37DjYSBvrgBdIEaKvCLvWUqBfGI8h3AQyzl/9YonOUm\n5UmdCnEJ27o0JyC3liQjnZlj6CuF8yD4gn52XxZzxaSGbstfbsLeij1Zh5Vh\nKrAU\r\n=TNgo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-6dcf744-1622050579042_1622050646699_0.06564366017643586","host":"s3://npm-registry-packages"}},"1.1.0-canary-303cb2d-1622108078656":{"name":"@iadvize-oss/store","version":"1.1.0-canary-303cb2d-1622108078656","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-303cb2d-1622108078656","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"404948d4a9a1be6b4cb33feeed9657cc9afd8369","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-303cb2d-1622108078656.tgz","fileCount":7,"integrity":"sha512-OS5Rrkei7aqJjrAinZ1bJ5VPSWXE4NjfeLPkzws9yG9Hs+9z0EcFo65ViWLwUGdi3phQq4K2JFU2DY8wDnkn9A==","signatures":[{"sig":"MEQCIEstm/qGuHmsQdxtngQlODJ6Gg0BZpqlhR4zx9kfeLxZAiAOwZNUshO5vRPZ1sD+H7LiZPDF3d4RDQHerYVSqeqNww==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr2fuCRA9TVsSAnZWagAAsIcP/Rs2DTIz7+0y9KKC8DOO\n20sWL/j+mHb+a0E3X0dmw2VkJw0AH/k2lruXqk91nvmd4GyPmqBpUTid8A3g\npNOCHgD6koQPIqsrhgsjItpaXdLT6UESHtR99EEu3bGHv3M9nU9klbsyZrkK\nHNG1Rav2wnbVBT8OlGEvtRK8ANrPnf6ZArBWmK74ZqE+C5Qrx1AFI1T3N7rq\nATLe9ntmiMVK2fdY16gF+EtCbd0z9MYou1pUMxzQA1YOj/yDyW8KyoQhyUoz\nOwab9uYN/DmYqaehcG0IoXpKF2XdzZgERAh36c3PM7DcpFjFq70V70fdafUe\nACLz01DNwDQPmzEeuEg5SxVG7Gu7ChxudTG+FETZbqcLnNUECRcDHMQInNnN\nVn2pn4AXBIQ50TEC7OKXH8wrPzDaS9dJlp4Mppv80MW7B0CHNUaM8KA65Hnk\nZ6/6YHWexi0urVvZm3/HmzoB7cJ1Fk5eYieHRS7a4Q9jSEpt+1wFzBApKIv7\nSTMWG+K0180M0wnnvPCuVLKddo40iNRcrqF5RxgzeTh8OhXozabGijxpG7gq\n7SeJ8SnmsNehDPvWvfsA5BVucrudJmcNi/rhyFQYjVO00qvalI2zzZYvysAj\nCnrDKTWUz7KV0USTMW6Ug6YGzSfdu7tYBTxQswi4EsyNT/1OGwLKDZPOJG71\nWl90\r\n=59zd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-303cb2d-1622108078656_1622108142113_0.9087988317332734","host":"s3://npm-registry-packages"}},"1.1.0-canary-303cb2d-1622108080010":{"name":"@iadvize-oss/store","version":"1.1.0-canary-303cb2d-1622108080010","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-303cb2d-1622108080010","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b014bb7c8b2e213ffb52a580201a0a30540e88af","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-303cb2d-1622108080010.tgz","fileCount":7,"integrity":"sha512-9FZJE5SHbIMJq8G/+T4K15sJgByDmETjJKxj/qs/+CkWJJTR5T6lhgXJGwnHCLoqcQQAUTQlPYy8obUUGIGn6w==","signatures":[{"sig":"MEUCIQC3lnYnQrBr+RDvkqm9p+jx+hcDnBq5KjbIiToF8sYrLQIgPfwREHCUStIKHrNXDc0d2LqyCjMBnOflTOr/6ZmQ4lk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr2gACRA9TVsSAnZWagAAId4P/02OvxXRhvFhB02RpEgG\n9yvYU/iqgGvdKJA7Q545NkgbZS4P5YsTSYPRj8MErGOaj2Zj4qAK/8GOiIxB\nTo5ltBJEb8PZZryb8zeRcuAf6GXlMLLKhKPoTCpuRIOjeTscxSxszxx1e1pd\nterHkprb/O4jTHaOYQCup6qa/mMMIknijXiu0pRA1Ezthqq2BoeCYccSOGws\n3cXpD6EWo4pCGnpiS5gLsMqitpQLn0uY3zBdZ4dq84MqtTKwrA1yLHbzGoxe\nlKVq9RtV23yCEPaHdaYqbK/kDC3hQ2cYWWPXpKh1TcKGlAxnErP5U41xrb+j\njbLA7osJLbawQCcHFX/Rq6t8IUQf9Fm4oKVW9/DFfCjf0CjdmtikDI9yQK9N\nGZCCA/D3/UBa3LlZdxX0sk4q3i2kg3KJBOX5LxUXki4HvtlDql/K4gbdf5Sw\nu+o1VytHOqYhDIyXQ+ERc4I0wQAuqhYWCkwY1pTIzN9GAHcaK/uY4IPghvet\nkp9vjPbLiDwIIQyO4ir8QnSB3zQTS6QYYKtpKHDV+2oQL8sD7I2vQr30qtEi\noOEpZlEWNzZ4G7ZzXexyAa+gLnBsmIS5JeO5YphbZ+1JqSXib593rRbtBSHj\nl8e4WXtRXvKu9RD+2hQrBWgjR9LvEsPgqFZ0KVl6/IVrfJq0Lf2bV0bKQ2H5\nbspI\r\n=lkma\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-303cb2d-1622108080010_1622108160166_0.5969658043228938","host":"s3://npm-registry-packages"}},"1.1.0-canary-5c726ff-1622114876095":{"name":"@iadvize-oss/store","version":"1.1.0-canary-5c726ff-1622114876095","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-5c726ff-1622114876095","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a28094f429647d08d1a5e74704dbff5d242e8b9a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-5c726ff-1622114876095.tgz","fileCount":7,"integrity":"sha512-qdPHPOmTIJAGXnpyZ7fpMtqhJbQRJcMbmGBVvUy4nrMrUHw2hokS6mUN9Xq9e/QoULF8FyCTD0rp04Misfexxw==","signatures":[{"sig":"MEUCICoZRo+6MB7/BQM/wdudTe9kLhcaQabV/6x/mkegV66xAiEAyZO/UiFEpWVMrHXrwlTGNNn7c0hXNu6Yn+jisCCUzQw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr4JqCRA9TVsSAnZWagAA+uYP/3TbQVRQMNH0sbZZqdl4\npIGgSW0FAbpwd/Ucj2KrKhOd9f1tPxIIfAYFUU5fbZ/tKBi9NVvHXOn73rQ+\nFmZNq8S1UFSjh9bGCKLGxjJjhFRFgs9jzjJ9KlBut0ovLaMjmisu9fl5TT9r\n0Pdjx9iVR6VjjuRBaRWgsNlhEGReT+l7UZDBGwS5+lOz/GYeYapnLDdVP5FO\nFOxw+QC6Dy8/BIfH7cDXHUSX/d8KMX3vyHFiO9EQq153yj5XclZve+dv5m3r\nZhzf6UX8iW3VA/x2hQ0iqeB2PlYeUt0rSob1slZVm3MrTzHHsCVjCQlOT3rD\nIM0uyGdtcD0X0m2FrysMSa+PlIfE1MYdTbm6n4LMUf1Qe4DTnKn1/DB006S2\n+mzfTDOw7Fu5NfoPwATgcv2zoKF+Jn5SiOw7pzjWP/1An8y1Gu9CD+WQen+f\n6txpfxeIlV99sQ9O0NipIXRxG/rdUyUeSZi3Ga55FXtBO9QI4YPAZnvd0OAn\nIwsVfjzY8KwTzgTT1mjqrwSVUsS6EPkBxdY+kW206yJNz+NwpZkR6X3mSggP\nAvtpZsW00RPl5wHIAG2uWQZ52tsJGy3eRD7gx15nMhTxLE4SNjO22nddySXg\njW/NebXoXVYRHueGqUpEAIpHkI7PDZdwqAOouUnphStDoF3mimXTp0aDBKgy\nRPKj\r\n=3DzJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.2","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-5c726ff-1622114876095_1622114921492_0.8473625519269885","host":"s3://npm-registry-packages"}},"1.1.0-canary-bcf2d00-1622194813454":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bcf2d00-1622194813454","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bcf2d00-1622194813454","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"314cbaa7266c40a273afbdd101f66443b675bd13","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bcf2d00-1622194813454.tgz","fileCount":7,"integrity":"sha512-HkEODszV+kwAdv0D/EJqKhXkzVspetGuNYMbH/L1XueVYKGqcgMQBHXavjzES4KpdArXORt8oyn1//Ncn+cumw==","signatures":[{"sig":"MEUCIEfBSVBDG2C54NrlQKS1v4wrBKFArMxAgPspQ3wgp4fwAiEArajRlRi8/a9YJKNfriSToICfAEJ6VTkXpHuEok6vhas=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsLq+CRA9TVsSAnZWagAABtkP/0x2EUbSGV5E5tZUmXNR\n3esnysJxrUGwNMlBewTYrEWC6mYgLzxofdttaK5pOcdSLWa+WCeEYnniwdJs\n/5J6/Q0uW/3eXDcRPFzzUElNbgCzTBdMYH91i9YaWk2Pj4T8gYQAQ0F6Ng3w\n0i/syr3iRQ4KLmytwsvVliipv7sNiXXQ0eWaK02THc+VldUAPJ3Tf4g08oiU\nX1lHA2eUpUo9eA/FAK47+KunJH02mY5xIz1zBcXmIqYMRuNAcdNHnMMFO7P+\nx0g1LvBYnAcNy19/HHpyld1z4ikvmdanjt5cM7n/qZ4/sf0iV9Wz9gw4fYgD\nNr6W+3oLPdKkFAjRkqDsDSl0FvIqk6CYe+14svkIAc9JLFiU8safUN7DM0j2\n1cZ1DLPu0yfaGvSvCl4sg6n4eTBsUZdBdtS5lxtkMMr2ys4Zb+dBCUoK/LF7\n1YfX2VB0ORGFO78cDm0KO7vruLfd6/bEvkWIGaoqGR4nATh+BvfhieLU2mvR\nHJsMpNQT4rFYP3ZXofKe64ye5VtwxFP0di2T9RZWuUQXNlyn2nX3Rx0buL9J\nXXk0tK48+UGtHnhy10DxOCO1HHxnySxDNrzBDFnQkDIPBfyL+iVmiM/HwVuF\nh5g7mZhzIpjk/qOZLLRyDISV7VWVP1lWNiS8XhrrY71/e2vwTF5g06yQ3H6F\nN5Ew\r\n=uR7v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bcf2d00-1622194813454_1622194878171_0.6461002600675674","host":"s3://npm-registry-packages"}},"1.1.0-canary-bcf2d00-1622194813217":{"name":"@iadvize-oss/store","version":"1.1.0-canary-bcf2d00-1622194813217","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-bcf2d00-1622194813217","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"be3c0cdc239a89dc04423fc6e4afe88a1111c6be","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-bcf2d00-1622194813217.tgz","fileCount":7,"integrity":"sha512-UaVdqPlaCupmq1oqlhjT5GOLmT1WoBaEnPp9JpbOU7pPZJ3c4hMmClv/FdG1s/9jZKo6xB957mYn1f2O6d/65Q==","signatures":[{"sig":"MEQCIBfUrCkYeggJU72BtkBRhhZr607tSJuESvMwD+336A8DAiAoXZNBAuUqFW9Xwgrv4jvIR7I5D2B61oI7ECTS3Grn5Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsLr4CRA9TVsSAnZWagAAYUMP/2MkoYkMuWzRsXPIWdVd\nGUEQTNCEF3+uqaRiEP4/hN1GhUOefvno01rMVP/PEmoi5v5fGqEi50kn2Sb1\nNKiHWqzkHARvC2ZkwdyuVndnqh3kUMoyLEiwNIwiIG80jMriCoDAcJsNFQcM\n2chhbRoeYUlnw4NyszKHoC3kSaoy536fXs8gaHliahnKV5TcWlLnxIO4oXgK\nm125AuGVOyL6SL9r5cQx6p0au8E9y6SXRoM9PbhjTm6ApXqaZrK0M1yasCDs\nCMg3kPgPgefcMiVyy9SJGs4YCkkaBkqM+N8el+5i2OND/Ybz9pDq+hh6+nH+\naoymXkN47K0rag0gtdj7/LhKmKFc+KGW/LysamMafhEBPlGnLXbFm9SWsQmd\nIofBXIqiE/h43FH8f43ELBZ8ycsMoLkpHBYX5UfavKprhRKnWPDKHbg3e2Fa\nblXEqOnp3n8lQ7MJe7iDVowBEJdUo8AHevgqdmA7n3U05A8XdM1J9uH6kj3d\n7a6f7wUqVd5/UdyTVQ8dont2ZDCjydE8DLFPtY5z8OCA7dJ3CparczHdPwfW\n41sTde2pVizjEkbWcltpOK9QAN9VAsZewqHgQ66vA0CX02I5nu0f3nAscgj1\nY3oHHxAXR4ET8rIzUVK1dDhAnH8pP8y2Rqpu66eSEvAoQUjAm5c/F3TpDImL\nVeCb\r\n=CeIG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.0","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-bcf2d00-1622194813217_1622194935930_0.3504781187599193","host":"s3://npm-registry-packages"}},"1.1.0-canary-08d7c87-1622203140498":{"name":"@iadvize-oss/store","version":"1.1.0-canary-08d7c87-1622203140498","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-08d7c87-1622203140498","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5c1d950f1967a5916f23b1862feb1e4b43f2660d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-08d7c87-1622203140498.tgz","fileCount":7,"integrity":"sha512-7dJyKysxLm4jYWdFwh9SduRNrIMsfjglrpafCzAfw9LkwvMaM413oLg0V+xTGPnHu23ybRqf3o69RyqQwsTRYQ==","signatures":[{"sig":"MEUCIF22Dj22QaZzLWNwc5j/hXxvf+tOQOKbtYP7OLSXnnXYAiEAkeMB3CVt3khchh4TCn0ycRyHRYO97+94kJjvdVGk5Qo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsNsxCRA9TVsSAnZWagAAg1EP/Rgipc0TmVWZyiyrVaKW\nqmN6JL7dbViXiYA2P4J3KuD+Co4MK85q5RPGgUvbknze7BH1xMYj64AJcvQT\nkaoJ99gASdUX5z+UUD5HDJeip+YlQVJz4X9oa6mTFJ9ofFWeu7DF5CNVA+41\nN60bxp8QF0auLS0PO/AvyKZbd0PdA48y87WbcMnyTYOFQsy6Y/a21wII1m19\nLsvNJM4+EtfCipN2Dt96w1rlnYSH5gg23B5yjSJwgTOBRa5WAyfCV9QvvQ0E\neLZMrKRiDlbBYhq6s/qJGNLGB7wUUvS7Ax+mJE6gETjsCV8hlz8DXdqrqtc6\ncVOF0GZAHhWQ9UNuNcykRBxkuxUDMEBuODHfo8TCSgwE6Xr6FztqqfmMeTMs\nrnYCp12Pt1/Kf8Z8srV+sp14yt10I640JnVLQDzRBoNUds9yHJRs8mBwNZUd\ng3W1h0VCWD/kBOQaJfTRCwE3Nyh2vzgOv/B3kbEt4LiOaJPhMOJgbdTX71Ov\nFaKUaAHF9CNSMExp31VUkU9hrIm61Gyjg8bhbkritkvCt76lQJtiCavix0nM\nq+7FuXLWWj/XuqXxA2PvRjp/7SrKdI2Wx/fGUiq2PDcd8c7YFEDLU1zPwFzl\nEdZ8e0v7GVwT9+ro7QyDYGo1l2+R8DwQNvQW65f0Ht2QQyqKJ/7mDZTrdlQ2\nOGsa\r\n=ItZJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.1","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-08d7c87-1622203140498_1622203185329_0.2997141681517015","host":"s3://npm-registry-packages"}},"1.1.0-canary-0744e13-1622207966846":{"name":"@iadvize-oss/store","version":"1.1.0-canary-0744e13-1622207966846","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-0744e13-1622207966846","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a1a9654b4bf3e5c6f9ed5918450c934fef4a3322","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-0744e13-1622207966846.tgz","fileCount":7,"integrity":"sha512-xrK1Ka4hSaKZGLABcirQbzhH+a8RUfxYQYwsY3IA7Yxite4dajTLcj70H5QZjMhFOvdKnlz4yVM2viGLY5giOQ==","signatures":[{"sig":"MEQCIG3Joo1avUNRqgRPgWoTR0s+lbD87rktZLDHWoWV6WdpAiBxLfqdkjTyvp++prk02VQCrkAN9y/Rb48GieAVz3iihA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsO4RCRA9TVsSAnZWagAAplgP/Rl/Jo3Egz3kjWwcVO65\nBqFPqwuwNK8K5N4jV2Mqg5B3fxjKIFWjwULzhEedIf0FdEb1aqsF4lf9RD0t\nAUMaZH3oAGR27raJhhOjKNMJPRtJzqEC/Ma1GbnZSPExyFsa3FCUv6t1GsBd\nPsnZw9s6uNAZFtkaV2se1Ozlzow7aVAoZMs5pNRe6gQ/XrxGH18kLqFfyOSz\nf66LvwpD51q25EbDsAphA7bE1Eb6166sIyDXwGNRnFiLecsKe0Ap4PCzJ59u\nuJGSW7LhvmmNdPbN5cWT3BrLSEU7FfR19VSo2M6NsWi8Q2EEehBPE9+VxDda\nC+BBvSKy00mkG7sNER217EEeZAybG0VvSA2aCJkRA9+K5KZablm8s22HGJcp\nipMLU0ZKNMfNqQj9cEmQa4yD1sqNyMb52sr0fqHfFLqpZPrON5ALaRhCplnR\nzYEKxPyu9BL1jIHBl7xayAetoVuwHR5gKa1iN8FTntrcDQ6MjP8JMTRrKt7e\ndhLr/FPQ+chlbWaRksPvrMvW2BCX1T+7DBr+1b+QdhZz7AxGliY367JXjVxa\ngwlHLbx0Afk/70cJgOHxwvw1BEo+KWiMNFBQkL5PY09rlLGdaAaGUJgKJyCu\nNGys/w919Avi9jSAjU345ucXUBx3kxMsSwFPFOC9Es+gyVRBEnCeXxgICZR8\nVy8e\r\n=nNor\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-0744e13-1622207966846_1622208016513_0.7956919121910866","host":"s3://npm-registry-packages"}},"1.1.0-canary-b6301ee-1622263942276":{"name":"@iadvize-oss/store","version":"1.1.0-canary-b6301ee-1622263942276","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-b6301ee-1622263942276","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f70844c61d9447961739ec1087497bfe23ff865f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-b6301ee-1622263942276.tgz","fileCount":7,"integrity":"sha512-mKA+Zo4fcXs+Mqz9DBOI5oe5IuNaDQmxyrr+sAHmIjk6gFn73LyS1t02nnNAuYxXuxK1yySzll/QiyNlb2Z+zQ==","signatures":[{"sig":"MEQCIAT3RxsACqk/VdrUkfr9Pt0ZG3ObPf9yKcpidwBTFNZ0AiAS61buMV9C2xU98wjCvzI/lH1VVhQgkwVJzeLs1KnEtQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgscjACRA9TVsSAnZWagAAQ8IQAJ3qSt7vZieVkI7cmq7L\nT8Tgg/oi8QkMsn6SMUNCVcRVt8pilgxoKlmMZRiUlup4wMBkosf3wrj5mBGf\nrY1Jl7xZK7gMMHhpWoNZEE0W+VUhFfFmKPRToUCyK/ycnTPILGnVRUjwzyj5\nR0NX43bLUIsFCoZGuR910LFA79rYghzmNwwLjX61g2XCIGhfYIOqD20MmY7u\nUPiq6jZiDsHQ+e963GSU+LQe7iXFB+LIgPnxepGNlrQ+Vnqtpwpe1RG+TRdS\nyupe0ki4mzxsK4oyvMqhkeuCo9hWh4i7kPA+Ioe+WuZXymJP79ngFvvNgGPS\nAE7LJpBqmFNyVOMA2Y6Ke3e2Ch2tHLXzziB/yqecsoiWAVd2vjyjGD4w+6Ul\nFNxTH0K8pEGsaTvdcWOiV13zF+AgctdthEtB2b7rfLNBIUNdbgoenbOvugkw\ntxzQzLcGT08n6K72C1IxCAKerfyG2czT7lfoVfHfhqkbGtHlg6i1KrCB/84f\nk71AaoUWyYQthn19oS7zDW44oAFtZ/YJIQP9EuyEFxTxEixy7B3j1XHZhAhm\nSqkHwWrGIPhuay3Wxws2+SgCF8Dq/oUkkf2AzAlF6dNvPjaXv6ih1OxzNL+7\ndWvHWd2i6Gp04VKuYsQAlO2L79g6+yjKANbgkaJ7XrLErwmpgyQ5DDVUCyo9\ns0Nl\r\n=zA59\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.4","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-b6301ee-1622263942276_1622264000302_0.8838286093525924","host":"s3://npm-registry-packages"}},"1.1.0-canary-509db69-1622292626104":{"name":"@iadvize-oss/store","version":"1.1.0-canary-509db69-1622292626104","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-509db69-1622292626104","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c88ac8f74c73813f8b2528a9e26f02998561f1ae","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-509db69-1622292626104.tgz","fileCount":7,"integrity":"sha512-8vi1EC0FvtSSIIRa9+E3tE+qIUMLgeMVpuCcCCFs99khTX9fdqHCq7u9BlKJGEximbN/xCMkPD6oChIyz8m2og==","signatures":[{"sig":"MEYCIQCBawxgufUSXZZBwfFu4f8dKHAd09M39WRSwTNvMCSn+AIhAMJN1+km87HmNmVtNNFV2VxKPZtF4OSgK1hYplSPBrXp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsji3CRA9TVsSAnZWagAAPHoP/RIXhtI85HXk2oMzBvy8\nnly9rqSPqePQBTGje5yocs94E7EAdgD0GtjmZyke70XBxJaOw97k7b7Xz/rr\ntfNd9hCKTPMGMTpcB1/aqFP8VNycmk4pUsIbqppzs74xZ5mVU0MHMuFAW2QP\nhSe5CpNtr7A7xpJICpJOZ2i3QhNYQ2SqBUnlvqJ20V0E0XTi1i6ToohQg19O\nr+onU9lnNx+BQw/gdMlOGfQgkK3z4RrJs644Bw5xRhWahTfnW6UpNnuJYyQq\n2khdbjdSQ18lnbdm8NZwnqCLPvHQwiHqgQ1UmgDcMYiVrUw7cr69GCn7FBph\nOYVFV22ihILWuEM+eEaB8/THQA3NEQ58S+ZQ75l2AXNA3CC6Nw60PuiR4uF2\n06gaR9C0mrn4nAo33woZ947E9k3zsEDyOih9HuktJpQ4m9g+tq1iVCLz6Xsb\nPvSbzBezcyIcGaHoYjmulNU+v6NQmD7AFibY6jUWKzYy3SKALgZ6GHEJ12bx\n9YZ9wO8SoPjvfwSQYsFdJ/Kp8PUj0NjQW+Hkikvh4IeYGWrzc5o19GzMY2/d\nNoKMchgKW7EBtg/HwUTMclWJV6HNPz3cO6cPNW6eMiausyUHQZXfL36HkXiC\nvr+5Cu0ajWmGSCp5DLijx0eudeePfY/I4kiMNk76OVh/1o4E7oajKGOBB/JG\nxrVD\r\n=PXMT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.2","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-509db69-1622292626104_1622292663363_0.6782339671498032","host":"s3://npm-registry-packages"}},"1.1.0-canary-509db69-1622292625339":{"name":"@iadvize-oss/store","version":"1.1.0-canary-509db69-1622292625339","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-509db69-1622292625339","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c7815ad2dbb594374713197dadbc3a4fcded4d5e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-509db69-1622292625339.tgz","fileCount":7,"integrity":"sha512-u7b8XuJmTLCzwszEXd83scQYUukeaYdz4zVUwsHYH6uD+9ZwvGCNAVv1X0CPxRIyyJH3zDi6szFPcHTyZJ5+sw==","signatures":[{"sig":"MEQCIDGbejeuvZYRCKUQ4yAAbdWu35B5ZdY6PvgBdAC9jfzfAiBcbpRkt0kQ/W3YAZ93nc+vCCVW6Kp2PMjKR3wCk+mhmg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsjjBCRA9TVsSAnZWagAArXsP+wc5pQRGRuMikZQ0wURO\n1A7fSMgRQRGriDMT/ZhTtMierIh4M9ZSHvj+IihZsp3OO3VZy/sbMfXPATpb\npG2y5xqHQLuC/pGbaeOJjTIsW5Iw0D66deQb4w0W26qZmTTgmmSu77VLy3c0\n/h27UaTCmRSkcwEqYV9o1u9DUcrhU+AZLpfLpXMYFpgwitgiywzxHkw2jM1N\nHIEvUh+1N4eezQXqkoiJpIIseL8RlD7IuoRvU1RTTQtupkyurkfc+GKBcS7c\n/PDNjDsio1L7XEy1y7WcZMOLQjqKJz9ODUWztwUcJDay41piyiNdgVUZNlKG\ni+hOIFrCxu6+XHykOo/7ouE4F2fBKlbBS+wIoytq6ZMiPRuogbEGLIOS4LDl\n/q1zJHDT7uZ9zv66PxsFX0Ayg1q7Mcs68PZ/uiaqNUwqEv/E47s4nAcUymX2\n/FO2fb/gyF5ZofRbH4O1nFX0iAOSdeMWmLBhbHCmmvP1Oo2v63wjavvlvNIh\nQuapKEt1kA7a/sBeP1kDM2v+gUK9LUtJ/qNPHzE4JlaFCkSbrmpl62QZbmuE\n3WtMy7VzlF1C8XRlwXEcJEplLUDZforjPGzfiKcoAxsPodmPDnBFvxBU/u+r\ne5fkUZRRASsrMC9Y2EG/l/7QlJoyt2Zq7WXke9x7WZ2Y83gzhH5Uy3GAUdfv\nyCVC\r\n=F4fU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.2","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-509db69-1622292625339_1622292672601_0.2848352778677776","host":"s3://npm-registry-packages"}},"1.1.0-canary-1593446-1622312698390":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1593446-1622312698390","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1593446-1622312698390","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2554a50659e3499bc934e3465bfff1e4917fdc84","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1593446-1622312698390.tgz","fileCount":7,"integrity":"sha512-mzK44F6WB/LVr5r+ku9TIHcjNQ5bjfAanZ5oBN5OCn3U/lzFjaT89ddH+bXqFXk7oE27gdHtXod+xjASLedCIg==","signatures":[{"sig":"MEQCIDwk2ohZ+Y30rGPV7jVqakKDX+pbObAWVpuboR/nvtFyAiBJOKmCRxkpg9g3qcNvydgqs6tlJ/pZDaJbtuJ8IWwv+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsoc0CRA9TVsSAnZWagAAxCUP/1dEZSuFL8gua954eMMP\nXv7neHnnk9ofY6XdwR8hCVVkz8YhWzUVuNQhdX8M35KCK0PLp5NesqNK7Oe/\nZg+X7Ok4osUCpSpCLA8xqMnswHhoOtF0OIvsJI6dfre477ce4afsYfCKRKvU\nVy1Tx8zyoIt6+Hwmbsdp2m77q1CoPU80XcrPQk7Ha7DUcXwQtkmEqTDm5Ud4\nSHgJUIq3TS1ZYdvtJF49xRG7ObycJ7/4wYZyRUrZZRSTxWApEBS3j2aM4AjI\nve5tB7XpiITzSHLwTG92n50w7vZjx4iW88sqQQ7Scke+bSwMgy6R6cqriZq8\ntPsKPq21pens2QaA4YJbUHjdxUIF9uIPgIBLBMrIfeyzZpcDaqdR+2WZAm7X\n0qgh2haTPPPO2ZW3pDY1l79eWCMOaUVIWw2j4u+IJaq2/l75shKq9jrCZDFp\nM7d3v/fYmlaub0OsCJATaiXwPUJKNIekVR27PYXEZXp6SKruRZ8+jqCPL+ZC\ncIsVrRksa8lqH+yzWHrhqqPGkvSmO/8kKH5PefX7Mx3lssnbJZELLPU1jgiy\nH91+fJ3tbgpSgC47thr4Ra9SzoBPWrPjLJ0XFWBCdgAFnKGSjuDxpMtsT5S6\n2vXFoxXXZLUXM0d3NnnoRYzRKnpKy2V8pCIhzllv/FciRiqjEkc2/K+i9Qzw\n/2dv\r\n=KG/3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1593446-1622312698390_1622312755692_0.2013830224848816","host":"s3://npm-registry-packages"}},"1.1.0-canary-1593446-1622312698242":{"name":"@iadvize-oss/store","version":"1.1.0-canary-1593446-1622312698242","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-1593446-1622312698242","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e84f9a33dc89d6ef36b397860ff7506225d3455b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-1593446-1622312698242.tgz","fileCount":7,"integrity":"sha512-3QMEGrvgVJ5XnXXoaGgDXgagLoggz6/1cRw1NkjmlVhAXsZZHOABzXj+3SvPZ++AjTlCt99JvgiBGfZlqzlaOg==","signatures":[{"sig":"MEUCIQDHE4JFHFN2OYe3QFuFWvRlqn5lkRiEfcHWBMoSKO/powIgFEDoxBf6GCV2YN4RCs7F2XU7zenZExII/Q1Y/fBZTjQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsoc6CRA9TVsSAnZWagAA5I4QAJBDmlCNOVJPDYxmx+Dy\nbh4LhlwILq0zspXW0Ba8x4mFYrPC/YHPckwcXl6sZDZfopZv3EllNBRLV9a0\nUHKf5kRCePpiKGbWGj/73lS/CJ6JyQjuVcAtLTkDkQg4ygxUHu8YbE+oG2Xz\nBY8P1VSqeCOTrhhBv8D0JsigDOSgvwbvyBAyV0sX5YibUQFjCiZRuqytxxqQ\nmyZMuniv0Zt/D6AAy7TUbpwRsWeeO93OFlaHjLLBhJ7Rb5ap5aMeba+iLJLh\nQXL5oXz/pg9UogBNhuXmsve9J3vPtyAzucq4c1/3FiDS8StDZj9nN4/AfADy\nCyBM3Jd4avNXXxzpF0wIyPS7KQW9a7unEcbrfOt5y0Jeta6KmI45VExDXAka\nRn9Pc8EkJZkCNmlMbxgkjvImqWEiCHHRkA1CVTy/BGd1CJU1pVwhW+/wEU09\nxF/jWvBhjnaCHnQHDGL7W3/Gw0CwauYqzgG5rDROx1U7sb7gvvFwG9nYN5xR\nG7jpq98Q4E7yDoD2SXy9hm5U9K2tmcyWLAKs1Iftobl7RmYd8/OyXvjF96Vw\n/MIZd+d+B0QXOWHjmbI+dOd7HUzvuOz0ECn/tcD4zDnOd7K2fwYs5B4NsynA\n7i5KQEnMMU1HcD0DeBzDZeSLex05sLAWMy9EdXFeFaiuUIqGZOzny5gHuRVL\n0Nkg\r\n=nooj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.3","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-1593446-1622312698242_1622312761559_0.17635238458791846","host":"s3://npm-registry-packages"}},"1.1.0-canary-78fd972-1622401311660":{"name":"@iadvize-oss/store","version":"1.1.0-canary-78fd972-1622401311660","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-78fd972-1622401311660","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2c8ab0f862cf0c5ebeb77979e9acf0fc1c30a1ed","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-78fd972-1622401311660.tgz","fileCount":7,"integrity":"sha512-c4jSadZ26CGjltO3XBvTSwO+VEqgnI4GL3A9UCWMpQFdg5sDjBcVKBQ7GCinf+BXTFUyLLCon5X2hHV9SXFSQQ==","signatures":[{"sig":"MEYCIQDIam4KUeqpnNYn6YtaI7JEU//GG1IjMkmRhEP0fGKxpAIhAI78h2LXbg4MaEm37NcRjARVdQ2AgFEkgwDdmDd7nOQk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgs+FTCRA9TVsSAnZWagAAM4MP/RZ+C1401ByIuSvF2ujK\nbjdSJm9QbUypX/xe3vfsJ/DU2xwTUzuTaMRjbVx8MJhgnSlzYnQw+gK+Z+j7\njOpgKG9vckExb7U3pfPF0FmEcS1wwj7ezMxQl5Nhyze38nwmuNmkNig+x8Wz\n+KH7s7grG0XmjN/ROx8d8PsO62Lq5D3x1Us3svLqhTi4HzldxIwn/NQpayye\nPQKdsHUrhV1Fw/yQIKi1nhQG6LXuP/rpyAhLercqyWuEK2lh0WpdfKr4L8iB\nF/ga9neDqTMcIaDAemjZnHqbTng8lAVJPI1RUp2+DPsiIpFexokk532fChxM\nN+lB4H9LqfOJIMhSuYLBMc9NjMdN3x7tavRJjiE66IrXk7QgwDtdHfo6b4yV\n5mA6AObh+MIKJwlZYGsHkXaLszMWVZJV494hA2MYmh7HiQxArYdlz0Vuh44H\nY80lbNMDzLMvTcz7ljEM27ox4l0ZLNDSOa1sMG8aadhuynDaKiX1DZRw/a9O\n/kiWTHONgiU4BHuT0O4jJvIKUPjdlNs7vWnQ8TZKFfGCCm2JhrMb+oL+nJ3a\nq8kKB4bsGvgq316hUvGwJtYh0VIMmfbfYFEtct+wMeHHeZ/F3due35odlqsp\n4LQiQb3G96yMQ90x98GDHOJu1felLJDURqLEmVLAcfVA1Al5AFtv5GvQ2W2s\nSNLv\r\n=u9l5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-78fd972-1622401311660_1622401362449_0.5042807287126418","host":"s3://npm-registry-packages"}},"1.1.0-canary-78fd972-1622401312782":{"name":"@iadvize-oss/store","version":"1.1.0-canary-78fd972-1622401312782","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-78fd972-1622401312782","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"da93b9a38c5ee02a210ea1759c201a52cb622cdb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-78fd972-1622401312782.tgz","fileCount":7,"integrity":"sha512-CCGH8c3hRWEwGomcKO00yn6Yzmr48+ZuWoDGzYwmYAaOJp8obTniwaQTOA+efSrho6oe10xxKCQddEruV9Ranw==","signatures":[{"sig":"MEQCIFSqUkgzk7ACIQ0w5ADrh2UnC9UNpzGuaCLTqZafrz3qAiBnIcW4zrQCVbevSYXKXVpqRs7lYNFgdLi7DX8W+5GZ8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgs+FaCRA9TVsSAnZWagAAAcoP/2TdfBxEEE7d7+OYsSWD\n61feHRUyqoLrxKi+3WS5+VKwouj0mg8w29qHgDcokJjYZpF2y+0vJOadTbh7\npz7Q/nfKmWk5dlb4uBM6oU6iSJMQxn0WSGDeKAmRPCKmsruVx/e+Sb1j3QcR\n80YQogzufhxoiWwx98MSdpRrlYaVNRKXPZN25qOke1+7UzNg9fRgFWXK1/SJ\nUHBNiAhteDCYQ1flrIWGU+FQY9r7L/Fg6nYBR7mSeK4Qat+XNw0UFEvs5Ade\nBRzgakNfALVE1nPfW+UC6SJ6dMmDeGMrSr16M9Y4JcfbmQp6Jg+rYEyKYcOK\ng9MrBVz0UShcedtT9Bieb+WvZ/DLRi7E3sQmjdIQ1Jccj/CAV2RMQqAz3/j+\nzQOZcbyN5n4aHC3k5efmj9kM+gUKrx7jyduuR6s6zwiKdi0P3VkACVYYEdD6\nwPobtLYYDDGsOwuATWOjderRTwF9a7lYp7vhm0BZswLzs8hwE1w6VuzJTYNp\ncuGOtWuws2AySO8pIHF9/Jhgvd+E2lojjDzcq55F1zMj+MIyPlf6Wkv4jKVT\ndJhnptFTNFtJz16rE7OL/Rf1GRk2hzeG+RFMEuN2YLfA3H9s96pwpFszbJtJ\nzMG3vfXXXu0NKdt1EUqHiHZNorsyZw79i4Ii1Ek1VFa6eoRLc3/S/9ZdNrPF\nEDgL\r\n=CoiP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-78fd972-1622401312782_1622401370035_0.41948476367590093","host":"s3://npm-registry-packages"}},"1.1.0-canary-395eec6-1622414493520":{"name":"@iadvize-oss/store","version":"1.1.0-canary-395eec6-1622414493520","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-395eec6-1622414493520","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"15973e602364bee4ce8048a22a500b005d8c6777","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-395eec6-1622414493520.tgz","fileCount":7,"integrity":"sha512-1TuYG6zn+XHeMhUQ4ISsaZunp+nWap3eFHKCWST/M6uwlUDPVZykFmQZBZ6tnI0KwU3NJBgmL/bWo3rPMXMZGQ==","signatures":[{"sig":"MEQCIDcwAL5Gpfh2qs7wtzcDl33QeBPVY+2lJoGCe8DIKUE9AiBhLIo1j8ahNhYMnnTqwOonIWTEyxTZswEWxW8KWA1iUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtBTPCRA9TVsSAnZWagAAO00QAJpD9LfeXNWMHzMkV2pa\nTE9DJvjY1q9JdDMCSzpD6hNsDLddbsJ89+hUncuhi5gVnGZIuJtPNy6y2goH\ntWNP1V6bcWD30GkQGkpqXtZXoCnBW7sew64Xs7/3nzs/EhAhYtwQUn3tFPa2\nyZF6m0+XLYzEDdXhTHL3ZiJMmstdwNXw2OrxbadyOWJB9NNjw2m3nUhG1Jzi\nDaOApuayZ3GLzds0sG2+DjCCJNwLh93is9CTHbmSMyGsLV6Z3gFmVd8pcswW\n7TmZ6i0xV6Gs2tAmNk9l3ntv16xxtGJfDtoYCqNoYYfty9gqAqEFi+mQhUca\nR5ZnCwV8nGQfrCsa/fiKGoZG+SpNuUtTqopySuVR/NlaLHLbHnp9T/XcFQ2Z\nLYxlX+aAG8wZ+6NEPv3ir/7Ayr0uA/tF82Eor87jdO91UvIvJR/xEVjv190c\n0yEijSN5ng5PlXJBOXzfOSd9lgFL6ZBeDdG2Rznq+JptDZ5UHUfmIlg+tuP0\n7pGyjGEpcteDjMq4oq/yOGcT+8gn+YmvYqolakT8z99ZJpWmTXupAwwReAd5\nUcZYKSGuIbRghnEmzQPN3j3+OL6WGkHbgVBa1Ff9/asoBKtzO29cTSygKPdi\nebJhnCxwDryiA3ut0mkBysTlJVySOteEP5CeilbU6BNv4IKsuWUirCurQmbv\n+5/9\r\n=meBw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^26.5.6","typedoc":"^0.20.36","typescript":"^4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-395eec6-1622414493520_1622414541722_0.9712627568026426","host":"s3://npm-registry-packages"}},"1.1.0-canary-3c5f93a-1622469711030":{"name":"@iadvize-oss/store","version":"1.1.0-canary-3c5f93a-1622469711030","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-3c5f93a-1622469711030","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"955526108ae244a55b6efce128d69800127c61c4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-3c5f93a-1622469711030.tgz","fileCount":7,"integrity":"sha512-jczKfII9FhrID4PSzsa/I2iPXBbBn74Snp2nTjcKLQ2yiLZHno0VgRE7lgaZPUhKOEHazsVqFVv/PHo3OTKxGA==","signatures":[{"sig":"MEUCIQDmBFUuZBLJ6t6ScfWq0wHzl8bZxcsC74v7hnJ0h728ogIgXc4b1dcdCPRawrUn8x+VxpWuD5aq6UMfpx5XlET9tXs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtOx8CRA9TVsSAnZWagAAsEQP/RFRB+1aqIuTbPGiMVab\nBcwBad9S5R4SI6IzKXaY2TXDEtKx+3eXT9G/yf+qnrq/xong5dWZf+LS7ysw\nU2KGNAE2AksYtbXbajT2Cdmoxrbt4kH9O4wB0ESk0XWz8UBfP/PjybQZohbw\nJSxv8VkBiPtU5R0/kEwEMSYid57eQe31HC5t32ByNvaaWAzQFPj/oxPsVjdC\nOgJIXQqzukIat5m8zq/X1tg8/uwRCd+duchsnGPCTv326a9cuS+Ydsgix2gJ\nMBZ32MpTfRAbFdtpgIxHEGFXfqtxWKMCyqnLWZtpfmOaA0JICbd2LSzYXsF/\nZdXYkbNtBoJCZ2cYIeHa5S35o3zHp6fH79N6QcQDUa0iRgASRvFMQVbiIxfV\ngEcwtP2FTiEarsMPUoWsSOBWFdGG9z4GcC7mKLlYa2tOHJoGbgjRpbiqldAg\nidzi2dolpYV4wxseaM31Yy0qPuxMBTOu/JSHuhaF5/qmMbq1iFr8Qp0GNXaa\nFz4HOtiQrvBf5K0OPZE1UfdClUY+yHOhEjDGy7leVBnxQ/S/LZ57aXCOUjdX\nA/mkuQhJ0YdVhdTYDPJAryqeIuLCUMVuxf+OxUrn+Kfq8oPf/BRju2dbqjTu\nqFITTXhDgMu+u/rvchLaglIzcjxyYb9sDMSYaZek08NJx5qDokO8XUxWSvUb\nd0lC\r\n=xmzr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.0","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-3c5f93a-1622469711030_1622469755567_0.5430001103025379","host":"s3://npm-registry-packages"}},"1.1.0-canary-3c5f93a-1622469714797":{"name":"@iadvize-oss/store","version":"1.1.0-canary-3c5f93a-1622469714797","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-3c5f93a-1622469714797","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6485e8b51e6f03c06222164e8d18b0c97bec3cbc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-3c5f93a-1622469714797.tgz","fileCount":7,"integrity":"sha512-bOQLtV2ZzzPjcztVH/mejK5KAVAFpjWJ3PCwDV/kUAqEV/hlnoyNAs4+RtK/ICPDKaMa4RlzHjnn8aao+UYVMQ==","signatures":[{"sig":"MEUCIHzqwOzfJggpuEQQnDMyjtvLtN25fTw7bUOg671x27r2AiEA1zH4kH1tXoRzA9gV0rWBlJjSJC2qUCtk8KpKvdc2om0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtOyGCRA9TVsSAnZWagAAa2QP/RpqxCOMujlbNFjeIOZ4\nDwlt5Syn06VAu0ouoVTIQYzIzETPm5p4ioqB90deX2ipxtehz1zJeiXZG5U+\nNrXfV9HvP0orqb3xJ7Kc3fg+3VlDqqRhif8xrgfmacuK3Ei3fM7J5tFs5qtF\nBAw+kAlCtSnEPRRNIDJIg05B5DuzwdssMPCKWFl3kv3Dt0X1B7EhZyurGjyd\nB14YmK7Tl4bmjXWedf/ZzkH+q2cs1uJmt4deWxN52eA56KAvmXwdSrK2kpQj\nMGmbV4PNE4/9ENOPSTB4e07mNpprvDMovZzfR+95UyHGyvVjpOaMu9kKE9Rw\n9wmAvwlMzQACg6U9kdLs6w8jfS4+Dv0ijyXIFO91mFnXPVkZHNWPcNjSpy1n\nutXin/FBMTFQEH+wTMEdSXkblXvwjKGZBuMWKCcHCPk9NzEUQOZ8rmzciQfs\nWrSpOfmTsicYjGuW4LU0zo1kOqIRhJk3Ei8y4EJBneoN/0iwkwnfTzVy+1G6\n37GF87uY+ut5UUSuD27LMn8Xv5a1p/UaAQOC44RekOa5FmqRPOM4Nwt+DFA4\nkr5AYlkn6IPu9lLwxXEws0zPOLt6r4btU6CL3YXWvPd4M4ZbdGkOdH+lvcOr\nDsErFoKJhntItm4KaHhEbNP0xMZqdw4P3mxdVwUXCnKRDH7S2znlnLPuNkAV\nXW6M\r\n=y+iG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.0","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-3c5f93a-1622469714797_1622469765733_0.2973420439933079","host":"s3://npm-registry-packages"}},"1.1.0-canary-3c5f93a-1622469718313":{"name":"@iadvize-oss/store","version":"1.1.0-canary-3c5f93a-1622469718313","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.0-canary-3c5f93a-1622469718313","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1fd285f5cddf793e392fcc4dc76dc6ac3fb11b9f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.0-canary-3c5f93a-1622469718313.tgz","fileCount":7,"integrity":"sha512-JY2hEA5qXr/BsT2jfY8Cf5NqzLnDiRMc7sfy+35Psd6jYvZ4TP13REqYbNGBtXFbXwaHRo/5wampWCNY1FyBbw==","signatures":[{"sig":"MEQCICIpEPkgpUxh+p8Y4nkV1OXGZQLEISiMZhFEcXvEV060AiAnJ5q8V2fQBLt//g14/TB51vw4da5+CtAt0Wq/4naFQw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtO1WCRA9TVsSAnZWagAAw7QQAJrIadNH6SeZovN7vHp1\nwGm7LBPDfJFqEbUlTmW4xBC+l6pDPYf2s16wJTQY//408k8osDLFmMOcaAIb\n7735BkG749Ep70iIpIT8lCcQftyNv8Hcx14sT3QN8nEj80ZPU1LArAYusSAP\nmjUSiO3RixwxBFdri290Qqnr94hgeCl6wWS8awXsPGctOcShePopqD9QruHF\nXtc2FGCFcw1GoG4exxSZUET8KvoB7bt1JYbmD0HslIyrZadoq3ofz0JC+2FN\nFbG2SPFRJbvgQcNZ6NqJ3qlI+pZ4pd94hZiEiQ1YPq01mf8R1+pAvaJE7vOI\nZ0JckRhuKLbEqqwNr5aml4PdAdMi3mM7pEfaQYHORbj71is0lVKL6FwFIJIR\ne00ZEM8/0PZ0G6Q3I+mPczm7LLyaBAOYJ3rNxaW2kcy6m3Yju4CsXRls10eu\nIZN/znQMcNLF7KUBDHaNL+eb2XRenIzChX9ztgB+veH+NrNwweuwUe/s3/X9\nkPdboezcDx5ljwEvmZUjqRvtNAdLPuhGlZs+0hY9pc7MDydlTSr2XafmcLw/\n5tQZJQGvObjIOuq8dQRAiJkNflGintojm18NK+06FC2kOQwaJU7QD4okODtR\nof5McMzVTYPJjRZB+N5uHO7N/D/fQ1Db/a5DmATUAw+ENilTDYGGL3xYlkQ+\nkr0G\r\n=SXZg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.0","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.0-canary-3c5f93a-1622469718313_1622469974528_0.34969801258038724","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"@iadvize-oss/store","version":"1.1.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"063e3fc8696de8d842e71dca5902deab8bca28a9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1.tgz","fileCount":7,"integrity":"sha512-e09X2uuBKUebIUjsBGX7qaMTzkemJPxZnqiMm9Rw4GuAOVOHSy3wK0JGY+gdyxeG1wMqQNSjGkk6BrfXTESu/w==","signatures":[{"sig":"MEYCIQDNlYQBOUNOEHiDZC7D0jY1Zyfbj9HlapbJOIB3Tzn/bQIhALi1i2sKF6PeJBh1trPonmR0NG99sT49AHufos0uuf4s","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16820,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtO5FCRA9TVsSAnZWagAACkcP/jatgf0JIMp5ECjL2L3a\ngQJvcADD7olXdh6sNZiYybkkXMJXjRGn7pSRLXCtdKHnLsBK8kdkynshEtvu\ntgKWc+W4U7QFN8I5JC6UYGV04PXCYPIsqVwoFC1M5L6fw8mh6QMsXhnz58nL\niuqW5z9ltfQzJIYqsXHMBGn20wCzH9pbkymoH8ik1UXtahuxxTH21qarfuLv\n/NUpGgHOr5sxBMuqNvjx4OQrw5WG8UD5gbgSg4J3tkKeQ2PmdM8GqfcaMYx+\n6P4l0Pxaro9fK0KvGdWCOsT1BgKMFH94zzkKzUCBWqiGTYRwh/xVX7DdtW+R\nPTMTI92rSdRPQE3oKLFbA45DvSXffqB+IpEb+YOh7TEgBNrWD0aIDU/XBmZp\nLAjOFupnUx/5qUctKvXfEiTwnKeckpaTXT3I8/oXKDdWxjz5pV7e8h3/j57R\nt1x9Z+U6YmLs9+M0OEoWlrSo5qW2dUz3wHtLK7lJe3htXu/Zv+AjhNCu6NgW\ny8spwdD9ATy35MysB0J/z/yUig3sqe/T1QtYHy80TPcWNe1lD6P3na2BgIvf\nNTG3L4AIFuHxur/mfBoASmgEzg4VbRtY8gCdCpQ6J3FV7xdvj0oeJH1Xj7ua\ngiN5wcZhuzAwr77klRWXX2mYIjYRZWPN95qLdB/0+MdKirG3OnzZ6X604fCS\nf7Ur\r\n=7Qeh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^27.0.0","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.0","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1_1622470212415_0.6685210390590712","host":"s3://npm-registry-packages"}},"1.1.1-canary-907357a-1622475026346":{"name":"@iadvize-oss/store","version":"1.1.1-canary-907357a-1622475026346","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-907357a-1622475026346","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4ef30967daaea20d925dc5f921e8cf0b1c112360","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-907357a-1622475026346.tgz","fileCount":7,"integrity":"sha512-HVhXRKro7WN3xPh/GcfZrYvMKGIqO3xCUHCqP3GnYf6APiu9/O+lvQRh48g5FjpWkVPKNB2DO+1tjUrolRJvzA==","signatures":[{"sig":"MEYCIQDtRaNrybBnC9004zXz3tQU0/5WK023HWkM5VgrsI5WSwIhAPwt46Vm0JczDWFk0AtEVs6ls4sqFNT30Fw8qF6sWXc1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtQFDCRA9TVsSAnZWagAA21cP/34E15JblcytUX8ANZvb\nt1lDf2mA5pMWLP609/DgD0qn5p9A2R77gXxxEKqWrCMOfdeOoqWrwt/uW3ed\n02dcsYyrrljDhihX42fmRXjLKXCncVWC44hXIYMA6Djlv+6k6QQMyn7pJGlG\ndc13k4eLdSPvBdw1PfFoE8V1C8DW+s0WxE9WCA3/FVGxrh99SjLl/qjGjQ8C\n7sSPsNpb39Jx+cHoKlut7od1ZWz3aD1kMhlDxmp81qbGC3EM8MMBNxFFMRfT\nSZMbgzwrYBDDGE2YW2Cf4H/ndZQHK0ceeD8U0ipwsywxVtdGw/ILaFjmVWoh\nBZZezHD5dwrfP4BDo45B7S/Qkbzsc2Ovk9v1F2sR9LCAeRh70cPMcohjSW1n\nJvqRbvdKzCtczikpZ2bZHTfDDwTu5T6jGI5bh2wQ0yoD79tJV7CXtd6FAnEh\nPlwL3onwVlLNTjgudJX5zisLYzJIXxxLkIWfaCok019RNPz9gvP/blgM21cb\n8jn3P5EnrQLyKuzGaTiQPxZ2SfP6TbLqnpHq0FeCPQZgHaxS08aMgBdGkM33\n7H3PYDwBtJF0DeSqQq/T5nR22rx6b32cAIAR8uBiGAV6QDAeFBoBKFqIxk8/\nEGriQsBt141PrCdPutNI/7m9J8of21KEFpmo3KJW6WsMHjfMAF8+teSnUW4z\n3Soo\r\n=Mv0d\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-907357a-1622475026346_1622475074729_0.32242477779523204","host":"s3://npm-registry-packages"}},"1.1.1-canary-79c9348-1622475046540":{"name":"@iadvize-oss/store","version":"1.1.1-canary-79c9348-1622475046540","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-79c9348-1622475046540","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8f2658b8d8364db13667378de15340f4b1905d7d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-79c9348-1622475046540.tgz","fileCount":7,"integrity":"sha512-qVJMixB2dNuCRQF77qC28qYFcq4LG3dH7iLJDcGlN9ta83D7b/cW9rzwnW0xvYQmX6yxD3g+/71B1hcoM8Z+Ug==","signatures":[{"sig":"MEUCIQCG00o9xyNYmRs8SbbXIkwCjoDOS6dJYq+LlmkHfaXbOAIgXkrSMWKWIiW7cgIcMBPsixILLM6VMqswsU2NDF71hmU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtQFcCRA9TVsSAnZWagAATq0P/jtMcT6tAUnYpXpUVBpf\n/1H+7ky4DYfEn0fZed4HxGXrA+HwyjJ0ubbzG3fYk8A9sayi987NRgegzjGH\nP5RlM4oUh2fENN2+KZ6V0RRYGofuYHJqPyI2xHdAUOOyK64Rw8H3pq+otj5P\n8V1MbqHv9J49auyfSO92fxk6FnRfD8s5JnytRvofnBbV59XIobjGAYU3aHvH\niEwIhzrKQsxMRNdXy+pcu9hwYSZE0pVF7Tb6cxOeNasCR1c6NqSWcrCfEHIe\niuKeUD6TI31ubeUTBjk2YZ4XOy2sAOM86ZVOBdfjPU4FnOsDeyXIiJDZ0uiZ\nXBtD9cipmJGRoUDzaPC0G1TxHD2EvKD+0iM6votUzaWTE8ZLNj9/1dfUaeqf\nyi6+qjvV1cVTAGDbgfTt7ktHp9MNyf1TVXClYfKWcCP0drtevEY4R2v5SSGC\nUQm0Cwidrqol2Bd7NsINpUNGtR6i+hEUTVvvZXvk72lpfkD5ql/05f1SfQkP\nqsw5p/BpOt2RwrYC/Hwx3Rmh+cBNq34LtouWKfpzma8TQ2Ujb7Dm/bf9+CtH\n5H5cOE6JYJiBlByat4GxyQNx0qmISHJvNNJ7phTtbY3bF+Y0c3fvctlgsuUV\niaNJxkEfttTzK2gxWUISPFuu9exvp03RukL7AN9pPKo5vpriITA6q/w7Qr54\nvzQa\r\n=nS60\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-79c9348-1622475046540_1622475099998_0.9159534361910049","host":"s3://npm-registry-packages"}},"1.1.1-canary-c6ed13b-1622499842501":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c6ed13b-1622499842501","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c6ed13b-1622499842501","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f9f0aeb50fbfcc13e942657a67b223de9120a7d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c6ed13b-1622499842501.tgz","fileCount":7,"integrity":"sha512-ZMnCKPawvuCjzyUlkAwFFVORviJDOpGT+C5LR6Y2dY4SS0vH4WIwnu1cMFPx+0aPqXDX30IxKC+sdKnWrn2bXA==","signatures":[{"sig":"MEUCIQC4NIpVRoPdg9om0goGkapTg5vgsb9C6Dut5sHLvAfVaQIgc69xy6IwGLAxRZPUnrzvHzNrbiigZoviIOnTcCVp60A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtWIvCRA9TVsSAnZWagAAHZUQAJWCZP0XxUnPvR1IoSxA\nz5xAanp4fD0AMcFWofcGVQ53nOTl9xydeNMStegR8W64QuJxK2DDGlBCSz5q\nT4YwQKztotoFhTZ+sV7ETL4TM0nOiWV5Z2BAs5irpM1+AmOhAc6idwMs7sUs\n72UQoDKlHy9PF1UuCLIQFdAHBr3Sd+ucF16VCsoetisScFrzXKiEQPb7epqc\nT8hrosqz0jBHvPazZcV0RYaM4LsYz16a2DLknCvnESfV0B1qA56E0n61OiGK\n2Rii8uhgbKgxJIFAUQ36Yer9RudQm49n4d8ZBvWAFvhDgpuBcACNGMg/xHK3\nJccwPThng3yq7YnlqkolcSOuo4vXqA9eZAtvrlc71ZxfzWS6tz0JXi7DlEM1\nzNr4bVbzKzpnokDtYRpPW+DZhymm4ySHndWVLrBbo1BmMmrFMfOarWiPeL3V\nwyCu6UnRxrR3jwzfjjpONlueF14t4G13oGbe1gaPZXFfXkP+9yvn6kf5vCl7\nh4p5wJcfo+ZudNnpY6F+v+DpeJGSUHtJMtlQ1gDYyvuoqETqSDG2oQViJBRj\nCiuDPHoFXvEmKAyHbEJkXgL24XOJH7ATJakXesmGyEL/JwupJDo7OThVfG+w\nv6IE8MZnUh7a/HpOLH5FCoS3MY0N5f1S2d3pkb/TBK0JeVLw6FZHnIurZ7q8\nhGMH\r\n=y8TN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c6ed13b-1622499842501_1622499887050_0.3501877453789892","host":"s3://npm-registry-packages"}},"1.1.1-canary-c6ed13b-1622499845898":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c6ed13b-1622499845898","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c6ed13b-1622499845898","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7a8c6b0e67e28c037f6a9ab78ec5aed2a8c7e6e2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c6ed13b-1622499845898.tgz","fileCount":7,"integrity":"sha512-Q/p+tIEdVIbwvQtRJSsunjPFWph12l7YGtZTecf7/v8BiBq5ZchicBAP7p1ahxrHLyjAm5TlO7fbauySUuaGFQ==","signatures":[{"sig":"MEQCIGfuFZaSdMqyxhXRbmV2kvUtFtv08bahtLgs0IbuQNpbAiAbsIJA6WzaRP32wDOnO83N+IFwdBPdd6vvFwVQsydGXg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtWI3CRA9TVsSAnZWagAAApAP+wUpcvLZLlbEca5iUy6W\n1q5fT78npNo1EoO/8ZUllBklu3yvL7TX3MxjJpEYoe62/Y0oIsVyq8HL+qFr\nqZFZBVl6UTr4QQ69jXkeeCfNrmIbIOz/Rg/RunHHj7qZ0JyDUBgHJ00U8SG/\nc9sjJAWl6E3rOC9aAVjgkbnJKuR3JJIUPcBQTNmuEtwoVaMsauE4CQRozV5z\nnoqzjnXNM2ifORTc6wTAHKXHprsiEJpJsCqUErawy5wUUs+qwH56ZN6cUqx+\nmldqIEkUMZBu3EX0uuD1k0hxGjmSr50G5gTJvp8bp0AmDnNm7Jw1tc+MRTBU\nNkMWyxkezczziIEywtKbPzzR/QMNeLH5tmTbtCCSk8Ha6YeMemRv9yjs7wky\nrQEOGKzTuQNKlo7YjgEE2Qxzo1trvPDH+V+Fl8D7axsddtaprHCfcqIf4VZr\nj0XvviYs2HjmYXbZToctcJrbWHWegYnz4naasoXtzJVJslsMVmcANliNclCt\ndAYBdBUwOfHvtExRs0u1/tAxpgdyb0yY/zZD0Wz72wsHqoHy71Zsis5l4sqa\njHnCCJmliEu7qyWJJSzG0WWnzRQLkJwI69upCGV0QFMUkDAk/VmOahRDXGVI\ngnYAT/4yR0e46GdyPIGtPCCiVtJRRdOVU6VQI75efw++wMmj35QL2KncwA8D\nuhkx\r\n=BzuT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c6ed13b-1622499845898_1622499893911_0.024819005515921422","host":"s3://npm-registry-packages"}},"1.1.1-canary-9479aff-1622538531622":{"name":"@iadvize-oss/store","version":"1.1.1-canary-9479aff-1622538531622","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-9479aff-1622538531622","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9b724f1f2464254b2e4b95c4efd18bd11dc5aa63","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-9479aff-1622538531622.tgz","fileCount":7,"integrity":"sha512-141kC9uiUq77BgsAHkvY/KrXBSgFL1x9fZkw6iEEaa4LZ629wZeYY8qbPZd1/VVLGPTrn1r8bSZH79PNuploRg==","signatures":[{"sig":"MEUCIQDHOncwK5o3NionW4hEDyybgRRsreQc8qbkG9Tv2+orQwIgE3rRzhKlr47pZZbuJkUuQcjSN1y5K2L9Nvx4io5jYnU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtflPCRA9TVsSAnZWagAAovgP/RYcjZ6NuCaftx332CHT\nDOCQjq/sORJMgiLdpdpwE6Kc9zuMkoXu9t0qRQ76UX8EQ4shL4lOsG2ndjLs\nKDpVuolPVHaUFKyFBMrShmCmZEpWFW/RP2Z9Y6FoBZazE41WSPtRzP4K6KS7\nfi0Bg4FvOS/NoQlaXbKDCOTahlumvQXcDyi7wGXB+6l8DZL67d/45FmkaW1A\nW3pDezKyO+aBzwSTdAvXC05kNGTqipMvu6YJdogu9czYBv94wGUGEOo3hrbs\n/2XZxE67kc54KI1TPRaUNdznqmLZq4RJ/msrHAzG1eFCDLCAL8pxgrzlRs/B\n080Vf/xAi4RTnLYDDJ3YNFFw55TInY9yp31/hGYLEjhWah6ek/gJV+EMVkpO\nlqXVqaTchr2EIWh4dZfHsyY1+IH8pol10vDhshj3mq8r+uPDsGrjli8gRDvw\nK+7NcNuZqxtTH1bE13hc/ZjgPtTr4t3nIFPlZVc8n99HELtXSR5+kRCzShfo\njOhDZavvCayq/x0s3TMjnPFU+tVGP3Xse5OJ4RIWlGyall7yG6xCMt075hsP\nXVVfLCJ5sSFLfmNPe8LQa7MoVHXcGgnPiBTsSULdYCSiWn7jr8QNvQIYQi+j\nr3y1AhFUnP+LyVcTP2ZvO3tsSV8CwerW1N7sHArskYjhceTldmLG414valnr\n54gs\r\n=4znA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.2","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-9479aff-1622538531622_1622538574523_0.22321040858161223","host":"s3://npm-registry-packages"}},"1.1.1-canary-e6cc5bb-1622552057967":{"name":"@iadvize-oss/store","version":"1.1.1-canary-e6cc5bb-1622552057967","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-e6cc5bb-1622552057967","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"eeaebe19f257013cbf57308ff79efc85099ca37e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-e6cc5bb-1622552057967.tgz","fileCount":7,"integrity":"sha512-VJ7yx0y4yixFzlmZvnKjs0LKfcOdI+BwQfdzslFdgG671LEMbSPteYSBn8Qvm5HBzvyr7IRUDvejZj1IRNXlRA==","signatures":[{"sig":"MEUCIQC5dXNK0X/Je6Ow/wD1y8GLGICrA/Rxn0UvRLVJOVemAAIgE1TRZmKt858NPjg/xZM25PEUbH9UX9JiDaoKaUaNNFY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16858,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgti4jCRA9TVsSAnZWagAAfE0QAJ7Unr3O9q8eCos/DPEA\nVVUeNZ+JKapws+NlMvg4AvcXbiQZJhava+iqolU49YTNjJs6zWI5Esi76eaY\n/D06kBK7x5wVY1gSKOLI9Zc6KMo3JiorN7H4u209R6Tbfh5MK4Gsu4oiURRk\nFn8iE5mr4nKkgw20hbIj0OYl95S6uVHioSoTNGhmBCbfXO/9faEukqkFo8VX\nWCusyv0EWh8ZI9X38BnZoo1ttxMIjlfZa8UaBsSw5zIVvamoul1nMSvTGakA\n0c9nrBJN/vJfI5fNqk4zg7VudQFk354j0OPJFFl6613VHujiJ5qUfRH9JyHe\nKOFzveLfsvUo8gzQ9dI8hUj4E2RJf3AN1jAv0+kXBxm72J98MmQYJ3plScgu\n6JKfUziGKEegeMjFbcK+1F7kW1359Xwiw02c5wt5ZSDFV19EEHBKtLkeV3k0\naWlE8Nu9unmcHt8l9x+x7+0ZPiK3oNHKh5sJnprzvS90x68qAFnBYUYCYhIo\n7e+0+64XCK09e1bkIwsbkkLH/uMElBaq643TkIYQz6Rrpa+8gIQTtAde4fnl\n8PGzY4dkpLZuTprX6yx+a4+uvp+8KvuHbr2E9rjL/kG5XPlcqGfgrOqZpcCc\noj8ULoETOHuvVw4K3Eg+NbxC5Rpf+dExv8nzfjsV82lqOqTEDWIZwRu9P82x\niTT4\r\n=5Wte\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-e6cc5bb-1622552057967_1622552099309_0.4556373036798791","host":"s3://npm-registry-packages"}},"1.1.1-canary-dd97712-1622772171605":{"name":"@iadvize-oss/store","version":"1.1.1-canary-dd97712-1622772171605","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-dd97712-1622772171605","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a7d4934440f30024e7532617f92c8e4c8813c16d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-dd97712-1622772171605.tgz","fileCount":7,"integrity":"sha512-b9evlAbZe0BSalsSyjijfwUcVuArGdlKVqkjxZT8NQzq8eHolaGx2nSde6kkPgG0KUmZd3aARhhJStyMNKK+/Q==","signatures":[{"sig":"MEQCIAfyCexLo/jYIm9fM43k4zZ5of4S/hLro6pF74Pg453RAiBpPpFPGyFeoMJYezaWOeraB5yxkfos29X4HUPH6VB52w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJguYoECRA9TVsSAnZWagAAAv4P+QAvHvOf5eSavIIOcAf1\nSUrvlMXTx1xbqzetMxIta/9ycmTN+89kmbqIaOJBXqccw0w6l/dBr79EwUbG\n2/P4UX0vxl5cwDfTdrgJAFIwuBdxvAxgXh5SWqX3EwvlzEX1pr8R9EGDmZkW\nqPennrMB93QmzOasBLVw3R54rmNLQ+hMKuHRPq2TDjbk5rr9qHukfW2n0Wsd\nHsZ4Dw/HPuni2DOIqPFyTUEaevQiR4/QcIm4v7pmt/gPOfVUR/eQcgRH2+F9\nN2LuGOlD31qZXfO8ScrirKce5SDgyx4PFMDDq1FttedBj1psO97os0f9W4FD\nFbNSBiA9uELmoQXJz/o3IHBF79fIMMzEaAtm6BDVJCGJCBZ07LQ/0MjtacOL\nmdDv4vJHM3zfvBVpcD9/3Vc3a4CO4E3z3TT67gMiyI59FRooyu/687ThEdvy\nLP0qVpBeYhZfvIHPz/NvQdMZWiH7hClFxsB+6ozjOqbVAA20d2XzhHmCp48v\nAvhI0gu0G2ST1597bBBPsM98WSkprrovJkvtiZ7ykNK9R4hFGn5XkBSqoKaS\nyN/9uG/FLpBLD0mc1sxnjupLC/yemC6uzE90V9Sh78j3H8A09GOQmlCJlilI\ngV73GJ5GUzgvvDJen/Fuwt/XvnhxGoLB94GuBZYyj1FSZMsLGFMQBeBmiXwj\nCEUf\r\n=RwAd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-dd97712-1622772171605_1622772228496_0.7464488713523363","host":"s3://npm-registry-packages"}},"1.1.1-canary-dd97712-1622772177338":{"name":"@iadvize-oss/store","version":"1.1.1-canary-dd97712-1622772177338","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-dd97712-1622772177338","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e1977387e42f01ed2227b05ddacad46069a42d80","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-dd97712-1622772177338.tgz","fileCount":7,"integrity":"sha512-sD5n2aIsxtKAf0ZZdyoPIjoiSepl2q78pGMJY3ercMn/eZsS+1/EeCWvjOQJ6b7jvhpOSJNSA9Bz7P7an6zNdQ==","signatures":[{"sig":"MEUCIQDO3EB+g2U74T9fVyXiuS4ItOO29MwzXq2ibWGYlKTAnAIgCRqhFArqSN352WlRjNKvWeoqRiXfQdlyHJNxW+AXLFw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJguYoRCRA9TVsSAnZWagAAOFAP/i3Zv6eLxKq9vOkLX6jO\nue7DJ7tq+fjQcNo2zXFp9xAb1+Li+4neQCttwFoYccgfQUCZNUKrU5L8CRhG\nyORTTTJXNvoPoYdFMY4NW3xw+p/bPulzxVu3l4xCiLG/c+td5iK9Z9NR6JQT\n0xH2XDoC4ZGSsTnNPhPW8WrInqJJTkkCh6vCvMBBAp9sxB+gdT1THZ8xjY63\n+31kTekfcsy7gwpKQNtqziUrVaYVA3UFVpmHfThIZUa191BYfD7WgygsVI9X\nk5PDed8uzwJgbMcxKOhUQofvHo2qsQMQBek92/qyOt2kEz7Id5CdlYH69ZT8\nGzWAqKb+nLG036AjIFqAqcYx1xG6vIL9N2ltjymOITfjb7mgHygQ5uuLAMfv\nz8zwS4WhgLW9F6qfphUR4S1YTruHoD1m0zuO9sqUqBX/QHN2j2HxADl9TsDx\ncZ0Y/Zz7VfzXp+/hriXO5VIgGtOqgFnodHE7IPzGbuK7UsgUGeWiN3wH7kyQ\n+9KeMICsoIrmIFTyyt1sZLvfIcMkGEsgVIYmXG8C3JHO74cdyDAyPcXH6hI2\nyr4PXfzkrDMNtBP6CTMfsy26xCFeFSBxg7n06uXR673PHWHrQuWAlpEfrlU+\nIHWdi8kCqjnvYAlHU2l7g7TR2dCQ3fVTw8VNXV0wzycZmqW3WZPpaFlHlNlR\nlS3y\r\n=6qOD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-dd97712-1622772177338_1622772241798_0.9456287852760676","host":"s3://npm-registry-packages"}},"1.1.1-canary-fd48f71-1622793465046":{"name":"@iadvize-oss/store","version":"1.1.1-canary-fd48f71-1622793465046","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-fd48f71-1622793465046","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"63dff249c1c568b0bb9bd4d98d3a7daf3284241b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-fd48f71-1622793465046.tgz","fileCount":7,"integrity":"sha512-USUeWXgdaNJmPtVQUnu/zR9bDpqBs6Rydqk8dGsvCjWJdRyLQ4+8sxYSxufTprphJV0gJCOw7+844jAQB9rXXg==","signatures":[{"sig":"MEQCIHZXgWIMd1OsjXOfAkxozSTZhgwRpLZRl/sm9VDtc+RDAiBjGxa/mj20c5n4E/Ds10A99XyJXKkBqdmMsILnuZQbNg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgud0qCRA9TVsSAnZWagAAnQMP/3NNQtFJZLcg/kxp38j/\ncCtpCYSqfuQ3Cr0ryhSvAK95op7z3IuOVFY6S1YhhO1QsekOUSasNH691QoX\nuGRYda7CDc4GVDgmD+v0s4bAeyb2GOcd9bMmjALyuxfJMJpkuqGXN3bYqwgb\n+PKOy7R3sH17lKYn48dZwputnp0IpNLNPEShUDUOzg3RaupbCIwN+fbf31Va\nyphwjjfiiwGuL134ca8dNo71Y2MGWVN358HS8f3ooPsTe0EEJbfkcbF+pmcU\noPIgG26SvyhQkS9H+ZidZ+T6zUgFY8XDk6pu/bCljAVDgyIgzUl60fiwrRso\nQm2w/LBs2TjgbtCKEMhFLHkkHKZsCyFIuVgaIToZbOFSEDyoysu9+mzQCjxF\nc0Q44Exn17OQy8KBvO1a1F+ya+XAzyqBhm1O7yvpAs3sgLrkQe1X715e64Bx\nEtS7dy1dOCQSp2uza2A2+jYrxO/bkzozBenA7Q04608gTLW2ocdQOh6UBlq5\nuS1Tp5o9gKrX+mg2lxVD9lXyc6xiwKAqCw9AEZwGwbKoVfPtuz0r21QoH2w4\n+qv7slgP8LSpa3+0ODGA9UtHPmrO+ky+zwBSB2/arFcfp3oj+ralxJhHXtFg\nQfUmGmWbE3SUMtyQrwEcQdHM/LgIBG5Wm/DCuWUHd2HUSQqsVlrzjh9kWmMY\n4ich\r\n=C00o\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-fd48f71-1622793465046_1622793514179_0.6172841069745765","host":"s3://npm-registry-packages"}},"1.1.1-canary-fd48f71-1622793465741":{"name":"@iadvize-oss/store","version":"1.1.1-canary-fd48f71-1622793465741","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-fd48f71-1622793465741","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a2bfcefac333f9ef71bc509186b30672126b0dad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-fd48f71-1622793465741.tgz","fileCount":7,"integrity":"sha512-Jt4Fy6CyY2oj964rYY2dd4CP5KNre+cYLtbNlpSWHJjpgjJwa4sd3t/R7Gv3PAYGRw3Oww0grvP+u/iL7JYVog==","signatures":[{"sig":"MEYCIQCuF9Ehs6ZOCgq4JcPvKkgTNq/vN57bbhVTaPXov2mmpQIhAKPmIjy1eoT/NjsZGVUo5oEy9sarKMlfo7pcbAX/NRl3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgud0wCRA9TVsSAnZWagAA4XIQAKQ/NQNmndJsLVesGr5+\njknzavwkZr025r4H//6+utprjVsOedXN8jPI4rCkG135Bo2j9b4OLN8Tlhfg\nbQCM73EnsZFo3v48sMtT8kyXZmqGip0m7f8x0Ckxo6ZhIQM+fbUV5UpVozuL\nWkmuIjpPhzgamlGZTtTbgfiu6AP+/x2hUzLGdHnLJRrVUjx8LZHT6i46xuTO\n9laGvvCxSAulTIR5w5z1EGa4r8DNeBMVa6kHuA+MrTwwAw6WiOOol9YZJxKC\nSmcy6QQwkoG6M33Y07PB+Ykgef049lbQ0s+YAxxlI56ad712eBRaRPfynbuM\niDV9Wu809pZ4/xSZnMizH5nEx7FbXqvYwKL2p4riwK9RPMax02p+16ouFZ2y\nxFsrwXmvmc+QykMgNjkxICzIGY0/O9oAUPQ2aF6AnhS9ZjuhTXtjulh93w7k\nCRiMa35dH6sIt9gXwp1CJjy8I2p86/ldqbQR4o1x/chiVOYHDZozHMGj2OZV\nToH0+1FG9GJ5vgmBKet6qsNNhkOl6+3/v9PQLjwk7Vl9YU+XfvInVewWXCy+\ngM7Jp+dWLZvmeb69wE7sbtABh5tEHmklvQCgJJd58ijl6LvCDys1JPGTTFah\nCp9H4UX+pjOiS9AmSF700YFW80ISyvIIkZq7n/86ioYbT6UlpfJA0lL34DNj\nz8AR\r\n=AZyY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-fd48f71-1622793465741_1622793520878_0.3594972265470029","host":"s3://npm-registry-packages"}},"1.1.1-canary-be8acdc-1622793773548":{"name":"@iadvize-oss/store","version":"1.1.1-canary-be8acdc-1622793773548","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-be8acdc-1622793773548","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"47ecf9a07f8a2a01e0b030396cc6185d922a3878","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-be8acdc-1622793773548.tgz","fileCount":7,"integrity":"sha512-d3TALTrKafkUoMKmRCiYHyZuNzjtQLK+Cu3rylEEnaRWWvGWC5wYwL7ZIZH6GjHf2hNhpIYAXr915LniC3bhqQ==","signatures":[{"sig":"MEUCIENTGMTsk2e6BFyw9Wd8EXcyopNX4vhiFyW3ol2FYKLWAiEA/2ScGtjssEP8uPNAMrwkYTaK5YbCpt9KY4p3rgMQ/xE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgud5dCRA9TVsSAnZWagAAMzAP/iH7eSXAe3kZo7tvf8Fo\nBm+qXcXI9SUB/gEJOGS7YgAYDcQNeRH+D+NI4l7OEGLa9P9krG5ZI7h4DREb\nETb7HsQW+owGN3/3hjrQL5boO/b0VGErk59P15C/exmQe31tqzPoUzg4JqQZ\nU7jdeLAyEc6EjGYD2xZ/Pve3WHrnUBcD01Pf7SOygXUqCeAYZWSK2YMO/Wv6\nEE+u17ANEXOKc9WlC5sOL+jn+AUIEEjBxlXm6aut4s9RtszYitZ9CXf582RZ\n02UvCO6Lzta4hrTC5aSIbp7/0fOD0IY2q4ow3Oz8youMkzRZwHgZoGn0drcD\n5KgjKbrAbbddPj8/BKYlFpyfi3aLUQJAZ2w+hNke6Ntz50c3CjUUVqTa9a47\n/pRH/qI5qVVQfq+UBG4xH4dimjlkxu13HbEUK+4faagFisMB2Y82uoAgkTqz\nqN7rX9jsbuJauQoZiT4/v7CdOM6lBeTcHqsc1VjXFkFJ2gcxikw4KPyvwHlr\nnQQVBvLlPQDeVevOHl4JDE4bBwUhKfpPP6I6ZaVTN6AgTVRdiA0NGEw6vqw2\nBzY3y2anz506BEMHJ2eCi1trIIaiehICSAtAQwHTg/2yoqTZu6eWfhxU89G9\ny1SJEE32tHwoPpb5WimOx2DkHgPkgULsoEpWh+N09ynQ61L/OeKOZdwJqOh8\nC85p\r\n=cfCb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-be8acdc-1622793773548_1622793821401_0.30095690381010676","host":"s3://npm-registry-packages"}},"1.1.1-canary-be8acdc-1622793779431":{"name":"@iadvize-oss/store","version":"1.1.1-canary-be8acdc-1622793779431","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-be8acdc-1622793779431","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2a8fdf3b70f1a3cae0503631f40d3c4c2fced8e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-be8acdc-1622793779431.tgz","fileCount":7,"integrity":"sha512-9NEdc0l7ZqqYrGXr8/ffYMpHdAotYx2WU1BCRWJ6rCiKX1Trl/Hbx/0+zXMjblXmFGhu3Ii5E2pdwdJCUKY6Bg==","signatures":[{"sig":"MEUCIEmS4oErDkWecaQHK7YPV6xOlqaxsB+nyrGsqzpz/HvLAiEAtdJsV78Vn1hSyZtoq78loY97wZUsY8jQyXMZz6Ar0cc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgud5mCRA9TVsSAnZWagAAsVAP/2OBEJCNWJa8TSj++RkC\najPfEVklum62AzvL1DU74wUXyON/p07Dc2y7IcKKoRaQF7gPsWocUs80l8Du\nJRwUu6seJQHQgLA3CLxzpZh8LzjCiZvZ5I8y1doEvWU9PQ4elslNQNC2LqB+\nzyP9EVC/vL4I7cT3NzIs8aR8ZJ6eNvO0YVHRxpAO5ES8L9xzbNNQl99h4edK\nrMYSi586PGnDTymPj6EsXzK9S4mBPgbYrrUuN9+7MnzRdjITF3uDisnQGq1J\nAOJVKW/txf9+U6ZYkLf8HgloDhqyBSrHFTmr78IxvZ9vIMmIhIhlZzQZZHz4\np6YULyHCn3KZbhVkphjRZkSqp4Rec65q7X/uSfFq2Hk4MK3adJAHbgqbnN0q\nw88oTf1rmapWi9T8rvDV7PPfbi81rLxgEcLUiiS1Olw5wxdK5akVJNOwhzA5\ni42elrPWgfTwwiIxsn3moRzNa1J6kezplfAEJuRECfaIp2nvJwbJpSgvUuaw\niPYvtXzCCaSsrtIFnRPh9QFeXO5AElqBYLBDJrC2tzJTFRmumHZq7Spnv2tg\noE51WL3if3KregdYOLY+Q8DI3rkV5U9+GDKamRd2T+vWOYzjqYWzPk7xgvHS\nWzSh86MVWMHAzP+/6xDrfdpWd3SOO9D156/d8gTIu0tqveA4/fwAYIHmrg/5\nFkAA\r\n=lyzz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-be8acdc-1622793779431_1622793829837_0.10674065145324296","host":"s3://npm-registry-packages"}},"1.1.1-canary-1ef0af5-1622793963125":{"name":"@iadvize-oss/store","version":"1.1.1-canary-1ef0af5-1622793963125","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-1ef0af5-1622793963125","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a71cf66d1b39858fada0b3a5fd865fb3eae3e386","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-1ef0af5-1622793963125.tgz","fileCount":7,"integrity":"sha512-KFvlDZPHBCtBc5TrY6PbrBqd0ysKIyp93RUQGxjgaRr+A6kui3IQcc8QdYrHWKOvvTYMDTIr4N0oXGAESQPD7g==","signatures":[{"sig":"MEQCIE4mAdzBOD4jYwPY+XHJGPONcOiPISHs9TqNi+etWdgnAiAiiePFx0JSC1GH3Vcqlv244964ZqwE0JmN92G+wxGVsQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgud8bCRA9TVsSAnZWagAASh8P/14JP/PcP+ZlAQ2vK9g4\nxeF/yyYl2xDbVMKO+H+4MPgxD14WEeUupFPDvclB9oRi/yekAxSD1EVuytUj\nmY/4/x5iNL5PXThQERRKlGPA4/XGe/SXf0eKsfkO6F9nO0N5RyjcYT+ne3mw\n/7r/kbDz88ytWDYRYSFDE47qkJ/02Gk2QjD+FkEX8yTr7egiZS2bxk/WLKxo\nlaZ1NMapJDjt+yPrcfyt0/1LsQcsGJDdwk9Hp0IN51pyyizijOgf6DuHxiWn\nc5eEjUidzM2UoiAx8+BeTyRw/JRNNbZWKHNB0cZEWLVqGGljHOjpE4xp5mMc\ng7KSkfrJk8Y/kplA1sG3n9P3VJDU/jXVDLMAYPV63ulgaWtaq2AXByGdEsUQ\nrwoSVHjUFdS4SHQn8sSVQb4XgtWuAp8O/28bTqclZMXXjjFcnv+OZOWLcBT2\npK5FItFrfYWw6+LMd3F19CnOBSOcAggD7ZE+tbJ5x/c6/fhJ1VONztVBaRrj\nnBxKB0hbAJahmHcB3bOsiz8FkDztyGalq96J9vQ+ElhGLyKg/4E+YQgfmAtA\nOLJgkf7uIc23uMfVgBP1lRgX3wFhBWD5l1brCarPoap7vE99SLqWIF0ZIaoN\nKFt0YBS+wxIGUKCLK/R/REgA4Od6qSMXqg9rxZU+6Xlf7/K1sT4fH70bgAz0\nuRDN\r\n=IPKQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-1ef0af5-1622793963125_1622794011693_0.7012572040786145","host":"s3://npm-registry-packages"}},"1.1.1-canary-14c1474-1623031358527":{"name":"@iadvize-oss/store","version":"1.1.1-canary-14c1474-1623031358527","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-14c1474-1623031358527","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"345648c893d91c9ca49fd832086e1731685befaa","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-14c1474-1623031358527.tgz","fileCount":7,"integrity":"sha512-dscEeZc2bA4PeAQ3BkiUwniy4STCFrj6LxUTR8/z51EPrDawYCn+6dqZF9rwdASA3IQT1ZfxxuDsILXeRH7K5g==","signatures":[{"sig":"MEYCIQDs/9sou8eXW5JXdct7wMNr6ouZOZzpF0aJdi6YvCClvQIhAOYGgH3Ug+JGSMZpAoMmhSUuMdpPn3swprGz1nCOmVVj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvX6KCRA9TVsSAnZWagAAHW8QAJPq5cT9U/Avcz3wGcYk\nLEy7q9/bkX2Tz8VaJNIt7A04blpPqIsEB0pr8fyQ25QnoPG1kbGfSloFK21U\ne/3+Mcc6KoNzIAZkW2o948gpVFCbBr2tSt1+51jfG0LEt/a1RqlznseWZLfA\nqQPf8akJzfgZy86o/IPp/pLqGwdKVwawTdaOGXZc88X/J+fN6sDWZtB8tr0j\nJKtXO0B3CbNceY83rZ0YD9WWQxELShoM0Sya2rosY5/myjRAzKaCIZjS+5Eb\n2U2kJFDncrlLq/FZuggxsR6Nq7gexTyIfDe5aIrR39M/U8O94R1PNhB0+OZE\nThUSpyoy80OOV3zA3naBGEHl87d+mLS733DUYNZUJPN9P/O6fZ3dXA8mjDnf\nqDtfvyrA7LN2Lmq8GHesbBButHGBoF8UoSBoIUDXo5RBp5pj/gFbIcYxXJhW\nDRmWHK8p/PWpIhYbJdnbIx90/UK4E2ZnV12Ub4jpKobbrCTDIelEYGAHhqfk\n4hlA4j7oA+kvNM2JT9JSdwncMIWBSw6SSdWVMgNvgAforY9yJ2aA83/cz3VW\nMCXOe/hOOrMm+CYpnspjBlUlbIO+jkBaEQndTQTj3hZR/LT6EFBHgPxWDA6v\nDpAXclUBGAzEJ0bxU3aMs513s76FwhWOA7V6/OJTqZyn0g/5a6rdrEuRWnlO\nXEu2\r\n=WVv6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-14c1474-1623031358527_1623031434321_0.47905695765080347","host":"s3://npm-registry-packages"}},"1.1.1-canary-14c1474-1623031359389":{"name":"@iadvize-oss/store","version":"1.1.1-canary-14c1474-1623031359389","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-14c1474-1623031359389","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc5c943ab3abef82ad5e7572440d34cff96a0f86","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-14c1474-1623031359389.tgz","fileCount":7,"integrity":"sha512-aUBA0YGDdezx7biikmXlfhgb4BsNQQ9ejDJ0CWvuWbCw8UmDUrNR4IGHTO0LbHjLF0SBpjRiwAfn7no6vmcunQ==","signatures":[{"sig":"MEUCIQDE7iP9JtV9SqqWqrh20L0gBkbMghtF6gdu9pHzvRQAXwIgQVlHZ4SQdrnP4/PBpvtUUIwcR2SJ6XMwSGP96oiyrhU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvX6TCRA9TVsSAnZWagAAJmUP/imSezFMUOEeIsL7E6oB\nozGQZOhar5xyk3PfwBkadWcRPxPJptXWfIh92WE7F0Jk1DpJR2FOBmxrpdW+\nx4ams8cz8kFiSh6/DZVchfYpAYDsWVzTkFrU6w2TxjMb1RA/zb1dSDy7h895\nYiZKOuwW+SnG67VaFHrzDq06N3Rph+wtDf/GI8T4lmI1cltS5cQHoQGKkrYU\nSLc7q/I5F6LTxuRk1UFjK0sOrrZBazrlVg/JQnMFUgJfIUF/P/90mbCJynj2\nTU7tWjt2kVu/lfE3HoVqyPOlCcEh7vwzLlBX6kNktMRXPEc+MRD1VB1aFwNF\nFCuXM7oHe5FE2ymdOan/Rt4Xvj2HXM2gTdIAEHLri6SrygSJvBZhK3G3SUzN\nn2oB9Iasp6YFxJyL2TNCSj/bAZycRftFwEjIZzfLO1L7B57LZ1u67M3+w5Jh\nM7OEI6Gg1xz+zIIH5YamzEmBn++aie2QKWdhBzQD8/X7CafesFF1dVSbQapF\nbHK+4LiJ8VvvkgfX//1tr+z0aFVI/yTqHxWLcmzA7P9gdoM1NfMnGAqVB7IE\nWPm0OLGUjbGMWq04/Q8nh2Pi+WGnKdzFkr4hkKYAeeFsfaF8onS1eoPcGVZG\nuKQE9gfV4e+Gco188gnvzy1/AhxmAyQoPBYETkGppI8cmIWoljhrAfobUDB9\n1Tq/\r\n=6Xof\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-14c1474-1623031359389_1623031443345_0.496017718399804","host":"s3://npm-registry-packages"}},"1.1.1-canary-14c1474-1623031417445":{"name":"@iadvize-oss/store","version":"1.1.1-canary-14c1474-1623031417445","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-14c1474-1623031417445","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"584f046701758b61a74acc88852424926c05cba2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-14c1474-1623031417445.tgz","fileCount":7,"integrity":"sha512-lmLgnD/XbBS+5cjX7fChXmqRf251PCKx3P0c51XzXI8l5u3O/wX+FYuNRevx3o1Ud/w7Um1Tp5mTd5bYeHUKKw==","signatures":[{"sig":"MEUCIBHeC63ncCO8RTsRK0hW089dNRgdRo7iTqWO09Paq8M7AiEA9RAPvSDIgPPsPY85FGBgnM7tOzxFfM93sKgAHE+TFrk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvX69CRA9TVsSAnZWagAAKbwP/Agz1jwYDwiIJQIJ4VR+\nt8BABGYQYb23Q0JnQ091LJ8Dz9TVTd0eB/7N1jS8pP+L0n70Z4sUr1Gwv4CR\nt871EmHgH+664nMlyr/w6k2RAVVcDx7zIgPP8vPaPCtMuLuQPPGWaiEJTXz8\nQkFwRBNNUHDtAmpfjO2IgdC78htKIE2ln8jCgRZBq+G9Hq5LppqqHy6sxCJ0\nvExWeTupKdKA4Q4/A3nU2p2ZU9jHFz4jN6aMHYBPV4pCtu9RgVcSa8nZhw9n\njSEFrz4BKCh83iu2HQiy3QmgIcomwErjWSO0m/ddqJrW2i8zN9jxwCfo1QqQ\nsigE9y8RADd8D/6CfT/KuKcEBzEh4NQh8VeKmYp5RRR0iQVr/Qr8fs1mO1oG\n+doOL3c+2iwFRdUkhXVX8x+owmFt/fASud1sv/85mQ+8ylQAxnmCEBBKHzY4\nylG2feUlcLlhK7cf5NZZHk26ZgmM2gE7WfeczoFLKNVufzOjl3dIvKnMOf1D\n+S0lpwLDoEksX7+QWQwnp38YW/pEDHB0C1y31SUbmeiZa/dmErPWK9MqLPA1\ne4RLE2pQ0gIjLT/DGg3Ndk3PjwhWM1AE3oxMB3ywglaGGr7eAJYn7dvpgEKW\nwvBCsoqTbr++4yHtGHoo1RWlzGVOr3E8PkeyleA7/lU6vXe6LGbAHMERh/4L\nUYPa\r\n=98EN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-14c1474-1623031417445_1623031485418_0.2398268473342149","host":"s3://npm-registry-packages"}},"1.1.1-canary-14c1474-1623031419128":{"name":"@iadvize-oss/store","version":"1.1.1-canary-14c1474-1623031419128","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-14c1474-1623031419128","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f5457228e331fa056b56e9e7b512fe3a9b9f4e03","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-14c1474-1623031419128.tgz","fileCount":7,"integrity":"sha512-bqom6ybg0kcYQ29xHOxXtedl7T0vmI6AkOvlRKGlPVmb+3mGI3KHE6EEUUptswVOSsphPoCuTbr2xa58jRsl1w==","signatures":[{"sig":"MEUCIQDKLQmFJzVTKfjZ0yU4q0L5OFPmoC1Uegyi4hmrFmVZ7QIgLPvRSufI44+uoEBucLHm7E/HjegGVcULON34vHs08Ec=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvX7hCRA9TVsSAnZWagAARVgP+wYhN+RcWnN4dpzfTMuW\nBPnioatWRLAXftPYTrzu7izmGfRtMuN+ia5ui/mNpKa7AVni3NdVojvpm7+z\neQq0omHNX9rSa2lAygAzbjGanGJ5d4LJlALsdIRxw2yLmy23kDJk1LV1w2tp\nzfGbuz/Dt2V73xn3FtdOKi16X73NSla3LYXPx9LUjAOYsYg/KtxVrZTEk81N\nkaCgE2XZ4FSyQBdOEvxKFpdHhcoPgPGYJquk8K9BStiS0hXOGXrWifOGxnkX\ntj5z5qC3So5mHa9jHieEc6v7W6t64fMKST1MKpYOoi5K8ZfmGT2UASEJG6sT\nDiGmJpewUQGK2cHGZmeF7DXmQWd6cdfIsbXEdMOXB0v8/hnZHhxVaqBPT8GO\nOlb2pFPGCUMmYaW5YA9Wqlb5ticFhivnNGNpBfflU+/SeQeRmafX08pKZBF1\npnWXjvuarDNKS1D7Q7PW25tXOA3FSGkObX1Mo/LkPYwVHFyk0xPJGWb7lHpD\nHtIZb0x3nebyeQihd1f8U38l87CUhMlhd7TV3kfKS3t4O6Stgj1Xols3+G+/\ncZs8hq0O3ap5qglwLfB/0ZmpgBXbqnlGpeEkdPPECU1IKP3TF6Gfi3tyyklu\nEL1vqbqV4PiX/llXsamNjghXJ/vRUevIdNKJ05XVbYT9UTkldMaP15mgoEt5\nIEJA\r\n=7rqh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-14c1474-1623031419128_1623031521565_0.5325987215556871","host":"s3://npm-registry-packages"}},"1.1.1-canary-15a216a-1623055378004":{"name":"@iadvize-oss/store","version":"1.1.1-canary-15a216a-1623055378004","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-15a216a-1623055378004","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f18b4bdf6483919c31d42ca7929ba1265bfce8a7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-15a216a-1623055378004.tgz","fileCount":7,"integrity":"sha512-mDRY3Kud3dx99TVgGr80Pqd+7/ZFM+trlteXYOd1+j0B6In/RnegKu+78i/UZxjaX2+Gwguf/tY7dNpWzOTLuQ==","signatures":[{"sig":"MEUCIQDlMUr5PMOMP49Tg8H9AeAfn5lljmGtt3w3btASfps4nwIgYBYaSgY++k+ZMegP7AgtiMISZIDmkMvvCrhLR59RWSE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvdxBCRA9TVsSAnZWagAAS2wP/3Jt7XXczkpDWsuaIHSl\n64FxDLzPrqN3mTfYhjYnn0bOGdGwa9VbAAW7JVzA9s6j6MXFthWC79hykEzi\nWS+JrztnqHGCQgK4v78VCqm+2ffG7hFPiePxB28XwaSF5rxyPNWk1CYryTPt\nFMHWCxfaprnokE3X9J4GqgqF05SbPql+S9Z0XX7NjtlS7eu0M9L4BJI8emTU\nPkPfQNWn5SiBl0XbUquZtO3D8duPxo9lU/BhMDNqvupkSnlrJRhuEOWlaxPs\nQyagOtCuGicSoWZDMKyESlK0Ktso+ZMu+t7NY3i3RKzKRwQgTwTl0Pp2f/BP\ndinckofcIEl1OVsFqAtvVE1ED7ZdrAoMsczOVPCTYlW0Ogz6shuof8qxQHki\n9dZOWvwidd52cL+SAs76pqQcpl89Ur5Q8GFwwPdxAgwKB/JC4V2h4mK0VsTk\nhp6VgrGF5m2jEIIRgg2W0usn4RosGAVUcX0iLDiG7LqdeOTsfr8fTe9nu0hq\n5EuGzisHxXnuT0DwKaJ94afXMJ46HOC/ZkY0wPCpLG7U6yW25sdo1y4M8NtM\nJqI88If2BuvTpbsMLvrI5GygLXl+alj1FNtn20tbH/hIcAgQacwGAYV3qoK1\n6ZJvxDh/AHHhHaG7f4RiSgs0cu9pAkLOQUy0HG+A3ayrXlAOQ4uQ/xKVHKIk\nCg3k\r\n=8P9h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-15a216a-1623055378004_1623055425766_0.26572824859328237","host":"s3://npm-registry-packages"}},"1.1.1-canary-15a216a-1623055409393":{"name":"@iadvize-oss/store","version":"1.1.1-canary-15a216a-1623055409393","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-15a216a-1623055409393","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3f4f8415a92aab15817c19a9691c603abc0e85a4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-15a216a-1623055409393.tgz","fileCount":7,"integrity":"sha512-0n6qPBQgszxu5TlLcKiazjHLtuoCwH3eBEpJSzD0+JgMdqC8SMRFuZCM6I8OJB9PyF3OcPHCEL1rWbfd0q2JzA==","signatures":[{"sig":"MEUCIQC74qTIfIDA+aB6n57rB725fTOmnH7mhfRvm8Bh73dXeQIgcMaxG/9EIiU1e7IDs3/ov5GM5Zyp41k7bDuQi9xvngo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvdxfCRA9TVsSAnZWagAA+k0P/iGVJ2z3XU5MhNRaYysa\nkhmkhvReuURZTQegD4IqeNH/E0khxYXG+6rRiDZ3NlqdAQSM3uZV16tBdyRw\n+x+Y2K+GfYCvP9tRokePKepfI3f01NkSiiwnY0dcLXqmuf/ZPuCC2sQLVqxa\nLoPA+EshvZSpWVN9+6QPGPIcCzsKC7wJf7d9rbvIn3Q0Yp3yczZVp08WVylS\npUiOyq7u5BD9zP5Cpuj+tseMkgqc5QWGzyR5EustNg8x1XTc124PCEet5swy\nE/4qs7f5QzhbSDQKdOEYnaedW4GOFvOws0et7aoXJ2BWwIA7Q/FRokKck4kX\nQJjCFV49MTuWvodyxP27dFVnRYFr7nFKSs9jkX3wNIp63qWrHX7PP7rJKg8Z\naV/cxizCHi73vQXpAz1wpxZ7WwzaoQZOcFmnESzzAxek+g7hv1CohLHP7iBa\nm1pOmD+35WNVn4rj66raLXq7lWwAj5UJrE+n4F464XEWV2f+vokU4rsUQcwM\nSIg5eJT4wcgD/kCruLx4n4lN4MAROiKVghsbbD51AiIX8SvISV7ARpGGRXVM\nVE0wsKYLWIctFgfbk+xz0ac3FWZfZbv1Gj+XQzFrp+OcLIF/mwgSPcQ1VbZk\nO9ZgNaxZ7qZOUo0pYu9g8/TEpBoz07EePHwHeDhbQbXV18ih7vrj8k4U/CrH\nOfJH\r\n=6pdi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-15a216a-1623055409393_1623055455514_0.45127273692226866","host":"s3://npm-registry-packages"}},"1.1.1-canary-15a216a-1623055661003":{"name":"@iadvize-oss/store","version":"1.1.1-canary-15a216a-1623055661003","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-15a216a-1623055661003","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"938830ed5949a9c72ba76e08c098938c0f5a3d34","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-15a216a-1623055661003.tgz","fileCount":7,"integrity":"sha512-ZAxIJ/GieQRqXHW/jX8UdeS3hzVHfvZ5KKU1knzgm/UYRiu9D6fBX3fhoy3FVQ9RjI1eZTCl4i83XW4oawQ9wg==","signatures":[{"sig":"MEYCIQDyxkdvgU4ePZRRnyITeVaQbghpVhpiofDSmp/aJvNK0wIhAIlHTmHbvtxqXZqfQmouUDDgRhH2EGQTurs5gjxJe+mt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvd1gCRA9TVsSAnZWagAAoZIP/2c941xyAMbmpZPTpPnQ\nwQV2YvIsjBW+8lSzyJEFeKsMBSynZVAVp1/3s5tjhzeauearcFRYWbnqJy3m\nMxFVtyuvj0gRQe5eNZN/laoVoBxTOqC4u6j27wcfynGc75FZNo2Po5YhPTo2\nKuDQZvHV9+G79LU6MaQxAwxV9nfS5mds8zMzq+di5q4WlC8fl829wo112lsS\nqHiGU9gHmF54x6gSLzzfmcI+JA95xL5/7xHEWcTrW/jFZDykA/3uyI0LQ0sC\nREn+yfz6rUThobrwSf9ZKa8b0jZUyHj83WCZsk1Bj8f97oX+StV6D9FdgJ4y\nMI0GnzO6JY37VrPfV9GiNDj0GngE/NMmwnwzdEhLGk19nxcWBYLpxGCo3BkB\nWNI8bS3gXlCtp/Rfl5zjaoxWgKX7cY2A1wihFa1Cpqxcx+CioG99OnBhAKgF\nOtiCAUFvuR2tS7xmiwt7pPyadmztvqgoTADviaqokahPWgQU1ixJbkekqnQU\nxifWUFTKppuoE4ZyWkxGyMfwsFSINXjt8lfMyHq3jfs7kY0H8hc7TJja3ZMF\nL0vg3c9FLfJSSn59Mm+Ylc0s2Jrb3qNqjMRvw/smTvcb9tgl9knQgzHt34zI\nggzQtmKahWbq69z2xJHBm8sTV5kpJmcZFStRDqSApqc4vvApczd8Tp5nkK84\nYH0R\r\n=MqK3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-15a216a-1623055661003_1623055712159_0.5956603575601835","host":"s3://npm-registry-packages"}},"1.1.1-canary-f70971b-1623055791409":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f70971b-1623055791409","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f70971b-1623055791409","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d3cef4f894ecb4f2b3440d81a75badab2c043376","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f70971b-1623055791409.tgz","fileCount":7,"integrity":"sha512-FYx5D7n0wy4Cq+I4ymU6pY23cWRCAIOoTEdLt291mNz8aM9KthSnpevHPLuxI3V0JMHV40HpHjXx2k8TaA6k3g==","signatures":[{"sig":"MEYCIQCJ4H3fxrjBwDE97R8It6h5XEVdl2TX62naFuKUCZ2VUQIhAMO6dN2zyki6D6ITrMpvLSegl7n7vREXQYs8I/+i+s77","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvd3wCRA9TVsSAnZWagAABfkQAInxWB4uIDLvO+x3g9mi\n0vKeKUpvsaB9nSFdy2wv/TyDX9O9XaboDMElbVH34j/0TWwWVSBsYb6jFPnZ\nj9hAM//eb1nqarKqAYXePuIS9CgqSEnNwWbhfsBH28TFndzZ9iR/8b7LMi4k\naGxY52mGaNGJ0QI3VDnlv6a61YvO4KP5qGgwaCJ9BaZ8J5rQgeRJLcfW3eAF\nppof1Sf3LoDxKRiw62SxpOrqn8jK8oKfKfD7k8h3OMtbQqumNFKgTzNLwZuP\nCLYyYRMrUHiGxBh8ULsLbmvKru5YYzi25qwSNNMCZXKkPki6Z2srZUJEtzyh\nfqnp9Pxys9Cg5SwuHbhaVCL2fdCWC9Oh/Q8KM7Ouy+HQhaSB1iSDLeTwwTIk\nGfhyeztBYFXUPDMGAXk9XTwjsU2MJYpe9QQCZi0eOs8hUJd47R1LxSNdRzyR\nyQFlGQ9P/J7/CO80SSWYfpYa7oB8MeE+S41t84YAIIMyBXMhL5W9NoDyIEgN\n2Ae0ENtG4Jf5T/NLrF5dWcPed6L5+Anu11EF9zPswi+iZarLvBB1uAxka6FH\nyQR9G2qNfJiA44+agYfqixLgxv679EKSPJR867v4CRh1REhowZhRq2PNlegm\ndCbJtb0yjkwoAyisVXFfAQTHG5HKwUMO1XjCWxNNRaFB9ePX0JQlOql0i4Lx\nU+mr\r\n=fHIn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f70971b-1623055791409_1623055856002_0.5213055352760505","host":"s3://npm-registry-packages"}},"1.1.1-canary-f70971b-1623055811615":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f70971b-1623055811615","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f70971b-1623055811615","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"edd4282ac698fc6f73bd7e61f604f1943b99bd06","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f70971b-1623055811615.tgz","fileCount":7,"integrity":"sha512-VKenYj7GGC3mwt0xDUDGCdNLAp+Mahvklrrybsv32Sl4OI9jUqDCM6d5dT6KJBHHkKJXU39blTnHS7j9F7Oeiw==","signatures":[{"sig":"MEQCIB9V33bOQnBQFPv3rRXfeeeC4IvtBgq5yKbNUJ4atcOhAiBToRYHBaBocgjnlPFrKf+IHNk1Z4th3lKM5C4tipv/8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvd35CRA9TVsSAnZWagAAnnsP+gLozE8hFguLNgHneW5a\nUkdoJTKf9qgTHqTKWFD03z4Ok3gCylgZtnFAFirI9zljzq4cGJKaXnPGzvA8\neaQZtvAlMM9yN3UlLn9najA5QFtlzdmpKDEUKHi14vDwiwFDegssxc4r9Jzc\nEGpczeCg2aCRIQ8S5YvnUzsds3xe8axERzmLZkv0TGrFMN+JyTowaXM6ZLgd\ngBOr2QLFtu4nl/3+JfS214q3sceYeV9sq1f6+0C+70MJ2BKoMwErOodUC4Q0\nd90SYpK5QwTwFMxlPpp8pEfcA9mr8jfRauzc4hu/8D6zqM+Hvm4RbCoeBzlg\nydNE3Flt7cfmSzRUj/xhIt/89zwJ0FiBGblVvSdSWKkfczYD6249yRlWK60i\nCHrmnabO8MQmHmRkis1bbDx7+azfyJt8bU36nyeRCwkoPBgMamcF8GgxNSqb\nrUFHTQnpkcExRENrTchOFnimSGfOr7JSOuhzYel2hrScAzje9MTVEt67vPcO\nDfAy0T0PDHknqDjLf89LAbOTeFP09v/Kd/7QKVtc0FEGxFFI4sR6bC1KS6Mp\nP+BYs5KCtjLB+weHr3HG/YvSeWuAL6LSzRe/+IXwTJw8cozJz21xeH1I6sp/\nhz8fb3i3ixXBe7Ud8PcUeB3Dz/4JBEowCji0jo4vmKJ9yfPhL3vbp+k1XFY6\nXhct\r\n=jBcF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f70971b-1623055811615_1623055865624_0.15442228477804965","host":"s3://npm-registry-packages"}},"1.1.1-canary-f06a303-1623056816246":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f06a303-1623056816246","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f06a303-1623056816246","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f0f407703fc1fbe367202b5a1a85188ea26d5cb6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f06a303-1623056816246.tgz","fileCount":7,"integrity":"sha512-e7Qmag8ADl1xFIqBMv1AUxZmH9upxgXVpKhiHapCQ+0M/Dgmcn9JASgPJ1PwFexDPBAxDfMYMnOjeoFDYHG/1g==","signatures":[{"sig":"MEYCIQCKpeiM/HaqrGMi6VFVPuHgmJwdVaSf8IDVRzpFN8uNWAIhANOq+QwvJjeda+XZwjVxt0fPIJ5CO6xs1Oh8KF7vDS+C","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgveHyCRA9TVsSAnZWagAAbOoP/1B6FbUviHL9//QlWAq5\nvbPAeXjeSGJvHE1B3jz36pf6mqBiMQefo6PYib+8gUmJKJUSACzlfAPVCBI7\nh0tTp3CrgHwIGx5pLZBaTX/6pwspAPuzVzpvFNl38bF/szvk6xtG8QtWqm3Y\n7PsLbgB4m26dSJkkT2RDSIMGvAQoOZ4jGFkHsfoIyb+dHb/GRJ1Eh/uhOzZJ\nojKbu7R0M3ZBYaEwDSoqQqtbWpbGJ8pUBkcyTN/Fg4PHgNVpUR6tun/jKY5r\nRMDxbCoHRPbz4sqeWiE4ZhjDzG2AnJVPTdw7U5lxIHb+E+v9rDE6phZiCr9K\nfJfgb6yC/QeGPklX0q6ya24EVu/bGP0XV9QfLSll3tiwvCuS9SCt2I85Oihu\nW0SXCHUxSTLJmLBlaqQtafwJ/RDdKCRfRBXuVGSvumRnVibed4L/nUD/OfgK\nvTiDSkzomil6GoJLsqRZJYaV776dChMMZfBG9docmSl72oRMT2vofLk+KAXX\nuE/UYk26++E+jksz+hkZMYlxDsyA5cTRRAhNWiSpXF+FYISluH9NBMrNlGre\nVZCbfamHUYZXE+ZfEH5VTanunluOZT3zn8Pw1ZeBEq2nqiXxZmG8LooZAuCa\n48oIpgINTBir+qOz6v/ifwNfNLkkVqHAhjIRV4RYMjAXItb0qeMqyTHQrWOY\n7dgq\r\n=dblt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f06a303-1623056816246_1623056882000_0.7028420581942239","host":"s3://npm-registry-packages"}},"1.1.1-canary-f06a303-1623056781475":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f06a303-1623056781475","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f06a303-1623056781475","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3f25dbdc7aec8eedd243ac3e8061568d0d4314c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f06a303-1623056781475.tgz","fileCount":7,"integrity":"sha512-Uq+tVjdR4jRvEBEBLFx+6o2ua2lJKJJ+IN70d1n7wfcxzvIvJb++1sgsZpGlyQ7DTcO7eRDZm4qJl7shbiXQ4g==","signatures":[{"sig":"MEUCIDTalI686chJ0LSU14z+BWC5ATciZIssSidg9cQOO39dAiEA/+2b9pJlVEIG7JwOQK0UAudysB6TrcG2xW6oTWWwLMI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgveH9CRA9TVsSAnZWagAAg8IP/2O/yfd4VGKwxFTO5HfJ\nwYKdO8HaFp+LIOjz/Ng/ye9sgNvTuVAI9idXfSJauG2oB28b4PtEPxs+ApSN\nToHoAHti0uCeq3zvUZqCY40BJUM9WFDZF7mMY1XzHqGOfd1nu4tL9XiuqJq8\nmQpEmIaS8lBB+R41wcj6nVetSgw6Rfwc9p5IJoeVM0fExk61sUSUH3I2GSUV\nhDbPEa4j5pcfimM8gNkt6Nf2261M4l2aSFUOnljSnfdtG/OrHYo/jVmy6vPR\n7rtZW0zn82+EtEpiC3B5SC9zB0Vg9LuYWBC/dwQgxZcbQhs6MqsPDWiwzlZW\nNWaf+v9SUp3Jsmxynkl3fZx51v1YanM2VSAEAI1YsrPCMRmQa1qFXEb73Lgb\nzhsiSzk7X1L8SuiK7CWpzySBFzbOHNleJzXzB4MsgvtD7OSBESMv3gr/I1H+\nW+GeiiH17Gur8huVFgUGuyCWOT3VS61fO/1wS1o5eeVCkWrSG+iGW9c7eXZo\nBGqmhGcgHUtclS1nUbqbiaoVrZOQNRsNxkmFwnx1Z1jQ1J/xrzyphkttDlwk\nhry47XcrEpa91wR9gbFchsfZuFeYByicfeLk06SQ2tHRHkZGgtJ5fqnLJzsi\nxwyvGiTpLoxJHbZexhJm7f9XpTP83dO/C1Q5pbw3JGak/rWdTrc9g2n9jadx\nhvXW\r\n=Bm5l\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f06a303-1623056781475_1623056893269_0.8774814267933599","host":"s3://npm-registry-packages"}},"1.1.1-canary-f06a303-1623056871428":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f06a303-1623056871428","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f06a303-1623056871428","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"83ca9ed2afe2b1c42a9059650b32ae8c07217045","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f06a303-1623056871428.tgz","fileCount":7,"integrity":"sha512-GwxhpdrDnIQ+RfTtZE/vVhtSiaoMw8MeHIkr9Br4HxQDcqezhZ6FVyAgmS7EVfoZkvl1NSR7ZjDX7Kf1qLwzmg==","signatures":[{"sig":"MEQCIFWwHq4o+gExHPG7mLWKpDZcq0ZjrNMDI8ck8pqoUh0eAiAf9Qx5PNus2xeN81Y/V3IyhdRPUJqzTMUo1qFpQHr0Sg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgveIeCRA9TVsSAnZWagAA+PkP/04qPg77C6oGgB7Mqb6t\nrt3RDJQbeYyVDplnMXPdvcpCSde/SVo0FkBgWkpmITpbheRgMYbquKPOul7y\nvD4Xe59lfRCJHQotgPR0fWFqjEQsj76L7wRb/YqOlFSI/ag9i8h+XlcJDkMG\n9tNRR9QFg/PFhmjBgvv/CyJ+wjgWwkVvhRvaaDHEGxmWQQS9aMnviid44lSy\nRcd/qu+Jaqj9YLKiK/OmHpc1p+0KkT8A2JalvttVJngCc4U1gYP3JsTVKQFC\n+Ds/jnH3spOQbrhYyYcEAsp3zgiZahUdyadsQN5SHdgetMPbuzjGx3u4nGMK\nl9a3GGKuOQKxhTCm2N617k7HTAniESwBh5o23AVVqRYXHXjvzYk3bAxDMgl+\nO0tA5C5cBMdQkyQBK/5jLWfhplP820gKjVK1V/TltPp+ZEe/zrllI5DfA1o6\n4NIn3FlfBV9/6hqiaofpQXM6MQVNWrGLm5UHveZ+ho/wnifoYhuXR2qiQLKH\n0PLe+3ZC0Y5qNjqSo+N2gqkBLfSTtKZGM2c7FaHOO+megHgOosCUwdy4yR4U\nthHxtIrWgJ80YxYz5FhN4Adb7YFLtHSu2l4oNKpxmaSF7ikzzjMbTm5YIgfH\nDhqR8mmDIgeFKf9KBbdXOwc9+vo0SmqVmAEtTyfgIkypcE3qhz9VcX64Ub21\nNF/v\r\n=PpuT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f06a303-1623056871428_1623056925985_0.2889363959996549","host":"s3://npm-registry-packages"}},"1.1.1-canary-302413a-1623056956232":{"name":"@iadvize-oss/store","version":"1.1.1-canary-302413a-1623056956232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-302413a-1623056956232","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1295598f694a65c608bc2ef91fab1ed9d2424c92","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-302413a-1623056956232.tgz","fileCount":7,"integrity":"sha512-fKCYbzmHd0D6C1H3hqLem/JQEzRSVnoOdwcpbkZ6iNdVAomxA88Fnug6Kwx4W7my5yE9eTIf8XByQ6vaVeTEow==","signatures":[{"sig":"MEUCIQD2BU7iqUGfQBODuB9t/IRL/MwYis0fxsDq+75j7soImgIgLEquKdkmEIEUf08BU91psCg3RGEPcC/Hxd4Zg4fK/gk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgveJ8CRA9TVsSAnZWagAAO9QP/ioL/asJdvowSWh3204U\nV919DkGxe6ZwYLjhQYoOEa4O6Xs72/9Qc5i8emxsfQQE5rEaQRzo8zJk2nhY\n77BSK0R4XmrbGgXwApZKkEISTDFmCmB+r9BIXjtnutCRvZ0tZElXgls/hkGN\ndgKY1riCseyp6JcGt/oay6XZvwzq4g10MVTkhOTvUo6eqRit1rL23dC+9aH2\nyp2NsXhYJA3C6rqYQktPKCLKlhh5GNUaYHVtifUF5UcqMHepndxWhSQ7Fk+P\nEkBhaHXCL6McYQlYloZqgZidIleaqNUUqIDRv5PtEqp7COTREPfWEtvSNvDd\nNfCfzF/h9j+vucrAYlc/QHYzcjQzZCYZbrlZogc9DyHg/asFtbD0jofn59hm\nqG3LK45IhoO99CKCfrj8uFI2DPTa2qhiAueAHbjCEaeErQ4YqqGdeO7HGezp\nE95Z9duNdbddCEkZ+WY7oMy7JO+4iA0LwCmUQTOCmcjM+xHZZl5NqdPUMfBV\naQOqKVFUTXFBKrQ7CjZ8rIl5xPW+BHw3mQoqG8J/XzhkmwP/RJRIhavIouJW\noZOO62pyozFaJstuG7wNJVRkNEqOgUopLWdk00sLDDtdcpmBegGSQEh7IAzi\nNhzWWxHXG4NV/VB4H2CMKDFYYIgOOUjr7G5Ydaksu9EDXN/QXvoabi6ytm0+\nXwjF\r\n=GDhI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-302413a-1623056956232_1623057020110_0.6827122522452727","host":"s3://npm-registry-packages"}},"1.1.1-canary-cfb3e0c-1623059323124":{"name":"@iadvize-oss/store","version":"1.1.1-canary-cfb3e0c-1623059323124","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-cfb3e0c-1623059323124","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5b539d775d0a4413154c433f3c732704cb7ff6db","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-cfb3e0c-1623059323124.tgz","fileCount":7,"integrity":"sha512-5eQrlZNQjOxTuac/POBaSNzZ+YvqW6rE4mOvBs9GjunVDXSkX6LNP91ntAs01414+j7N2fhMdg01IlE2UAdohg==","signatures":[{"sig":"MEUCIEI0vqW0oLTGWTM3kDVbLb0Dq5GSmxOugMsLJ2gTbMWYAiEAr1fLE+BJCfuKdSMoyt0gCdNo6RNJPiU3GKIUGJkXsS4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgveuuCRA9TVsSAnZWagAAb84QAIZNuJ/xCQtztpGML8Ay\nwqszTjoinbfFLEgDFtGY1gGne15uo4O3p0+qdZn/g8ieY7gEWEg9btSraaAO\ntmvFY2C1XwyvRS1i8ryP7/muGcDNeLc0lxrl9GvSpByXPBIztOD/JhN0g7d5\nTovSdZ9PGnvpyKWQ/Ls578FUNcY7V91YMkSzk5tYxJyBRNHfXHJmorX0t5Uf\n/KObbSl3mcYyajFk4UyPexSEjmmh1D1QrEqD03mYbpL5CYHE/wa2GJhd4nhY\nF3bAavuuciqe9C7MI92CHQD0HLwhUNJUnNfufPS+SpgvJZevgu4ivs80zlC7\nCcdvyrmBweImXmUuB3iSj0kO1BhMIGoMqoPQM21+VNlQ38kPBQiYn9ymVeOJ\nStPfBGyaXFSILj4sehhffssIgwDZmteB9ZyQ9hmhgqa4FEYKPF+s4Ll6p9qM\nCYBd1huDaRQIgPQdwLy5MaZvTg81zZsjp1PyrfIogxYlXNlMSFreljCPGr8T\nkXkvOVQWXcHW3d/ij2XV33/YtwwaI+edWVcZ1rUiAPDEgpnNAbRsuEnaPoc5\nHmVhJ2HS4ItAWX+g/jy8xYlhp/MMeQ8wSfzNLZS8rFCz9ispRM6c5Ag9Lg9k\nbOZML6MGn0dIN6bh8ZdoGAdmVR2ZQcopbBXLytBtaLGo6UOpJXPDTP5EWO9z\nMsSo\r\n=E99q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-cfb3e0c-1623059323124_1623059374227_0.5891140497685592","host":"s3://npm-registry-packages"}},"1.1.1-canary-cfb3e0c-1623059345291":{"name":"@iadvize-oss/store","version":"1.1.1-canary-cfb3e0c-1623059345291","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-cfb3e0c-1623059345291","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2d4911bea29b9d7d446ef7d9b6b5b748a28ce406","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-cfb3e0c-1623059345291.tgz","fileCount":7,"integrity":"sha512-PhHSV0MLPOxl/5UVvT8X44u7xw24gTnEKfN1nEEtn1UnJGcjeYNgxeJYPRk8RSzwJOE9kqPfDLFG2EGRp6NaIw==","signatures":[{"sig":"MEUCIEJsvOOR0ty+tkFW3BeOGj0+jZSVKsu9XtaeqFPyaWuQAiEAwJmvRbLfQVGiNTHogUdW9bQ/SDeMAW8x1dvjz81JLqQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvevDCRA9TVsSAnZWagAAASQQAIfkQra9wszPvUz3yOcb\nVuxIphKcGJKpGUfYaw0G0Wrvre8eziLdVl9Kj972svrHzKJU8l1v5LzV1Xks\nSheJyxFCMKiDuZXxmZ9PqviZPyDfjvCAM61tu+55OTuF2ouHf9ULBUP6kWAQ\nfdPFCp6iPG5o9ohndCa1QmBOwLdjvJz4I8B1pUo1TgX/r0IjTfSVZ9emoKIw\nKTwb/Az7isbBijiZn/jcXbKvcyqoxiL1JVJhoCQyMMlEyAkkTpbcT9RZfJNn\nGLhF3B6IWfPv0uOkFJHW9ze27cIGgvR9lQ9o8PwoMVuolyzKcwpVGQXCXVgv\nhOZi8m74V0Njsi6Q17koCoY1MVRt0EKMbLMBaN8dSJFbZazGpZB25zaoIRsV\nv4NjD/aj7MOxv8hKiHBNrhq/GTM/Q5VMkXsBR72B7ZiZhEShatluG9tXs03E\nUGwqHp5sDcRO50QHvozAJ9zpI+ewJT+SsTHXJnaFQb44rnUHcJKJXBpCmrur\nOoW4mLgsHT0B9KSxXVUkE/UKOpfRtH17IMg3/LKnUytl79C8TzkXEDqt5Iax\ntdW4YfKNqMflK5IHUpTXeSvudwwAX2deBdVk4klsn9BPh6U2Y4F7GqmDtsoB\noMhk2BPo0hTA4e1NulsjOs/GfWY4DK2FaUytNm5CdMaHx0AWc/Tjh7DK9kuR\nYhyy\r\n=/7m+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-cfb3e0c-1623059345291_1623059395298_0.9537719187357716","host":"s3://npm-registry-packages"}},"1.1.1-canary-ed4509f-1623067811606":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ed4509f-1623067811606","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ed4509f-1623067811606","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d3652e4bb855a7c704453d750b56183e715e4c77","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ed4509f-1623067811606.tgz","fileCount":7,"integrity":"sha512-4F26rsVr6DIiGnPiVD7BRuC6aj2jMi5b0p2zqk9PTCrKIXq9AIMBxC7Fmn0sD3q7JBun/qUwColG1jnTUc8ohg==","signatures":[{"sig":"MEUCICSlfQGuVLn7TTzpjtA2Qmvbp+uSuGVYfckGZTSHx6dGAiEA3Ys3a6wK5/Xkifq7rT1I/+xNz9JwB91Yte7CQpDpbF0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvgzRCRA9TVsSAnZWagAAfkMP+wch69Qr5f6gdTgQz4pn\nnnDifSC/RVt+DUZb4Hu+l7r/bp9KCdWVFKO15N9gyLD1dGcDZQVsTZQEbUKT\nOmy7yb1wfbYVt46jn3f3p6FU8+ri82AP27X3hZ5vmCylnH9fTo7+v80qnvv5\nLW82ucDfebeNWZdeFt5T8sCuLDXhHiQ69Q2Q7oElytoRtle4XX0bEfvnXtcC\nwccsHyPNJer45g0bRX+YCk16lJsmCkc4wdlDVwzWTseUZmuvweRR5m2RVor9\nMNbqv0g63+IW5sGO9mPB11Hv4HAm5KhC+0pDsX5R6EyJIW3+EJiQKPVOFchQ\n+1cDWdTBQRhsOgXPzS0E/lSudU+ZFvdDVeGPdSvRvd2sDCNrYjuLV6tHl2hw\n7Cg4DeQIszJvCdLc545rdi1AZuBUgPACgrsZbmySBJqzPuJh9Vz6EgE8pxlx\nPZ06KraBQPgk7epPdGpAJ4Wr70ihmmL7yVCvBUUXQ9Pj3VgSANtwwqrA5Nb7\nom3BfoYidzQJCol9knpuknI/IuLpH0N959sCmo5pwcWAuipsUE2fRLMdwVYL\n9THDiBPkg1dMwH3NQ2E5uXYQsg732fBjBN9n+JkkoYOnSFZj7WFSMhkCMJOl\nvZiHGCT0iRpDSvpXRBaKIib2telpnUqUfhZfS1yJIy7ZJ4OObCaa/Rsm0mUh\ntHiQ\r\n=D3tM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ed4509f-1623067811606_1623067857154_0.672553636083536","host":"s3://npm-registry-packages"}},"1.1.1-canary-de34657-1623070086232":{"name":"@iadvize-oss/store","version":"1.1.1-canary-de34657-1623070086232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-de34657-1623070086232","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"afa1e688f1bd60902c7ead04f9fe37aeb8312a02","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-de34657-1623070086232.tgz","fileCount":7,"integrity":"sha512-2P6H4Ziq65RBKuPkTTkr7MRrUBifIA2i16lBGpdzhuTFrQ2Xb0oM2Dp4oVIeTbOLchHJHfQEaT26gQZCAyTWlA==","signatures":[{"sig":"MEUCIQDEgKpu2f8j42+sawPH0/LAWGZqC14n4qjjt7DSJH8m2wIgGxpn8NjasIi+FhUQHklhZG1sGzUtYOh85wPV1f5dfaM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvhW2CRA9TVsSAnZWagAAnrUP/0+ztgYr95Qgb4TbAt7y\nLAz5AD32/zp11OF83XjFRC49D3ONKd9wuYT2VX0xEZI4XG6RYfYhT2+zJ4E5\nUpZYzJ/alhMmzIEcTnGZ6AVvspOL1+XfMQq5hvo0axkk/whpCer0fLJWsaBw\nV/bM1uMbOHnlXQ+AKrbv/QQ2R2Af603jOJZmBqfiJom3PEVgzM6F89VD1vTk\nV35Yr306l7spXLP2O6Ry1sy4i33KMc+Yr+7nb4TVGzVnMM7x89LgQCljW2xJ\nnytIwn6ac0P1xXr5AI0Xoj5lcy6gEgLGIt568hL4DB1u6CfEyJGKb3ixZJ6k\nSaFbiYN4Eq0lD9XBH3Jz9/cXVqPT9kGVSz6s+HADc+U9fpsibbLryGzWCS0F\n4iikwKBaPLADRXsdnXFXSwJ1G6uc1oHJ7PoB29pPN5Xb/7rBY89XT/06sYhL\nrOfG3k1YYInVo9ZuYfrot2rQd8/u4Zhl/+RNCE8zE2dP9jKyE1Cy/obquJeO\nQX2Ogc0+jiRqKEB/iZBGfCzWtYV1idhG0uvPIsFRJqrIR0OdJchqmJ4wZO1d\n2QJrC3LAKhunhp0fLbKnZvxrXGd8vgTL/aRZsm6LCBlx4VWBRTHZxJ4i8UHO\nrlCJXOLsm2YULI0p51eqAGm4TNpFGjrmqZ1XwqvHuNvT/lOzszkOEMXwkWIC\ngzCA\r\n=mVPc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-de34657-1623070086232_1623070134199_0.6324725568519183","host":"s3://npm-registry-packages"}},"1.1.1-canary-41b11c5-1623204125265":{"name":"@iadvize-oss/store","version":"1.1.1-canary-41b11c5-1623204125265","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-41b11c5-1623204125265","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c7bd9889112fec35bd0c4c897254635f8d30600f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-41b11c5-1623204125265.tgz","fileCount":7,"integrity":"sha512-Z009S2PRC3/dbZuoCgZPW2/krkVZeDMzTgq2UMHkzOhN1opSbxbG7RqLFrsh3i/FzBbbu9lhq2F7znTKvZjtmA==","signatures":[{"sig":"MEUCIFvAQrbxdfS0xtGnKv95/Bnb4WCazSZ7wxtsRFKSxI/IAiEAhKF6tv3lZs3IQpo8pITCjZinRtwZ/TTyDd4xOY0RTG0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgwCFOCRA9TVsSAnZWagAATS0QAIrJuc6QSNNeyxwHp65H\nKTeDoWq833R+azvnphdrmj8V1OKsnPay5oMpx8I1x2CjK/lRzXnK5bldmLAw\nE1ftcUV7mTDFOsKsxOb9JV81rTBIy1s2KNLM9m6k7L14PDhHcNPYsPwLudCt\nfj3DHfk/5zf7bEeEax5UOVgFe4oZirNB9fb7OWQ8Bp1M0ocssJafEp2GSO5r\nmiW9cvyaesrp4IZ2AENZdXAVRfUmn3td/fHwCkd6k9an2ybiOAWPkBcYJpKz\nozTutgpHMC3hkHQpZK6OITtPqbCBvw/wZzHCM2QEEj/18gR5htlq2VP+xLSf\nEkuc97M8/lmhD6qA2aQMq7D/kFCn1RTwzJR0ZhQIku9ZfTrF62tK/DlfOUJ8\nCFGfohy0uFNv7oT7gCk8JlpqZZ56+b0/RSPAjctI9C5gC4aYa/SVs8YR8RM0\nAl0nEvvPEks24OfssvJqSjZdE+AMMyPGPqwWKDwu+pK+XEuIiBGE0J8HXF8J\ncAgJRujSTNHII2OPF6Qv3YIxn2bJjPX5eppCduY08LWoKa58DFu77h/+KWzO\n8Elz+7i2c7M8WFHUab3kskU8GF56upDyxoBM57Qln8Pa72zbni3RTSWoM7tT\nxGf7ZyYOekBuID6a4XDqOd6Ocmum/nk+lAuSE5Bdcd9tdfsyZLDtPT9MMony\nx1O9\r\n=KmPr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-41b11c5-1623204125265_1623204174545_0.4957506907556417","host":"s3://npm-registry-packages"}},"1.1.1-canary-db0d632-1623636161589":{"name":"@iadvize-oss/store","version":"1.1.1-canary-db0d632-1623636161589","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-db0d632-1623636161589","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d31bebd201a2572bd89bd52df500fa6885c6ef30","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-db0d632-1623636161589.tgz","fileCount":7,"integrity":"sha512-NNHRcFO1U58GapByx9W4rWFG0TI1NjmV5/tss+XwZ0W8zj1d8ppvB0DIW9jb1+8/5xse2bEEh+EQzb2Y8PNrrQ==","signatures":[{"sig":"MEUCIQDguDdu8FhaW1jw+PkkOTrlE0hspwSKrRRbcRbwDSbvrgIgCN0DBEshWOx8qmdzrs4HXcCkMVykS5lTfoImE2XWXAA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxrj5CRA9TVsSAnZWagAAPOUQAIccqpDU2mp5YgsZj+aG\npvfjj2xV5W8K96Oeg1BY/STOXLOBEBJAplWT7kc/TeL5xjbms2iIrTaU99aq\n8nDNuWKpjzBcMYR0w1pXzFg23+wgNjGFl+yeuYE8I9d9m/Ue5b/nqrCcBAz7\nB0XYgebpv8fcNZuSuK94J1O2cHlIJAh8KaRveuLuN8GJlKSKgxdxZz55rpws\n3cKYwTYu6jo8W29qbN0qugLrgXdjapgaOZo43mr1IDut+4FGzRwum1ROOSyK\n5aPu2f7BvuT91hRzzLKHtwqBPPEfgBDdym9Xq+wGXqAr0vMZKreQsMxmS2vx\nM+4wp3WB7CVYvW8hww3GdhJP0vbUQAdBh91d5zVTkXNP/JNtLYwsVOEhehP3\nkeTzsNvQLA+eiks0vzagO40XAe0mKrpt29kF7poVnI/KeeBphGjNJIiOnFv0\ny1Xk+J9TPM+yru4r8gdQJ7a2ruxoG4QQPrIyy+S1Ygllydr106NB01L/Ci0c\nOGgcEqu22FmmwDx/zEnUjv8OcrXGuNUJ41g0z7kGZwzucQ2nE99X3HpnIFh1\nkWOc3i5Nw6Bfx+Gv4lLjH1A0/1EE/OJMjPdOY+cbPtC/lHcAPcMbe//2eTXV\nGBIOdmKlRPHLLGQulxO3dgEuvcd43xIVB6NPDuK0QK2lwQnKC/+EYsIorMYP\nEKOP\r\n=/sR7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-db0d632-1623636161589_1623636216876_0.22338923209747263","host":"s3://npm-registry-packages"}},"1.1.1-canary-db0d632-1623636151826":{"name":"@iadvize-oss/store","version":"1.1.1-canary-db0d632-1623636151826","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-db0d632-1623636151826","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"460b280b9307796edd9c643fa7befc9541e5f060","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-db0d632-1623636151826.tgz","fileCount":7,"integrity":"sha512-JBNZ40lSqeME7AnG5HMKAvS4xqIWP+vKRbB/9pBk4n7YbTtnJjUdXGkKwLWmAg8CMggANUKn/jUp9VpZxzvR4w==","signatures":[{"sig":"MEQCIGQE9KWP2WTxk7B9FHZiDm8XE2+uPxK5C0ro3bZf0DGyAiAijfbpSNyhXjyDmqyIT0hnEpENYfQNuZf59DOhxlQl2A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxrkJCRA9TVsSAnZWagAAkp0P/2Xg0iBi9F6DUKxV2yUh\nFja0QsmLBo4tkjCN+894/p+p5NC8RcV9SQDc48kK3q5pqRWD4G0jUguOC/5q\nItWX1z2oS0Fe1YgXaveN+nVzsRUuA2XuEdLqsZbUleNEjZTDt5bg18upNWOd\nnTO02Ky6X8uLI4z6VJTTsYLdOHbCebeuqpfbvd1GZdulbjbj4bMZjPLvaz2n\nodY4T2i9TFkElsEIYq4m5OJvJAx819uu7XJAJjj2C7nYccvxpg++LsrSXU7+\n4NlXw9vO8wo4rR51iX7AdS1FT1u4c85lPepzkxBVOaGPxZUXg+IgrhoAuBhu\n7ylp2cU4k+LdyXW9kX9tts+5zWo/yntps7IL2BXE2XJ2jKR4b4wqeKnrxPD0\nu5oDFPTjgDQiIUeOAIb0SrP5TyNQN6f0dRDbjY6ppkWOONoesGtPAVBjyJ9H\nxhD8EKjpNjPtTSYaUrlCU585osd7wk+tkXps0cGQ93u5jHufD/ah9PQRK9Jb\nQM22sohBsp+99tt1NAmLr91jlthDng/hw4MLuQ84zAEFcq1kfXLMiq8riZvm\nzIrazUkVfTNH7GT4ltDoDXVGHo/xve1u+QKE/MwJcY4tU1R9L4G6cQFZ8kuk\ns3wrSpCEZCn9BSChMnVl0DMViE+iGyRlwgjVyNpppnTpudIv6aWlRngGapVx\nfW75\r\n=aLmH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-db0d632-1623636151826_1623636233011_0.3198627023056617","host":"s3://npm-registry-packages"}},"1.1.1-canary-10353c3-1623661440472":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10353c3-1623661440472","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10353c3-1623661440472","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"014480670ddf08c70636f1ed6c364d2c22d7b98d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10353c3-1623661440472.tgz","fileCount":7,"integrity":"sha512-JfNeK2x7xcaio3NQUgXJK3i0Ee4wYVWTPcFET7DC2xVBZhcvD/DEjd6AYEXpT8U1ObXpKNf+/9zkrO5rQ0A/ew==","signatures":[{"sig":"MEQCIDkSA4IOv/PNTioaAy1Vq4CVdfcSErJQJTzlE8oWeGpwAiB9zRg991xgjZ11XD6ri/T92TcrxrfCx5z5X9Vt3xfGxA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxxu6CRA9TVsSAnZWagAAYQ4QAJ7FfmCwj3pbwW9yqDWO\nfrUlHRBUKvOYJ2BXXP0BhhtQZT384u1phoCESMw9pZNaqny9gJOC51HBtx7V\nVTxmkK1cY5QaqVLDYh8ZhdxGRd+pLhX4Ei0Aev2U/n5G1t1Gmo0tHZk4KRYK\nilpUXpuux2tTaEOQQk03Qmo3txF1VOPswD7SYBJiv25oTd78fFNOUdFxLQj/\nBGpwD6butcabcnuuqhhNgsDiFmrrUUsooFtmcpeETKRxJvQDjzThZkUm9I2Z\nJ0+q/O/+6sI9uwRuOKP7SOrwn5g0+hXFbvRP7Or0zOaz9midZ8TZKJQ/ApFd\nO5FPXZJ8at/76+snpVU3QM/mpKXMMGLZYesUauMajTmj58tTKS6kLglmdKpL\nYA0ZKcLBXV+3wM8uUggSl0FXbzQK/13oNywZ8WZOaMpEKgNL0X+MOjhsjRK3\nr+bsxo4aPIgtVn+iYEW+XaYUktrkf+RKvUnWxVG6tuVDT0Bdz06TlVBNiNX4\n9x7GLBKG6nfbAIPNL01OqtXgxh1kyV2/LkNEBu/28bYR/tFrizA3fSBAf/B3\nGIV9y3Xn3FLrxdQ3AUi1Pn1MADg3M9+lpn5zmpcAWvG85Czrl5vPVTp9jFSq\nv4oTdqsJR4eGcwHgPApEvn0j/W7IkwXA3Dh6Wv4lcWRiwObtRbJDAsf4Q16n\nRuve\r\n=LPOd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10353c3-1623661440472_1623661498389_0.5964157089717497","host":"s3://npm-registry-packages"}},"1.1.1-canary-3bc6e5c-1623664277221":{"name":"@iadvize-oss/store","version":"1.1.1-canary-3bc6e5c-1623664277221","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-3bc6e5c-1623664277221","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dd864212ce91ed982a80889de510e3bbbe008dca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-3bc6e5c-1623664277221.tgz","fileCount":7,"integrity":"sha512-gGM+UKSXtphh1S7eSrlteHlGsUvsbiuodqVaB/jI3hnzgTPtl510hE/Cyy18WK+kl1zoznk0SLyNIKzmaPQinQ==","signatures":[{"sig":"MEUCIQDdQR71F4EacOhXKtt7dHTQoxFt+k5jnL/55BH1/SoV4QIgO9+zGWDNAkS6rmYv+XIZv29o0UiPxWwnTEJtDfcUvE4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxybSCRA9TVsSAnZWagAArGoP/iL17IjWGKcXa6YwwrnN\nv7UmnptlAxPjNAPtCLJQtDQQY2ahVpM2rnZoASAcR93KcbIgXec5GxTBw8wa\nIz3YM0UlO25YqTMAa/NIXzpfAOZ4SpN5Jlnj25Wq4ZaQZLlh/jHv15st84Au\nbOLZXtnQqbRoTjznrP2wnG0pERQ8oPky9dK1qgEUaTE+tmCJD+ITuhP3X6PD\nAsWRNjon1SISg+88415FzdU/nBITuPpC+BQkmutH3RMLUAG7mYHB1YudGbNm\npEVYZHeqlMNU19YDTb59BXp96h5R2PctxOb0FocMhFxzfLPJzLg0Xs7H0dFo\n7VsrYy+d6F88sFFFcNkayC/Mgax1QJyK08P9/6ZFizwZxduF0UhaAbQ9lUkA\nzF4Ky0MwQFTSEtCOv52xYcCLd0cdOdGXScz9/L4I5adT2ItHjRzv1MitZkbs\n9sio8wXJ+xOn/W+sHHkkbd/M4xG7Ai+PdEnqybi7cJA4rSRXBD/h2lA7NJyz\nZkiPVYxK68HS9AxqLMyvb/Qrcn+pwLPlnzS7YOvvtTWIrXh3gljndROoL1+s\nzLZp72aFJKaJZBmlwjNtERF6bCYa8upnvkW+KnROM+/2Te9ItIg6zk1s5Sja\nipzZWOtLbTsFyteUipJh5+h68i+J19qrMVUPq2TNMPx+h8hl8jk1PKkq75GC\nJdJZ\r\n=76Ch\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-3bc6e5c-1623664277221_1623664338084_0.9197386278575133","host":"s3://npm-registry-packages"}},"1.1.1-canary-3bc6e5c-1623664284021":{"name":"@iadvize-oss/store","version":"1.1.1-canary-3bc6e5c-1623664284021","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-3bc6e5c-1623664284021","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"74c57cd3f5ebd1868519e9c67878f283282c7832","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-3bc6e5c-1623664284021.tgz","fileCount":7,"integrity":"sha512-Ezs1JBRbSoMj5ck9YcYGekN66ddJYsxCRVOqezrkrNHyb6FAArC/jOKL2Bb6lpBNSK/iFMPQgQHdPuof6fEKgw==","signatures":[{"sig":"MEUCIQCPeGY6I7+CW5ne9mJwJbLVlNNJdQ1zp6bsFnINIkKemgIgAl7qqaVGJZDycxBXp9AWtFwX9Asyt6JyBA+cqq12dDg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxybaCRA9TVsSAnZWagAAPpcP/1DcUsimG0hqOCzfWHhu\ngkiprT7S7otGQAEqiNolrb7nbZptET/KAP5u6vHdmhc3jHm8r07kDOOnzbpl\nIVwTsuNqyrOXhPVLaJq0GYYQU3olGkDyB4gHQv20ERwZvXWyqcXmh0H3BFRL\nmflkhsBcL2hVKOShArbU5rHPUIKsv9JtefnFg6OJH+SwiMCWb7TTqaIWusFO\nX5oBFZHDXFCdKTs0EDwS7D0WJy/gURuWLxuEO7bP6hAfILuieyR8RSR8ELDj\n3SDZmI3h/83TPB8+Mkz5qd03DN1/G6O+rCqFfG9KP6hwLsXdz7wK0/7lSfpI\nmqpKemH79kufmeUG79Ap1um1sFXPNjwa7bUKZhW66aoTV5GWsE7kerpMV3Ee\nj0HW8T1wtmZAh7hcQSadtCMakYr5ckIAb8SmmfSzNwYgmY3aanLPqigvHGfM\nhbAkIEEek6ayFtG4yAvtAhRIBFXpFvvHPONSEdx5E4dDVYdvtXqX3tCkf2hb\nRizkbOO+qI4E5cGM5jGNU3flxVaWvRt9YCe3yzBp3qKZEukjMkDNRCq1tvu4\nOqkL0D7K/gIvFj9kGFP3qya+uUvwQmbe26zZn5bfUkRTl9XIb58ZegIRVRZI\ngZM58h0845R2WUaLrQJ6oE//RR+1PVaNl2rKASntfRPz07ke5eTTKw0Ok4rK\nsO0u\r\n=14pG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-3bc6e5c-1623664284021_1623664346347_0.5519665514943217","host":"s3://npm-registry-packages"}},"1.1.1-canary-3bc6e5c-1623664308588":{"name":"@iadvize-oss/store","version":"1.1.1-canary-3bc6e5c-1623664308588","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-3bc6e5c-1623664308588","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c75312295669f213ce7beb5b41aa5299ea703975","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-3bc6e5c-1623664308588.tgz","fileCount":7,"integrity":"sha512-O87ZB4CkETckMmnSqXKVdI+IC937SQNv2Qp5mq+yupdQL0NnrmB61/vrZuO7Ph6aDR7lrKSUAEzF3pW0zdPs2w==","signatures":[{"sig":"MEUCIQCmiPkN0r/22EbF3KpMoMjlfDhb2U1cejs1g6G/uUBBxQIgIGAzZeLqChWS4OEmd8x8LZdqOebP9CjwNqDJ4lC0SDE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxybzCRA9TVsSAnZWagAA5i4QAKSRjLHQB/9pBAfq66Hi\nwmojHDQv3XMFoSG6nT0g+hQcX6VN7B/F3yMzg0VwRI7zwyQlijW3NzAn4EJ9\n+fAThBMNlU0xdu5XhSspExyB8hIELJC6PHV/cYX8XyYD0KnqLQTjMvzhhVTX\nDWOw3dhgk7CJllU71imQ6CNevhEPFGh28JfsUN+zzGTx/MfaUEiSuWGq42r3\n/Xb6+gu7uptSjMIgbvcEYuYhefy4n40ilVdqrBzK+V4Id86dBEJbgEMSceOx\n8DI7MqqjrfmBsp7ipeO6rL6wkoMfdeAlCo3UP1D5y21zU9l2Oeuznu3Ov8t1\ns++F5F7rJPcMi1Pj0xJiqaLbAgwrc2DFoalzxFwVvQAzDQZBV3A3mm456Ud/\nxH+LfPA15rRd1x/lDcimEhmdXi8fYHHKB+Kw8Yy0HnHGBpZrS0ZyrHP4NliP\nMCJ/Hqan0BBbPR357T45rnnulZg7gW0DSt7oWVfC7Cw5eb7PR3Qxp4VJxI4s\nN3jidfFYA2IwDMNJxiZlxq+p3/Mlsdxr15Gw/xoGyZerHgdKfqIQ/elnZeFN\nlVX82wdhPtFmSAD+c6awt+dcj3IEk+Dt19w3cSF88zl1AGtqnVMgPTZdKCCm\nwSSBxzM8qKxQH31fb+beczQTigKR7HM/sbsVP0oQQ9x703OWjhF42ggjQuuN\nwYb0\r\n=+xFE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-3bc6e5c-1623664308588_1623664371012_0.9514771715078063","host":"s3://npm-registry-packages"}},"1.1.1-canary-3631be7-1623668120673":{"name":"@iadvize-oss/store","version":"1.1.1-canary-3631be7-1623668120673","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-3631be7-1623668120673","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"03a6578e8c9719854e8b22b36f508c9fb74d95cf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-3631be7-1623668120673.tgz","fileCount":7,"integrity":"sha512-7HYUAewdlVPbhoF4jcgafgEZB5tTfFo1lKI5ScSvy0kLAomr5cQup5dVS3/IdsAQUYHqwEJNXg07LHxVYSuGLA==","signatures":[{"sig":"MEQCIAbE+JDe02rpXyEkjRWoK5naayNLMm7qP3syzpF0P26KAiAA+MmzebPbveKTQ3811d+wxTTleIpFvFMypJOEEXgDhA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxzXLCRA9TVsSAnZWagAAkO0P/AochX2moUoqD8mN9oGc\n6X0LkxlyLeVr660peX9oEY/nGkVod4zV4Qqag0E90NDuaPy86lUj+vVbRYOo\n44xXRjM6EQmoe0emCPj8ZYRstbqsdZROXkjhg0zIMl1HZfRbWAm2TrskUKWz\nlBGiVpwTUvYvA47aGdaQMTfyjdNE00LH7bGwCgcZtGv+QMUxY9mT/UEr1POD\nw0YNGSDFXCHWkkyENOMTPcYmE4cPb8buZQuUSK/gCdOOivWon1yoHGUKA3Th\nfNT+SSIAHpaW2VenJp2YbQgGYjLPgYI4m7NMT2OAobuLNMM1ZoEreqJoLkl+\nXcmwP/8AzHGFy0icoHLGKbT7BEBhJtNwnV3/nZLRUj1x1di1HZQ2L7XzU0Ej\n2tB4Zuyc46qsMUCRzkQy93bqx9vWifaUUdonKYs7VDfLyOJ5Twl4ARISayOm\nmshT7G9hsKSuHsU3eCj8MDFRzJdUXDT4BL8fIM6Btc5Gn4/76EHv3mK27kRW\n+JbNCxY87vIzsVpGfDJPnlMWyBZOrkE4utYT1ax6aMsf64piyrzFCfRiuUZu\n8nxUQCmVvM4Ry4pGszTh3hlQ1Onn5UOU1OikzHIVBl55MJUqHqN6J8E5CYom\nu6SSNlC4nHUS1I/ogkumurKtV76YSAE66KfuXsQeohKW8E0P+5BU5BwcusEn\ng51f\r\n=DX4A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-3631be7-1623668120673_1623668171421_0.9784125448558731","host":"s3://npm-registry-packages"}},"1.1.1-canary-5f4ebd3-1623686644087":{"name":"@iadvize-oss/store","version":"1.1.1-canary-5f4ebd3-1623686644087","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-5f4ebd3-1623686644087","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6df40b80beb8dc88df270d206af1869ee858996c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-5f4ebd3-1623686644087.tgz","fileCount":7,"integrity":"sha512-0ayI6WWteUdd3UgrbcRUq/knZVjiu6uqOmRZ/butNKwXR9lNuhFgo1QttnBjLfD84WxNvguE+SVmxG5gAkeTbQ==","signatures":[{"sig":"MEUCIAaDrqyJr6wZ9v1FGm9HgaIQ/jvXCahycVin3Nwyry3WAiEAyVWB7CD44hSRDjmUto8j9swgHba4risjJ8NCmQNLfpw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgx34pCRA9TVsSAnZWagAAy4oP/10ML7j0pLZiUy83Qynz\n2gAQBONZXuTWqnPJeqj+KgWAxWIazmRhCPyDpaNKdED1vfYGwJao43m/6UbX\nUMgIXOJB96QeaqKoQ+ICXxUejGiQR7V0ywrwxf5aeXRn3ZSj/0mC36+foUcV\nb9aHPlXQoZLIY5Rnmzg7qyrWQu5UyEG/ukdRuFQBNjef4FqhxhPpfbeWYBUb\nTEe/5ZnsdJNsVWWA1+jCUxFzxXL46SNyMybnS6D6EcYqti4C4oDQVfI3P70Z\nIx6PDyZlPpkKjBs+xbuzZ0iLk8QAr0SHhZqnuITGCa1E3Dnbq3b3qQpjX7Jj\nUPNGbsHNz5ZLiLmhSwhyIr+dE5dxN21CMCy8+jRaaLA96euIofs+CWPH92OS\nGXgkZbD/uAGt3YKQZipyhDTLk22yesCG+F47daT5RLJyccJwT6fMsgMioxQq\nnwxGnDQ0FnmHLgfNPo/4TiSBJUKGzya1GOnxJPb8SjIe0uYQGY6kk1I3uiwc\nelUR3i2+5TwQ6/SRVTESeyDV6s1tQVSPgLleXvUwIu7z/SNCseXkvPf0mv2b\npx7zvryxJHCKyfa7EP9tkCJ5h4zxaNhHdEqFmU97O8bTj19bCa9ethynSVRi\nACVu3Q2dbwmghRxHlGcFBo5T3iClWoqRGSMXVq4SMDkaCR0OMhqjDJ2fr4bI\ntV3L\r\n=hDrl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-5f4ebd3-1623686644087_1623686697717_0.06273711430518891","host":"s3://npm-registry-packages"}},"1.1.1-canary-26896f2-1623687595587":{"name":"@iadvize-oss/store","version":"1.1.1-canary-26896f2-1623687595587","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-26896f2-1623687595587","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bd9f0fcc8e44ef497cb996731df02b6be5a94910","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-26896f2-1623687595587.tgz","fileCount":7,"integrity":"sha512-YLbSU0BUT0lHeWwkUAiNRxaseVFh320JyqWKccDATEUw/EMwNJ2dbR87iR5re30O7Z7cDJbpKZD7QlXR5y1nIw==","signatures":[{"sig":"MEUCIQCsGPNkTTS7025fxeT/vIlLXngYi93Dz/AkFJQezgC5vwIgD/yxHh7kolxtGbkP8rNlbmdsbj/T7uwra4289VPe/C8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgx4HbCRA9TVsSAnZWagAAgDgP/1dFgM90EbhnmizItJyr\nMtCxhwzhvBp2o7QEE4C7Pp11ZBAk4iKrlkrJpAJq7vetfDFMcR1L2+RwY14g\nzAg+QcGZvnfBfhVSh32/LM5dzlJzuSipL1vj+QDwTj5IVUOq4MVzV54D3Od5\nuct4N1nzgA1CWUQFZX0cvFWlUu8rFFQ2DP/Ef5aUXu72Ac7aLxmU37e1tPRe\nza+AA7ejPPgFU2oEpW7TzmsiEGxbHdNkai/C7WCxnrSe163knjtRMedRL7CU\nMZDBaVxsv9OkoiiiBXWw5PP7MaPUOWZX6ahZbhPwuKPljCmeEkjSnBCYtMsv\nollwtTVj0J2aATaPk+7gvklriqNWQvAte64wPojxi2cR4HHCAewadPFIsXxE\njrOzWDuSmNhYIk7aduNrm6eNXXfhLUHa+KXGEbGcfynQcHPT0+XoEInkvH4h\nCkRFY1ZCFoUe4NaXNVaC8eLPt672mTalnhGYJaKG1srEe5Shk8/+inUQj/gR\n5Zm8VKdFmn3epxcQ1CCoxQfZKAl2wZ1c5yAWC2srGQEekZL9hgJR9DdU25Kv\n0mN7pTeELNA+A5wnhYwIUNyET6WlSf0sYi+/sRPWAoRz/1B9P3bJO/MARujG\n5DDor9TcgEAYqPyYXB0Cm6jz/NouHMBN79zeliQrRt0z/DEUrzhk9P0H8EwB\n49Tl\r\n=34cM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-26896f2-1623687595587_1623687643146_0.7652152994511636","host":"s3://npm-registry-packages"}},"1.1.1-canary-ef86f58-1623895413866":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ef86f58-1623895413866","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ef86f58-1623895413866","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0b29b46a1d50b850a143e826c7068274afbe28ed","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ef86f58-1623895413866.tgz","fileCount":7,"integrity":"sha512-jJgpB8XM1L0yww72RsO1qNLEtHooWuKP8hsYy2lZ9GgpKEg2Oct/5sO6q7u6DMF7joIoWPUKqHPWDAZiYIfpgQ==","signatures":[{"sig":"MEQCIGbbS3niO2hTXxCMuPc9KAsj0E/4yyCANry27VPz4kykAiBNfDAkHDo+RReuDobLS0Z/OPk4QimSgY5OaWFqSoPmOg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyq28CRA9TVsSAnZWagAA3P0P/j2NvuVgD+15XYrnYHLy\np8E5Uuhcl0seLuDnLsAoHfa/3+LPlxUyOEDyWjcyK6+jfRRRkbjjXi2Lbvwq\ncbDPT3AbzRx60waNHk/rtCit6BThodfU9XIR/mIOHB2obG36Vdn74xb31n0P\niEbgboSPNApy4xvGMWV+hTrqOCeMfdznNa4B96o5/ppdpGnnohirMmuwJXcV\nXLNdHBTyiFpSpuTAsCqrgj3fq8rXRRdKmSAw3DmDWMqGpNxudUI5uHKt5wXf\nQjnWD3cFe2G38Q5U0bSBNax9N8k+5E7pe7ZWZnTYyRu2XDOPi1NVl3l4Uh8o\nzw2io26pph/nfaJIoA1YDaiNDRQcMb/kPYrUtJGJr1mgDWmJ0pI62iEIZloo\n7lnFfUcdooq2jeAdolmlK0Gi6jVnQDXL5hCGKmsw6/ArqErAcU1v/azBtEQW\njtTAXaJFHR4VJtxsw+q9UMRkfRfCau8qEbyJVutcUmJHzAXFZ9Jr9uQvEjrT\np0d4Gzn4LNRGp7ZDVuJUE8TOrhCJooyRYKB/dMyHKYe1GXtLpNNnmZWUEI5E\nqHiMBN3aYgWLXruWQGfY99ky+QSqzvffu9N49i0WdmIfh1yw8XKnIoa7Iz/A\nv/jtZ2s9z6d5BCwCIJ45n53PcvRLxOuYXJ9yMg8RrbmC4zvIDIDLoRjF/p43\naM6I\r\n=1Ftz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ef86f58-1623895413866_1623895484385_0.9075863892117346","host":"s3://npm-registry-packages"}},"1.1.1-canary-ef86f58-1623895388474":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ef86f58-1623895388474","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ef86f58-1623895388474","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3f88ba6f73174c356099c468c229cbdcf11d8535","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ef86f58-1623895388474.tgz","fileCount":7,"integrity":"sha512-8KtaBOqbhR2Wj9eulG5izD9LD8cwBd0smZfeoKE7peMpqr0RJ8Dh3wuwKpmS5SLtqnftU8twgb5A+0EhvFG1Sg==","signatures":[{"sig":"MEUCIB18LBVdCX+Xq5UsHunNNooSMDhxOzPzeTMG0b6kZjm5AiEAol+9z5cgQlgGJ9Z7R6oAb/dCQotMvLpyNdTpL4TO8Q4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyq3LCRA9TVsSAnZWagAAQ0QP/13gejH0RpleQNZQpl7V\nOePiP8rko+uAo7HcwY9fHcfYili4YRvHF+7OJhz5ByRg5jtPXj+3JJUXi9r1\nkHMHjAcb8S9PzbZOz4ADoFCsA0EeNEj7vww9GC0CV/MC7RxaHDnBii1gzOad\nTQ6UL0dKoX90K8B7I5NTUp7U4C3LqjP1Kg/S+H/8T8OHVegrajs+Y6E4ict5\nVJ0i7qIhaPLc+fPe1rKyasMUA69vEYvC503ZuNlgd9nEu6w89sxJLQT9c/R5\n9OzOrNWjQjC1CFxsdM7pU7ImI5YWxiEeWUGrASJ+Zp24v8CKhCV/Im37zT5Y\nURPRTlFfeXacjOsSD81uqOX79+grIfdOZRQvxLUCovv5Kvvw0A0gVet9D92O\nRBRkCksv+xnq0fWgkpWZXgXab/owNUTha2pP0x6x04RbsYrfoB4B0PrQ6s07\nuAx59amxeKs8fgEumMjV66/8O/2hBwm0rJ40F4F6/UdOqGyCkCAQSu4v0n/Z\n81vPNZBHyr5WvJ3wgqG0j+4DMCc40xtk6AY/63YGJGltRktvRwOIvvPcrg6F\n128I/bP+wLpTkkZ/kllxeyW6Gg5dLMwdaii7rc4mRvJ/uHngqEukeexARI4R\n8Q1eq8wNwaNpvH6bqjEr8lvFlapvmN+xhl9zYG7piZ7gcqQscYEF8xcZAGFx\nlfXM\r\n=6r/j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ef86f58-1623895388474_1623895498654_0.22548335702811118","host":"s3://npm-registry-packages"}},"1.1.1-canary-ef86f58-1623895476507":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ef86f58-1623895476507","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ef86f58-1623895476507","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"23fc66fcbecef6026e90d042f96978f34f6b6a5b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ef86f58-1623895476507.tgz","fileCount":7,"integrity":"sha512-rswsl3THZIGnIHfWfmEARQ7PpZihQsvZhBy9vg+YGPiz1NvRWkgVplH9LoKuPvhTxk92RRF2a5R3APkY2pdSmg==","signatures":[{"sig":"MEUCIEbN1UZggUrn/Et6fUizSh5kCWATIcAGTrVwaIUyhzCrAiEAyGQdZ3qiUz5GUCKVnW/fBJXKzsMi0L2cS/3qfqagM7I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyq3mCRA9TVsSAnZWagAA2bwP/RQeGehZ35fcfcOe1eR6\nlWMbsX6VSHHPiBq5EWPKOooGQG2u+Y2fd7fcyZwHimwfdUeqCeumKTnEx7Yu\n5/WFxN6507ixQ1rHfNW11VYJtg17h9cV6vo3x3gooste0eXQUWv8Uvm2rK+j\nZ7awiA8ve1gLBoSwIFi5SVG2mOWFAiDjlcbmpn5Ka/wb4pBF9/CclPN9/xej\n7du8m1dCocrL2W5FiRMlKOS+Sgey4H+6hR9yLJOE8Vs/hjeKr7ZXDBhsJH8B\nAtolNWkPp0My18yaAB7tHYtufpYXisN5YYEOnKo7FlKs5SYKW5gpJUo9XPHb\nR4fFNJLGgh5Xxj77Q45MBRmiMp3zuhii+1+BHyEpmcyZLfZ9HwdVewHvyh2P\n301mn8o5UOtfNoex5KUQjoInwtd+bERThyHw2sjjwqLokFJXVVy4CoRUtFFN\nEYgpNTx60jQHWEDYGUjEjXKv1Uebgn5C2YJqV/bVE1uJkIIfSeqCzZF6/p8l\ndNFrRGRMADTuNIbIcSc5+ouYIaf7JgDtlDkohxiaowb2kUPoVSuKiTFH9cV0\nNpPnkcqYAmq0m0vEE8tR3kg5ATGkH7GzCY8p5q4eSpqDxSR2UpfVqBJzSwzy\n/UCPb65Zut/ceVJ0MC0cEgnEEAfSXqo3u2chw8o5Q39ptP3NF280zFEjmmrr\nAnbK\r\n=yMiL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ef86f58-1623895476507_1623895525891_0.4900985439769363","host":"s3://npm-registry-packages"}},"1.1.1-canary-ef86f58-1623895479196":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ef86f58-1623895479196","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ef86f58-1623895479196","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"33ff9bdd5c77693913619174741a27477b4d20ce","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ef86f58-1623895479196.tgz","fileCount":7,"integrity":"sha512-vKKyC83GDY7faHLO+AGexutUrctEGXBJqkBwBweYUA2PQNPOK/qEg8un1IkzkWJKpeYsX5Tzy240H1zvgSlUhQ==","signatures":[{"sig":"MEUCIQCWh9w69wDUWWhATOx2QwMwMFtWKuYhTbg6bzGUnEb5KgIgdizs7D0ksG72UN4EiAOusSanjoxPz0zLVdg2FahD/0g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyq3xCRA9TVsSAnZWagAA0ooP/jYcelW+aFTxF58cO1hL\nPhP1rPwBmxBFQBdIkPXNNo6XzyFxqw/ZT4tYKOMnNphMNkSZlDX2Kl2+l+24\niMXD2N6G6PDn57hGfbo2LaYX0K7fcXq74CoXdukRfqWHcCMgBGe5xVQoUGkd\nZ5JGKMV6CEwoy7Fzv70o/ZxQn0TZg/rzFPFxr7nwv7H/b7MfWZ6HHSfdAItc\nb8Zz08dpBnJYmzcvLNOP2eYPBN6ziFQocxzuw2F8VEtCrieujZfDxtI0tf2+\n4wVO65tSqb5YudNckMHZC8bM3yNp/jAjnNHxst2JxQPcZjnWJQ99F+NyP8jl\nJ1GRv7+oVic9rlhrPhe93ObmTeMAmfhfceX2rKOWwhgv5vjj6iPip6cJghgU\nuizSbDXh1ekNcb0IrnxG/bwNLAYpBcE1X21ZLoxDafx+0TezEKiyZhOgUClA\nJ8pkqT0KNJYG1jWbo+JMHs2aYyPkbJPlNS1S4+U5WTA4S4+QTQWTYACw3nY4\n2I86HCGZBbp6f59yDJcatfwIuXADrINW8/frXGmugetNyd6eb1udIKfmNlAM\nGqjOtkXHgRpp9gdZ1vE58BwMgEQbZ6dmoadgVinfQuKXnMreNjB+LexpzHfP\n0RwgOQPCF/ckqtVDxh2HcCYnoT0CqBmnGStMiPEneGiqaTuf9RNgJ3SxAO/Z\nIOA0\r\n=a3ql\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ef86f58-1623895479196_1623895537372_0.20318891817891704","host":"s3://npm-registry-packages"}},"1.1.1-canary-6ba0e3f-1623917619543":{"name":"@iadvize-oss/store","version":"1.1.1-canary-6ba0e3f-1623917619543","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-6ba0e3f-1623917619543","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2d32ff2061ae1796924107fc2b33f2d70f207afd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-6ba0e3f-1623917619543.tgz","fileCount":7,"integrity":"sha512-vETV1UBAxy7yhlcTc9n0GF1di1yogR3+LKhs/SbjkpADxoCngSBexEP30/8rdpZUhFKuj/laQaktRzqEAXwadQ==","signatures":[{"sig":"MEQCIB2L4LKkbmNYduG9x6ZrxtgjXv8llm98RNw/jXZI1qaLAiBPu7l5SjtH8wP3qoO33LdgmgUzxxDgpJ0+4cjGb8HTNA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywSgCRA9TVsSAnZWagAAEq4P/RvMOeyjD4U5HZNbT3Mg\nBPAAnGcBskmy8J5GcwbUGAVJvP68nZBTPUAOb0+++lPD4rrWHIS+RAG21FvQ\np0yNeBypYUNWYENdx3LQBNwv4KObb+h8hDAf54GZI9tthn1ZDbJ/MVJqE7f6\ngdPHa/mVLxtjfPC3uivk710Tl3HtVrW0xewZAjvgQ5OLxHkVfZvuQrXQ0m1i\nvBQ6nrf8Rc7sUFNM8O62njCXiBbg6NoADB9O4fxfoPkU5OTWMsBoWl0vlPq1\nI5zIiWa3I1R/3NWX+P422rTMROcpn0qj5gT5mQKsQlpW3PZ2xJ+GX73rpVnn\nMJUHL/LOuypXCKngi580XqGBcJ4uAZ05r5O6WgJ+8mGJt8LBQPjT5vXtAJ9j\nKo0AgPs+g1wS1dfrQ2k/t7+nBzTk1K13t3oVTrQsWarzSbYrGEmkTMRyG4QS\nOubHkkcXYGmJle/LueojMZKCuQZwZfh5t9pTKhxQ9wiBhqhj4hMgkEHHzrCR\nX8F4L0JoXJkRFXEws5saJ5KaOOswMpYVmtLM9trVokUC8MD8NjOOnVm/I5cq\nOcCYUzUxvVJt89s2rXg0Swm/K2/aT72UydzLcCrabWwuwfuslJBIF0Q19BsQ\nVP/lc9yo2ielyNMx7ujrvhJ3esSpGwz+Jteng89oUi6d7k0ZnLxAtK92fsRZ\n0clb\r\n=ex1i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-6ba0e3f-1623917619543_1623917727928_0.963147759264775","host":"s3://npm-registry-packages"}},"1.1.1-canary-6ba0e3f-1623917645004":{"name":"@iadvize-oss/store","version":"1.1.1-canary-6ba0e3f-1623917645004","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-6ba0e3f-1623917645004","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"10993df5ae350fe09731d9e671d3471f9a3d174d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-6ba0e3f-1623917645004.tgz","fileCount":7,"integrity":"sha512-Njops4T8+W+nwtDU05sEe3woUOJBtW2GznxGXsfpUFppNCigjWHpvX6Zp9Dg0JltTRZyiUVoixvAxRvXoEDbzA==","signatures":[{"sig":"MEQCIDFr8XAlf7K6L5eO1SyAgpOUQ4X5Mje/tW6g5ZmVXVFMAiAAvfhxe6rgUROffMO/Wi4+A/BOvWqgOQLgPUwq1wN+ng==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywSrCRA9TVsSAnZWagAAGHEP+wTVEGvTY6OOmAWRZGjG\nJLEOdfP6cQA573ZVNOzP+AP60h9rsbX8QiWzGxqH8wnfef8sIuH6A3XZOkfe\niZ+qSiDBwgEwT9FM4ooLjNEN8cJTeV8j2ilY1PT99SRHU5G9ixUQdYgAwysb\nzh1npT5yefwtNzsnhWfWEWyv47kDUAfgg+rn43C5CobsSCzkdXvFsPALCnyv\n1qXQ0wB6DaNS5+JgsDBv/URiLifxsdRi7DuVkiJ4n8d4RPX3LZtifHWao8Yw\nhjQP9pyf301sZoMKk1qpdFk/KAFmPJapIILQ6iJ4xlK55m5+h7gjDQxqHYsp\nG/Z+ic08iMq7jcIm459oF74RrewKpWtD/sxLBex3l/QkmZw1lmXaWpGwtVk6\nP9IumMO+VBNC7jcnQ/RqefEuccKSy1SCJOyA0HULLLN5YjftzYC1SuiUMu4Z\n8IM1aGl98xOB2cdRh/6J5zIoOApvyTygaT8Q4+tv/p9KyMkqjT9R6uTTN04j\nLnwz3kbw1piaRnzhKQHcg4DPeJAo5IhcIFZ/jgn5/PEbyqW+RcIe9rK5euTN\n/c9lb2mQ+tBpNgQpioQYXgshF9pABW/dPt6Ugbvr61XgUv/lT1z6LDeDew7O\nigcqjBcy9BbDJ+krYC19zhDtyNmrYaaXwxIhr5WQpfmyeAzs2PibMJj8FZfw\nFvgu\r\n=zp6F\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-6ba0e3f-1623917645004_1623917739037_0.2910795597062792","host":"s3://npm-registry-packages"}},"1.1.1-canary-e7a5de4-1623917845252":{"name":"@iadvize-oss/store","version":"1.1.1-canary-e7a5de4-1623917845252","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-e7a5de4-1623917845252","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d605bac86496cef11823376daf9a81cb0e70dea1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-e7a5de4-1623917845252.tgz","fileCount":7,"integrity":"sha512-qS1o2YTVKfruJHU+fpWxzcdk2oDYDjGCxW83gv9VlB+/toR6GYOL57qyvt5lKpOUOa9HiDBm6XLgINEsyiG2wg==","signatures":[{"sig":"MEQCIHD439Fy2W/d0nmh7Vox3E3P7S/zf2z7IfirDdvfeVJjAiAKysH+kvtk7a6QszPXG26ttDxZcoGi2a2qEnbUeQMEBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywVUCRA9TVsSAnZWagAAzFsP/03V6q+tJpe8LMZrGM9c\n4ZTYu9j59TwtB346cI0dl7BkJy6YvewtFTtMjvMkyqIo2Z6syXOtJ+9kJWe9\nzJgOZJFiryVNBUR4yl5wLHPeol147Of1K0oAgeq5qZeQI2rp+oYX1Izq6EL1\nhq3dUXhKuVeIbBzQKESsQQ/+jw35f+GF5V07qygVHEkeYCrFkzlkKpBT7Fqu\nMBK1fs3gsoVo090s8MeJa9n95Sa4QQ0FMpSOisIcGALS/FpvNaI+33zFNAys\n9heKYXOyDN5G5/G33cSd7KzD5fCk2DNod8FZq1owZLFvJ6zRam3yKDpwf2Qf\nA5llFHD/+SjttTN53nGX5txSgp7CIL6pFpSB2/f14CewfwuZcFl/R4zhK5EV\n5nac1jGVdBhjov8Wdeb82wCQa0MYVPQWwYK5bw0SLIHwxplIajHmQRgFTxsX\nXH3bxd++r0OX9sS6pfvSJAJL3SyMQ1xJ4jf9DqQHVcoeMuag1C7WA9RTEzFv\nnlqcXhAPk1VLMB0IYgZqa4LTSOod9eAIw8xf/K73Le9nez7pQch6TqPqUw4m\n+54r+Uk0sRJoViMN4ctYRqMuAYAWgJnLGTdnYGU3G0ErU45xNGAQwX75H1C+\nH0jC0zHfDDLznsqJlOv8vZsPxfdimBRW7VlZIsRCY4b+33NOftQ6TJlm3I17\n1qHu\r\n=2yRZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-e7a5de4-1623917845252_1623917908480_0.28564312326322305","host":"s3://npm-registry-packages"}},"1.1.1-canary-e7a5de4-1623917857399":{"name":"@iadvize-oss/store","version":"1.1.1-canary-e7a5de4-1623917857399","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-e7a5de4-1623917857399","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c87773ddb0a848d565849314e326d4dcb45eebeb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-e7a5de4-1623917857399.tgz","fileCount":7,"integrity":"sha512-Yu8cl1nGvdMEANhw5EjnDdXIB+wvLLCJiMuTSR1KEc8xpQNSRndewGnukS2Az6A9XgLrXU9XilQytublqO1FVw==","signatures":[{"sig":"MEYCIQCavGlGG2WxxAuiQSuEASqUajBnIODdF3bf1BT+s4ldnQIhANhY/XGFgSquqdJ6XQKAYplsLPrTW2uOkEBLJKhvEmun","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywVdCRA9TVsSAnZWagAAlEYP/0dxz5wHmqhNkjH5lt4D\ntg+mEUmtviQk/FCVoGl19e+eJh1ZThEFj9QpvWiWyeZCDybmGyvsbcQnM75k\nY+S1sXGppxwlSSDkXQ0nL5APvUJ1mgq2QCf3OF/DTgpSTrDgd99esVBodYs/\n8vje7cZchuuKqCGgC052eQPwnDwLjfz2v2pR90Heyb8aJROTDKiQyBHJwgkv\neDMinH85+Oxj4hJ5OZti3eBeJcniVB/w+5RksKhiJ2Xslqi8zf5GWzbuibh4\nJbruNO4iollbnGA8be/2hKy2pwj5Ru6PEXN+icGdZM36tbYiT14ACUkFicEY\nu0uv/OL7X2iJh6R/wwNB+PPOy0wOrkeK+yyJpfjhLrig/bG99e0PgtJ3el1V\nGuqLfcE7eJg4/Mkn6F2T2VBO3x2ZE5sQTAHmGu1PbIqPb09+Xo2l+c3m8CCH\nYMTPETEUQlE5CTT2IPp1vlrVpjYq5Tb+MxlO3E+UMzDMjFBgktruJkn5rHSH\naHIXWWae4wqlxipzFmlhanMnUH4lCSCkZ6xpFMVKEyREC5cvgTP48LDNRVAb\npt0OxTMSULAX3TzIIRUQE4tNtXaGWkn1GcjWPKl1RucBzt7CNh+CdjFpo+gT\nwthhlFSgloYXYqTXvE7CYii9Ri1xFTCKCQumlgUrkSoq70lDT41gjos4gKDN\nRhOS\r\n=HTnO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-e7a5de4-1623917857399_1623917917322_0.4644356673084138","host":"s3://npm-registry-packages"}},"1.1.1-canary-e7a5de4-1623917865117":{"name":"@iadvize-oss/store","version":"1.1.1-canary-e7a5de4-1623917865117","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-e7a5de4-1623917865117","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"eb2692d9ff7a451e390c9ff9d06a36e7efa566ba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-e7a5de4-1623917865117.tgz","fileCount":7,"integrity":"sha512-k7ghVhAG0l4t6+tiV0rls5s5inJatqnzyW7LD9SHt0g72uQ5GUmFknWOyl1bUUTYFfQGcIS/SaVQfBt1L21zIQ==","signatures":[{"sig":"MEQCIDyor3MwDLV4cCw3jkxM2PAGGTVz6hOqlo8HwPfCOeR9AiBCTNqYT1lSNvAeU2KRxnGY8JFvNBHMcw/5wqH+wjtuOw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywVjCRA9TVsSAnZWagAAVrwP/0L53rxx0bQQqIgUfb0A\nNESJZei54L+Q4Tjsz8tgNByyOaGSO2+BJREqFkAf0DZ4xR0InNiQZCxynLbL\noJmN8Xa+0YxJLKchNVkFoSaSuj28R7K/TG++4YM1aoTUFBFPJhR0d0G2dWlv\nPD6/WU2RL20PoqsGMBUikak/zgj4IQ9mGp2f11uRuk+S4JWbBOSNj20PhWZk\nOGyUYTly6XY6YtxfA7/P50/ia551jEeA9u4WKrTCZR27w+R5eLCrSec3AhJm\n9g4WemvvPReORBUvFa5h/tDdNFyDrFjnAdKKUfbMvzc/mXBgMlwCvRM6lfwC\njnubAjA76JjnCa+7C/k5LIFTMcQAcc5UOLRqZvykF59t5OXTMHhdmgW2fKog\n8G4ObZBOtALfKsRX7PRAqwa+yHmEST1brYpYZW6j5huGb3wzRRDoulpP0Qa9\n1t5ENL3t7wu9En5LlvoA7dtyGx6w+lc7fsawJTRxg/E7TrNSCHb46l86/EiP\nzGuIhT0uGCwFZU4Zw7vrVePS5X0Dvj697QiyG+9koo7Ptt0rO3cUbsOMzaMz\nkuqmZoa9ahk2u2olKLc88ybOjjY/5Ejp5VI4eONUiJvtktgd5KHy3Mso7MiO\n6X2p/LHyfld6cNzze6zvfqAk72Mgu81wux1MUCjzU+fPunvWTQ11wsNUq4R5\nCoxQ\r\n=pwdV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.2.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-e7a5de4-1623917865117_1623917923172_0.39764372462932673","host":"s3://npm-registry-packages"}},"1.1.1-canary-5d3f62d-1623918007319":{"name":"@iadvize-oss/store","version":"1.1.1-canary-5d3f62d-1623918007319","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-5d3f62d-1623918007319","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"53f813d39cbd9609fb1e56ccebc0dfe1ae0da196","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-5d3f62d-1623918007319.tgz","fileCount":7,"integrity":"sha512-+UWa3advIv8qgufZxzv1QIm2LkyLS9Z4q7dQguYXlKUbzlMRFt/I82jG8sPp6YE2BVd6vrP/5pm9L+4KM/fxBA==","signatures":[{"sig":"MEUCIERO2f44VBzuPZdRMNm6/xUZtQSAEAN7Tzoj7zaouaOrAiEArv3sIcLIvbce98lXg37r8YTKp7oGqIvjHsiQKldI2k8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywX4CRA9TVsSAnZWagAAJIcP/2f12rhr0diTVK/AD85T\no6yWh0WeG+YEl1JvnW5Hz0Bs71FhfoF1caeef4Z50xkwfL8PVIKPIoYT7Tmj\nVh0LprePVCyQlAiY3+w9KPhImN1Yc830k9BfxgX5ZMUDOreumeQOxjZWBPeL\ni3IsXGpF0Q6OtQqFBReTzQpgK2gJQJ/OEYDUgeDCSY6sRY4x1jYuEyACju6n\n+sKUxNUnrk9/tkOib31as6G7MuT2K0DNv21aYHUNuIcXgALAFr+UK9gtntcC\nMrFc+M6i1FguwDO220iGD95vPA1JA484yPCX0Hx8nQHlexiQdCGHvAjNKEyX\nfi9uu/OvzjmUPezY/RspQ8DrSDZpIMAGNAs6YJCI401Rn20z9+XZgXsCIVcd\n2G8xjr5goq1sekKaSK/twNp45DCb8Nw0fpOsBsv7JlzVyNcdD3Xr50Bd7thS\nGG2ht6/iZ43uF6VVav7NPLca1k4W7lL90xrM+7ougdLF8/ohwnwoAXAJqISC\nSjYDmEjMgHf5rSxdHN15GK2Ib25MVdLpNazETXfUM0JsZaSVWioO2ln96xWd\na0oHu+25yZ8hVPhVHQwN7zHUQx5wr0s2FLCBF/6gxuqObciI/RCKOJkNslv8\niBOEfEYSBtd/xh6cMoUw0LXElV9w2+MgHLmmbaR9KxJbzeRFm555c3QbTO85\nbwcM\r\n=OQ73\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-5d3f62d-1623918007319_1623918072290_0.1386479151377371","host":"s3://npm-registry-packages"}},"1.1.1-canary-eb24f2e-1623918039519":{"name":"@iadvize-oss/store","version":"1.1.1-canary-eb24f2e-1623918039519","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-eb24f2e-1623918039519","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"994c9344da62830f06a75a18b3a819281a6b63c7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-eb24f2e-1623918039519.tgz","fileCount":7,"integrity":"sha512-Rax4T8EPIMdXKyQdh/Yvc2ABHOAgEGJ0Me5ngwNl15YhF81U24L1CEimesslbNCVlupSQcRHefbOruYhVw5BdA==","signatures":[{"sig":"MEUCIQCbV/kz3T4icWPOLX83ORPcwv1yumg8BsmxHEd7EGNxewIgWNDa70dL6PVjv8TCk40jE08847nFh37uWJhkO2QCR+E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywYUCRA9TVsSAnZWagAAwxwP/R8Zlr6Jq0Rl4yfkEf1D\n8+mVVI/JSFgFAMGiuZ2kfg1R4DqQTlNvaDeXoqMva0s3qHm1sgXtSzK0S2UA\n/Vn4m/B7erBpjl+rf6nwpk9RH1z8cVf+ZOPz4zXt36a8UxN40cRyQKoYGWFc\nr7wcnEv/rFmxPYcmLfs6Pi2qiW9RGxYN9s9Dk22aRj0iZMro+C8uGXyhrI2j\nUITn46WZm8LY+816Zpc1oNMejusaKKfpuZYCpBPU9k7a7LcrboSYtyN3txxu\nPx+zO3HRO7MarbWntJRT80qlLsnf4EysIWOcIHsTo5Y/DcFVNND/y3RSazFo\nTsNcziQPlmb0d4HKrEUeg3KX64iZfu4r8hSrPixUURO+03zOUJzXVx4Z9CFe\nHVG/kNiMIAfJxhAsv/6YWxPE63xhGoby0aSjQutLMxPcO2Ovm1cfMWx1Jr8k\nn1zU8WT2z5occQui1yVP42NIp4tVwW6zqvO6sOsn3NScJIjHxEbXXVSJBTeC\nOBKUJ/NvJbcN7VCtK1rlqkCDNiXq/SIJFP/gKwR9aUBACr78480FMgiRsCbw\nbnHGhVL3hs07gK0oe4XQr3d4Bf5ulYsVa6w9kl7z8M+NZd6p+i5wK+M/Vjq1\ntezQIDXbZBWLWpCvdBJ2dSOqBSW4gDcNgIcS3f5keCgz+KmngvFwCmtZnbGj\nVETQ\r\n=MzmB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-eb24f2e-1623918039519_1623918100231_0.036383269743145874","host":"s3://npm-registry-packages"}},"1.1.1-canary-eb24f2e-1623918066671":{"name":"@iadvize-oss/store","version":"1.1.1-canary-eb24f2e-1623918066671","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-eb24f2e-1623918066671","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7140e118b03a2bea1eb968c8d833236dd2da5a09","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-eb24f2e-1623918066671.tgz","fileCount":7,"integrity":"sha512-UjFHtTGfoNv+m9A7WTVopLM2eWuLpzKIdnA79rmfOOGmg/QkHhSMprxSqgmy38Nte6Rh76jUqNWBjeCTfxDfZQ==","signatures":[{"sig":"MEUCIQCnTqFQ4HGdngEPiyRpr5LEtzj9d+1Q0FUcupfoRgcbjgIgMoqxCN2P4OiwQbv58WS0zWm7yurlwRpbY681kbJhUNE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywY1CRA9TVsSAnZWagAAHC4QAJZZpTy/c0u4xORKLxji\nALO0HNGvEGopuZcFhBHP/VzcNT1POruHATa/1l9HBJuMGpIpwHPRsUQihsyV\nmUa16XT0yNOyvP0hu8dVm/KKaDmnRVkrnlfDgopaOATU5qyp5XGkMZBs7v61\naW+OFJcZEYeLWK5lFT608rZ1bQoUSEf7xFsviBJMKd4tnocUtG9Fhqo8a+sX\nmVMXhAoyxg4NcX/qSi+/gd7tOoYcbZ5AAkF1ULMmoEAFNffvw88HDRQGGAWq\nMEMCDRvUvUWisesFhVURnQI78Nr7FGLR+EPSqm67AgVPLVpfhv0wzo0nllcg\ndSwjTz2eGA64E1b2+EvkW1yOZfR90wiK+NnF1wdCMzeKxLkwgd6OrNFsLIgU\n1AYO/sRtmanCKIjD9GWU/o27PN3I16TwcnpHuQYWXA9R9kWiWxeRladxsn2k\nVCaEas28Q5pVY4x670TmG1NVx0dGAl9FOZbqD80XPSOaxFdAuyz1/LfQcSIL\nLG93ZHsIdCueJmg23SjWJQ0Jtcz++rIWu0HXqXpUEdqiAr/HhKvYOk0m8T5S\np57RcUedzXSjJy6z3f2M+6UnoepnjpGakuK7LS5RHgjLR1hzgQtB5OLPA9Ry\nR5D3hnStr6Pe9KG9yLGlQEgoG0nrFFxVoIZFdd2xuuzl369WFqIFGX6fEmKo\nB5cS\r\n=MqD7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-eb24f2e-1623918066671_1623918132989_0.9116030652059237","host":"s3://npm-registry-packages"}},"1.1.1-canary-eb24f2e-1623918083142":{"name":"@iadvize-oss/store","version":"1.1.1-canary-eb24f2e-1623918083142","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-eb24f2e-1623918083142","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c7f66357d2b31180a8f39058260c4b681cb1b270","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-eb24f2e-1623918083142.tgz","fileCount":7,"integrity":"sha512-7LPGi/btw3dmFtzONX5dHJj4sQfgDDaAr2HS65QgF88+mvhm7lw5Msw7T06o2O8yd5rTb4JgD5CwYNHDNxpdWg==","signatures":[{"sig":"MEQCIHSBKmEZsJjibATqjgEHWK+/EnFrrbCbzmxuFDWOQSCRAiBWj4a3xMMlj0V/U0MITtk2fyipWWuxuHWl2aYHLyfmBA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywZHCRA9TVsSAnZWagAAyIkP/1PtsOHf1+lQi3SDUgyX\noz8Ub44vB+l7BgBuEOIKlXO3BZvlmswq8Evo1yRucqOgs8Fg1UFzrgTf+HJO\nQnjB2v/Z9m5oOd7fcNjlwMPsDRncCVChhI2TAJeZym4BtaU9/jm0pBqeujoj\nNbmrrsABhWVwOrP2ujEDRkGnTmm4wswkbYt3zlxw6Tt0vRMaZXYUxklkIxyY\n/j+fpRokk6Vv1ASGBRei/BzLuMKKC+CUaiGJceiJn/U8Cu9meQRJM1b3jo0z\n75hE9pke6yClHvUG/hNjbWgu/v6Urv/Hd/AEygw1NFGwkzGCvbdimGR6VLAI\nsm+XAeRBuF3/ZtX3UlLfcYll0Xj18VGNiEqXdgUf90rq683CjJD3rm+oKGxj\nv5mFTmhCgupVbepAmrPuv0gKo5P30G1H3cCjgwNXe58NXnVuj/6drL2Syv+o\nNTAYh+1a5ruEpY0n0zpck2DGoSPxt7gAJRtiFzkmTSXtkKgWhnmjh9TkcgYC\ndysyKIGozxEOG2GG+/yn0sPHbziCuxyje0ACczZKqPyVouDaVF5ES+Exzr5z\npQ83kTc+iJANckDhFab46v4c5qVRYmZS14L7BMYXxOBmV6JuKV3Lk+CPtFeM\nNiy4x5RScJGD/8rmoUakFnKK4WOzHUOzecScQJ4X2EiDDluRQer3yg4lor7I\niOkX\r\n=aEhA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-eb24f2e-1623918083142_1623918151226_0.737242901876574","host":"s3://npm-registry-packages"}},"1.1.1-canary-4c08875-1623918546264":{"name":"@iadvize-oss/store","version":"1.1.1-canary-4c08875-1623918546264","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-4c08875-1623918546264","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bd678eee06358d2bf66775ae3625aae3af423252","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-4c08875-1623918546264.tgz","fileCount":7,"integrity":"sha512-AiE+5+dw9u8OouRCLwT6Ck8hglpxPLbJVE4GT5bJ2FCK6YQGb+QmkziKnkc6TXmeU9o6lutY1HrJNO8zuSAhkg==","signatures":[{"sig":"MEUCIBxaCLyuYoYsOIFzAH4wXTaaebuZVgBbIx2RvJfgG2dbAiEAk1LmfB0w9Bot1KxTKmiRb8A8V0R/eH6fwWe/lp9COZs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywgDCRA9TVsSAnZWagAAFvoP/3h8Wh0lQqktum/y5r64\nJEueH+AnNU20Z1sjX8PLLoCFFKAFb/N5M5vg5wFdH1mbQkmGUbvCN5aZh+o9\nSS0N9kDLIrc77fDeyDPgt1OfpYM3q/D38YYuwr0A8Uh2iQRfjQDrZuTooIkF\nwPJWCh27K/oS98gXQNOXup7l8QBGRE7DdT7H6s+JgOX4FpaTne9qVWd1Phc6\noDyiyHZJ8GKBkIdWEu9EEYHdJahq70Thwzw9xIIRdWSay/wgrD3apW7gwcKr\n6hsVQUA5Kw9RemZwqn+9AdEW88/D8Rz44/Ua/87W+IzrQzIWu6olelh+yaLS\nKrbLdY4zBjeStvYQsoFN+R154RYQpWnVDYBTwh8m3xYMuu+udz6RfiTVT8wa\n4dBcBI6UVaMPenqSvIBTrBSFjTJb9h2ITus42AbKcUj1m7KcXUJepWdgTy8N\n48fD+Pbkf7I0QznZy2bxpQJVTFyO5BOWSP9Cv/oWXBaKKbD/Vqsf8njXGo3Z\n6ZySWbTcCW3A3T+h79A2Ry8DMWvdBBCezGi8W8OlQfZ3+Q/ObU0Me010wnxq\nz9rmqgtGcHyLuLISJRD6mHCU44cQxfZX6Q/Qz8F9QpfKQ/wsByhKTL4yo7Qu\naV93J0Mj/aOnSrQAaJZhzQvXbPPHUikC3dq9jjUIT1AYEqlYyXURbx9gk2O7\npgwL\r\n=ks8+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-4c08875-1623918546264_1623918595376_0.20342136905556707","host":"s3://npm-registry-packages"}},"1.1.1-canary-f1361db-1623919076612":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f1361db-1623919076612","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f1361db-1623919076612","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"74753dc7c049e7a2ed1317f5325a1bb9a4aacd8f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f1361db-1623919076612.tgz","fileCount":7,"integrity":"sha512-Qpeq6kihm9Huj76Dv9CyhGNEG6FtBd8N/n9myf6tLD/nUETLJJO+IzhCq9I/paRMG+/LWBj2bTvopXIZj+yNoA==","signatures":[{"sig":"MEUCICxYVlnOOIq5bNFcigtnnvZctsZYNglxpyZlrrTu9D3wAiEA1k26yDderu30y145GqUVr+q6KK/EmVMzrU+xme+5Uwo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywodCRA9TVsSAnZWagAASjgP/ijhae9loTLqTZTeCxbu\n5lc+bzzaDT9hNC8wnYvfngDwfi9TdxykOPLx4AYzfn+zJr+FFquzPtvlVFp6\nIHrSbZsWVVKk8lzqRk4cafJUh9wJIZkr5XCdNuWA5ORsqQk66CqvbtrZhAyy\nawy3bZ7mtBAADUNpeqpI2NiI5V2c8geGGeeu5ovsFtJTYTZvEFOzvl4Zytfb\nea+jT3ItqTODRhZImPMl1xtA3veSg6oHSp1oT2VuoN0yG0U3vWUJGDsVjgbW\n7lOgyFcaLZgv6A3pmdxb8dCR7Ub0mCyox3x5VELsSn3xwLlYuVXPrMYVAEZR\neIshF3xcSyNp4d8CrnkPqBFuYQGt257Db68kH6AXlJWijswWsgjCkB5rNgzy\nUAT/p9cBVrYrnMGkR6xk6Uw8+wiWEnC0Wql823qatL0QPSuWO3yMPPmCTFR3\ndXt8CMAtSK80b4NIDvYQIOdlxriz5CHMnpBJDwjL5/W3khSfQByLQ0OP2naj\nSUo3MtLehsImPWqRCwlKMufoD474FnuH+yY1nmOxUqSjAh19okLNEbaqUhlJ\n1qS7SP+QIfBQO0iQtH5GNfGJFRV7rjAW7ajFFCWkCaGpPcNa2bV44pNThXi6\nrbasQyiMT97vAef11AVsH0OAIUcNUWywl0Wd99eJsiiORYHM6bjxsufhyztB\n5UtZ\r\n=TBV7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f1361db-1623919076612_1623919133557_0.9575368825563064","host":"s3://npm-registry-packages"}},"1.1.1-canary-f7ec6d9-1623919731522":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f7ec6d9-1623919731522","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f7ec6d9-1623919731522","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d83b58f7c505d59f8ee499158e426d2816c00b90","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f7ec6d9-1623919731522.tgz","fileCount":7,"integrity":"sha512-cR9SBYGKfUZSUdarTpjUDU2A3BWxjqGJONjEWGghBhPrK4N65qqZPs+jdb6Vx9E9p4EMh7R1kKNlQy94fTqiEg==","signatures":[{"sig":"MEUCIQCeWsUqTj1/HfureNUdMcXpiFcoV5QUHpzj0764O3pxwgIgFSjv/BuDlaoNVtKVnLUjuyJNqisusn9N7B9zIDZnQ/A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgywyiCRA9TVsSAnZWagAA1uIP/1c/pukGYxgiz54Lj6dx\noke2Y0TUcykrZ1ep1Gkrr2e9NITia6elFbplPjBjDekmBPJWQ2TeDPdJcd45\nQ80wJl6k0dz1CHjARqMniZ83tWhzVaNEYjijP81Ew6wpHsafqb+11+49t4T3\n80HP5MoyfMDfCXdbX9hn8aIYZG4X1vJYn9olA7Cflk8IryS77XJRRYDsNPIT\nroZZIAegH/4iHXiuFpZfkZXEq/zICmBeWmgJfq45dww7+aFDbJBQw+bSLLdV\n4nLREK+sTz1pdz5q0hywd3b5OYl4rs0iCDannjlRI870br9L0Q8Om9Wlw/R1\nQDoL+g9h3lBWRKmqT75IWdD59udlbwQvbOVhTn581mXb3o09AdGim9XMMZE1\nw51Dbf6Fy9wYb3PReqcUiQmPXOh5bnlocnO6xqUGMwC8EIS2nF7TdcwbkQrO\n2vW64cL907PSA0gxF8+Guaw8dqZd58edpSEnnzEi1zQ/mDvxrD9lUYZjrsmR\nlPvVIYb/1D+0J/L/DKUJNmQIKQBJuDG0k4tQmGGCBHjFNt+iDBYaXdnwb7lf\n8pXdBXDvewLz4AyEI1D7+4HStv8a23vmrnIvIkbaygn/dyPajU0sNkXDZ8wa\nIF/AplbE8rKtfrbJoTKJNongHaRy1glWB0PHNTkAvSJGEHIOJPluRfA9Hf1k\nP7ba\r\n=qxQh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.3","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f7ec6d9-1623919731522_1623919777572_0.7777895943379838","host":"s3://npm-registry-packages"}},"1.1.1-canary-3552985-1623981724835":{"name":"@iadvize-oss/store","version":"1.1.1-canary-3552985-1623981724835","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-3552985-1623981724835","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9b99cfdb276f516c2e7a1bb1f8134a52919ec5e8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-3552985-1623981724835.tgz","fileCount":7,"integrity":"sha512-Mi0G5Ip5YfFh4Z7rBKNqLfJTQtfpua7Jd14461OqRjm3XdbnHqrMYpxAppXSueekwqm5v4IOy7ntYpQj9U62SQ==","signatures":[{"sig":"MEUCIB4OIhUrm65PdDg5ePL3iq5rSUgmEQhSC00MEirSNpoyAiEAjvRyvVrrZ3tfYD5M6R8oGQlxozdFSR5mzIjj8TepHLs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgy/7QCRA9TVsSAnZWagAAkhsQAJWSiNYSt/VYh4ezE4Pk\n5WT8vqQ0Li/hgKArffNCUo9WcXJ3RebMqglh8BD6MgM4807b/gVgHfF5DkOk\nM2nLLDmSM7zZ2FPyn4wkBdmirB6ZZCKlLWQ4zWiXTxBA5GZjYCCgYjIlgZCc\nEdZcPaFFkQzZELcI9mzXnop/JsL/0MPLwWpzASKcpzBFyz/ZVxPRIeTof6XH\n3KAa84LYzh85vODP1AvCDzoJBqJZcwxZ+ywY0r6J71AtkRT43M3ZtC4i5yia\niRmaDhCERDT6BoXQnxOw2LiGcQmgagJJ3+ZH4+La6mVC6sM0zij17xZjD1Lb\nFyQ98wA2CE1HxDB+B7bH8Sop5o2uulEY2ITQdN/rqsneXBLIXNp2sw8w507n\njQYjPxGxpjxsS+6x/Mnhyhbh4+4lxFMYCKrnLXy2i20AUp3Mn8IlJAcDf2Vi\nopIDTuQZqZRTKisn0XNnFyjdtLpR5Dk8qo7f/GdyoqeRnrWnmqH0D93PhIzj\nq93hPWjqhxh7Zs/F8qXdj2ICV97bwMhGKswvXvI2L+kjvxifYmR5SwDPkJIa\nvgz82eGhar4o4nOImDgbul7VJ4bEvhsk9fVQ+6Y+zsKrelalW48qNiFHD25m\nwyAcFpuzQvVFH2hHxHs7jQ8oUXyiyuioFVKrHJAhlt1LL9EGvM7pHCzy+CB/\nkKCp\r\n=X/dR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-3552985-1623981724835_1623981775907_0.025156361089857526","host":"s3://npm-registry-packages"}},"1.1.1-canary-9a2b0af-1624002503855":{"name":"@iadvize-oss/store","version":"1.1.1-canary-9a2b0af-1624002503855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-9a2b0af-1624002503855","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39a67777474b4043d99713d12109966c1d952340","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-9a2b0af-1624002503855.tgz","fileCount":7,"integrity":"sha512-deDt5HG3cymNfb6SbjoDqYK2WwQ3iIZfQzmO9S8Et3sD30FnLgoRwz4OS3HHUjNlkq3Z/Sa70+8GlIDvsQTLpw==","signatures":[{"sig":"MEUCIAUHWZZ6oCka2Za6oAw63k0rMmMrUzhvioI2kmAd4VzNAiEAtwU5nZQLbbmseVybdXUNBHI2vS+Hx7Zktp+fLu7GA60=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzFALCRA9TVsSAnZWagAASUAQAIJX6/HHNcS+wvLjkw3g\n9XRZxQpwUIc36IrFnbb7xlDYqnYaFpOlntd8W4WqmtC3a+ZPSY9co2lnPlUS\nwhmoKBJ/NV0oamHZ5+hiZ+3E0QgGb0KI7IAqdqHKgnyw7/AijZQ+3DhsFZ3w\nueBE45qDWFmxYPJCKCkAaYYpnHgQKq/MnI1CI5sYK0MMrZ3//zp3UVeicw9I\net5QChOnSv3APv2BU8Y/hsvcXDXSH9cSG3dPsbLGDxNvmUYrhfRvWryuzz7A\nCyAqWKOhZCSb2dGluWhpEoVPtGMjD/AwayJNWAD1GDTQUfjNZLwJLX+tbqwF\no4vNfdm+0DFirQc7CrWOxSgkbIYNS/RzgI2sj2LTDAKxETOkQrbtpL8puAa5\nS1xZv6lAa95BNnbGeAmeLJFIB01hm0rpdUUk8vNnO8FkCQ8g3lhAc2Unshqv\ncv1rjeQRtsy2AIv3yfVHLJFt9otRJM2wqDN/U18Xob1t1/XK6tzoIRPScV7C\n5wqMgk/dVWNl+Fg1ZmlEE+4yYiuQ9c2LbWiJHVFfDflmqx/OvYshMAh0mRlF\nLi3HrHohg48PUs1PZfeZba8+Mj7PXDQoUfyf0tH7bRC0SYHJ+99dem0Wm3kg\nlEbsFawBrr0ZlMBrRRNh0mYlSbhtSHaLTNuxkmi0hi80Yu6+cQbIXIKP99Lr\nu+sf\r\n=+31p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-9a2b0af-1624002503855_1624002570644_0.42921200412380633","host":"s3://npm-registry-packages"}},"1.1.1-canary-d18ee20-1624003245952":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d18ee20-1624003245952","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d18ee20-1624003245952","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1b90fe6cbeb0ab1e6903fb9992d2eb0a49188a12","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d18ee20-1624003245952.tgz","fileCount":7,"integrity":"sha512-7IFoHOVlVaMYhDb6JqjgLywE/7V4yA3GcsTzDoC0CgKwxKtgJiF/lKrAre1QpC4zv1oU+udEOMoYLu3brR4B1A==","signatures":[{"sig":"MEYCIQD8cDfl+bjSnDYZY9hdLRbi/otO+ytF+VCyaXAx3rOkPQIhAM3W77hTyMpvdsyVSkXFmXlBWxF3yyAyOl4zTEstlfmT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzFLeCRA9TVsSAnZWagAAR7gQAJz5XJxUit1N7G+GwvIF\nfPfqwV003BfzeqYK0mywhCZRiBy+agbgVV5+1kEBvhsD4Ti20RmMLEUSynuY\n4SQdbyx3pzktRL8zWuIupZSMcij0DH6d8PtpRJ1D0v7wPTpGxdblVSl77waO\n4nGhja8LFBPsDdV8P6D2swGeDUcbwQhzCgQWAhyhvCmuDDqWLLjC65K/DnjF\n6SEehXF13ThL6vfSOdHRK6KpdmeOBdf1+kZbskIS+XBpaWB8pIfAEE22NQ/W\nuJOnG0IZ8DKXF/3U340MqTvRc9bdAJ49ENwsrZR2gp5/dLcNAv7ZUkUYl+gR\nnykHp4daW8IUHCr32++DMPew2e3pQ4NwUyqEBakfiuPZ2cRqk/5+sG1q+8TB\nyHVTIVT9tdKhW79yrrHsO1wWyhsj7sCjfKJ/JdA31bkenoZEmR6veAvhLbdQ\n+41yDuwR2jErBxuFZF9XiJCeYBfBIiiuyPdvbxtBEya24+4PuvsYg0q03aNM\nYa5/T8NxpCOLySLNu+MR/mLmQXfFO78Uuyi67eAuUExAqgL7Ya+Ns6kHwYon\n5GYpN8b7zpLfulQzMv8s39C2BWotllwGo1C5EakyTrflJdqHc9kYVkvXOkq+\nMw/28wQdqzGUNU4tV/FzlpsrloBCMLT3XsiYuOes+gP7yZii4pRgExpFj3Z+\n1zRU\r\n=JqDD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d18ee20-1624003245952_1624003294257_0.3499891776445936","host":"s3://npm-registry-packages"}},"1.1.1-canary-d18ee20-1624003274563":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d18ee20-1624003274563","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d18ee20-1624003274563","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"88fa30762df332fa53ce6c822781789df3e68589","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d18ee20-1624003274563.tgz","fileCount":7,"integrity":"sha512-DinIMJenxc5lnYv8x67SbcQ0WwM6XflWtDovZpVOv0gNy8m1s32N0MLiuJjtaRTAY89SgZpRnp+m0H9tLvDvew==","signatures":[{"sig":"MEQCIFLTbrTm+sKtoHeQ2iodRC2Ux2BGHDncp7lHMXkxpH3gAiB3RAb83eVojXi179qtvlGlzM9J5lR7k6OF4xVBCcRn+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzFL5CRA9TVsSAnZWagAAWl8QAJHW0sKSuLSPFV/vg9Ui\noYJR6tKGLEXMqRUAh5EDPNiHeAYZneN3Pm/WdG+ZeNEobTUtpx7jAPxmo+wZ\nlKNNe63sCGxDFeXVOoUFRZZRA1zynRsHlH5EolZXmgD0cNwZ8PTPGlIEMN/G\nnHUSr4STev0s+Spp7C9ysEUnnPw3IdJir8LnD9wvL54jwgncf0T1rnSZ1Qx7\ntHk/22aVS3awHllCO/xsPBJeqXdASJs1Blo8rOD/UcIZiMebzmHwl+4bozjE\nRoyD3ntTT+FmyQIQHJRLnrBsKflUlB4C6uEiguQMxi3uo+hNazBL98wqTK1v\n0y7Cq3Xt4rDgaZUBu49rWNW4aGrrqrEWwIrDZ/lwJoRbZorvh6zWyQWBjqAD\nKH0EeztNUQLlwcBF42ntIZqrEF5yovk3pH08jzH9VOZRXhs5MuKbqcbiSPTK\nek3t32ygCD4QWZ7bC62ZBF4rNxbvSFRhsZH0S2pFamko/XAac0e2GBlnhhLM\nNsuzBskwHtt/lGCAtTXAF6euILnVNqNUN2V96puLls+nQtXHSw62dDb7Vt2M\ngJlwhnpw526gnNKx8oooRYZdZwiVSkTeXLEXjzR0cFleFwmDGV+i1nsUwfuH\n9OsmWTk5GkuKnP4Per2E/JeJpz6qOVKiYHJyMwkHM3xm1mvfINyD66UO9xe2\nKYDs\r\n=Qa1O\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d18ee20-1624003274563_1624003321214_0.5553212533267537","host":"s3://npm-registry-packages"}},"1.1.1-canary-b6b0a89-1624240940941":{"name":"@iadvize-oss/store","version":"1.1.1-canary-b6b0a89-1624240940941","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-b6b0a89-1624240940941","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"471325446a5ab80b6fa2cf953bb6155325630ab7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-b6b0a89-1624240940941.tgz","fileCount":7,"integrity":"sha512-xlUGg+lJQ13NcQVwpUrhh/FXGq8MTw8okHvhCr7yCxMbcvlm5tY5mYiQ+FCeJJxtextNs8jBvVm0BQRMMP409w==","signatures":[{"sig":"MEQCIEipyYS7UJxLHYlqNVyfXteenWanYqYWUYIsK+wfKMMFAiANROa2dh/IOE1zW8UUx0d828bTnM6dKMSP1c+DMDQkPA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgz/NrCRA9TVsSAnZWagAAiYUP/2xwyKLmXBc0a6gxYlNs\nAC2UGixsmiWrSRcxVwhdLIybHOqmal/RvaaochWapCTFsKzf9F1vZ0JFkmbU\nOyeBvSUokj3/yBvGwY3xGLvbTAeXz27dWIojZSIB/CqY7iH3BGrWexdq9OJ2\nJPTnDn2Jb/hwTyqqI046L/ylCK9WInxzmNC9YC+iN4ZTWwpk53q/JZZlcdEH\n6/Rqh7BKsn85XiNa3PKZ/TgEOI5VmhuD629TFMwt+lxRXdypCFjEBx9mUQuV\nZaTPl/HIuoMyQ2kLrzAJgsP/uatqfKLwNBU4NiF+Y13Li1bzzUaRFdgy6Kdu\n8rVshr3Uc/Ly6RQDOZRxbLLMF7k2Xc1hMtnFJ5SZDLeFAjSedDJG92y84DvS\ntfs6kzdxHe4JUC9L4T4jziLL1cHnZ98AxcaPjorM+/zlwHfBqcYJcEhYRaGl\nWiX7fEk7MQJan7d2c7qViLpRyx2CKogiqe1ikmdjNt96fQsj3//HXVYM+yhE\nUnFv9jhh3s3QkqUys+RmAvFaTByijRA88ZQ5JFrNRJ1WkIvYYo/8TetYO9ft\ntIArsgzRV8PjRx1bhx3+5jdNX7e+LF7lHnDVMgrZgHmZx/c6YpBBqm05bPiN\nwRdsj2KalBoh3tY9AgFCJctsgbgAyQ2UmL0KCjcPXrUglERX8yv+dIz8sn5P\nCM8k\r\n=VR1+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-b6b0a89-1624240940941_1624241003166_0.5213577461496599","host":"s3://npm-registry-packages"}},"1.1.1-canary-b6b0a89-1624240943941":{"name":"@iadvize-oss/store","version":"1.1.1-canary-b6b0a89-1624240943941","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-b6b0a89-1624240943941","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"33f64c4613ca9834b9630c8ab1509cc76d3b761d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-b6b0a89-1624240943941.tgz","fileCount":7,"integrity":"sha512-QJpnb2r5t8g52bwfrRokJdPOe63A2W9/u4DaL+pKqhIrdPJUc38jT8EEiocy/mJGvv2FinMy8CIYupeamh3q9Q==","signatures":[{"sig":"MEQCIE/YcrLoQesXOoa9RrXK/FXKhp/BmxkYD1ZjKaiHnwJIAiAyfdwHNqxQeHaWKPjlRKIP6awBA3U/AJiVP4CLMbAx/g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgz/N4CRA9TVsSAnZWagAANGMP/RSxdb6HX+U3yDcGygiQ\ngjgd4r0o3es9T7b4nYeFPZOKqjznWeDFr9JrZ1EiB1FvXPrTltWnUwFAbAmX\nvh1cWctp884PgmnmRUiCQvG6G0LDaS+tmp4L10v9/tnsjivNGnR2h+RlqoGa\nPaLvsEAuIlvYNpsM2GXYR/xJVkGNIzLbRrrBXCF+YiFwgK2C/KGcemlpkTkb\nxlgvwNpTiXtrsV+Y/ZRy0o69x16aJzLVM17sEj/tueUnaEH3+FutsFMA46RS\n7qhwyQr/bmO0ThVLywWtN180Bu03mR8in4SeXkoNAfaeYd2QGadh60OQG54f\nS7m50RUURH6rbXn8gonxxJwF9nDXs6aWZTf6PioYZVGgZLlmH2tGcWLKJE0x\na3EdN78HL5ulsNlfKWhOffAhy0WP6958zp7R6F6V7rWTsDNP15j9kBhhPpBY\nt7eV5U+WqGPOSbVzSaARfjbhwoL4lYjx2DuBFvTZXpYTLOYe5BVsCfia2+ox\nhGEbHbXmhw01c7nOjhE8NKourOMJ//uNHmeXRTpRHR8ogH/gxO/BsKtdZ1H+\nF1LHjwM0iOZPeUsXzskvSW6lqk2HIrDPGZdnXeBhYiUeogeB8RG1TT8QhL6a\nKgaqq8nMBr/AW0YYrVH8fuYT3n3yGPQ757/1iKnKXLsNPQuj8qRoRksJvCtu\naT3y\r\n=cMIQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-b6b0a89-1624240943941_1624241015764_0.9559554759104858","host":"s3://npm-registry-packages"}},"1.1.1-canary-5c0017d-1624262553577":{"name":"@iadvize-oss/store","version":"1.1.1-canary-5c0017d-1624262553577","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-5c0017d-1624262553577","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1de6b762a93ea122fce90c909cc4982a10e6a08e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-5c0017d-1624262553577.tgz","fileCount":7,"integrity":"sha512-vZaw7xF++nQU89J7RI4LLiZqL+zXF+PqZVb9+JjsCSHx2zYuHNCTHP/AhCwNn3E63eL9qypJZ+EmWbypO7rnRA==","signatures":[{"sig":"MEQCIHnzq9zCqt/sVg6D7nGWG0KX42YzLIBQFA3XLJMqil6fAiBoiiyPWpnSOIZLU84wIQ7sQ8EwgKndxHwlh4j1F4r9Yw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0EfWCRA9TVsSAnZWagAA0sAP/AxRukJOSA7OiDveYDJP\nPgH3rGQ0h27TeQV6AOe0FGuqT2Wtxn/uaBmjH0+vvQwH9an6gzQVg6uuBBjO\n8E1UwXBygoGXm9/scpFbPnsZxUDwMpwWaGSZ7i9N+9aVYGVdVgOfCDAyDGcJ\nln5qOe/9G7tHfOzmVtfv0oCcIF1YXd10+8w77U2JXi1gHOHMFxdr9qsWLfha\n6d42KzMSXrw4m51/2mHHTlRPRj/+fpZcZE5VNCRwiSWlQNnowHcl3UkuUTPl\nkWWKOnBPl//WbPxWWfAocPGWO1NZoHa81F3gkpWOHd+AXA4T+6yDhipx8Rge\nsDlNNNPKLHjRLZv8FhAtb68oF373cT8nFYk5PpxneLCoDdWVAPFwBUkEZ9Ns\niZer8+KTqKOgtDlPFBVFZtgqhFPQdmKApaAzeT0PsGoV/nsWoA8p2WyaPiUw\n//Po7SSA/W2o2g8aHbmb/ye3ZZiZjpd3VlrdstWu8+uZjWXyiILmXZUMYA3P\nHI5QrO2XVpQAcSbljzuz0bMAwtxfTDYYj7u5e94O9Hzcmo6s+koioy5R+ETy\n8KtxFeLf3NsjtetIcwQFtDLXu+MpKh7PcoAqCZ3eHYb4i96oYpL7UBdMwmGE\nGAr4SDJd6DwNm43l9sHLg5Be95DMrIKY9KOgyQVO84wAA3e2twEjbCRNayEk\nMoVQ\r\n=gkLy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.20.36","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-5c0017d-1624262553577_1624262613664_0.21776336212680092","host":"s3://npm-registry-packages"}},"1.1.1-canary-5c0017d-1624262575598":{"name":"@iadvize-oss/store","version":"1.1.1-canary-5c0017d-1624262575598","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-5c0017d-1624262575598","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"becc7a5de046a57f532883719510bb429a6ec76c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-5c0017d-1624262575598.tgz","fileCount":7,"integrity":"sha512-DSxNwXkjBDFvMQr1xx3dJxPTavV0O0s88QSn3eNAOIv5vy5VsJcDIdF3+SYuaNYbtIzFRbtRq1uKr55VdlXCyQ==","signatures":[{"sig":"MEQCIBrKinpyFxok1oHGefZELQU4CujsHZ8/V9W9QmYaXX7LAiB3EYVLh1eKAemd9WU2oZYlkuqTOb0aOacgLi6msDXzuA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0EfjCRA9TVsSAnZWagAAugoQAKMpNf37KxuDKc3TKbJU\nTjS+BC47VS7ejdlM8Jbvga4wF9IsabEFoCeQn6CuZgS7kjequoenE1wkRzet\nShU3UnhUy+5PelLIqljfE6eKfnpY0iOuy/BV4mC9Cor/uRDuShG4d6PQq/w2\n2PBfYVRjLmjo3fYDV9q3lOsOCU2OCPmPgiGl6gwotm7icgiDnvTx9XxDnvAW\nhZxzhn3Dz1WbFiBB+73JAc72FiMrhnaKfMyYb/20IjZx+Xh4fdyoMybeOKHe\nlw2EvqMFc459uDFPjb/qAMqNyMHeEsMCku9LgLPmjGEqpnSB3FjsdYiXbGk4\nEynO/S63tg2hwUECyXq7MMmbspEAZW+cyU+NxGjole5XmNayDy2zPjLWql4h\nMB8SzEeBYMFVjbfeuId3hwdo2l4e/OxeAt7o1FkUtd1suNXPzHCKGnhzdC0g\ntdZ9mRxWBDUtLrQ5hlatB3b3B1R4cyOp0DdQVpXsVMSNxlB7GN7MX+O1ZG7X\nbF9zHrU+e/XAv/31NWaeVzHviy0Iqo6Nmp0lSUYogRSdDRBkL323iMZadoaC\nbzl7po6hA7myJFdCoaM2IGJpllg/eJBoxzB9HopBs37+nc/Xhi/F6HP0LRoY\nVwWj6NURHl37S1iMYmp8hmW4GNiDf6BmfdD3O7gy2+eQSmJ1GeJ9ldD16qpn\nbLt1\r\n=/YwC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-5c0017d-1624262575598_1624262627197_0.08583367186261115","host":"s3://npm-registry-packages"}},"1.1.1-canary-6721d52-1624262725615":{"name":"@iadvize-oss/store","version":"1.1.1-canary-6721d52-1624262725615","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-6721d52-1624262725615","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"456fb16e238a7881f8ddda0b0d01f52ad4561d3c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-6721d52-1624262725615.tgz","fileCount":7,"integrity":"sha512-VX4Ki0+Od7Uqun0UgVGFLnqghEezh2FG61jkxn9fkQPZx6ZO96f/jjEwSKeyQzuVp2wuKviQWa6eKetHRG2G3A==","signatures":[{"sig":"MEQCIGlYAdFiYmrmN3Mc4wUXZkuJA5bRyKcIVMRarUHG9BLiAiA6AnNDUN7E5mV5iWEATbpbMLVj1iKVslNvApLJgYRrpw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0EhyCRA9TVsSAnZWagAAcEoP/1mkGWqXqtMggtY20jld\ng7xcKQvPiTiIcolfyEHTB5pErSOIf+rLCv55FaEZYgSNVr3Bo7yar8cxKuaw\nX1DcWSUn6hRU2CSslwZWpIkCkJDjuz89hTOpLHc2MDcwATRT9K/rJxnynyQC\nOXmhvdcZy4+xNQCRW6g9ai1v6EUwTv7yfs6EXs/fE7nFLdxNiyLULuHb1NO/\n9o7hb/zUFARQihv6xNi/sWwG5XsCZzOXHiwqWXFIviccUSTeCuQrVuT96eVv\nqMS/WYPhk2498k3105pdvcVEritNMQoTwiYHSKRNtEcL4uKy1AOeIVl2KQ8n\nsE8gdVw5w+1vCNH3Klk/ay3d9NwiU+OtKbyb0Z1T2df9tXOE3Ra8UeZLDwua\nYRViIW2UcbYJlcitsXZT0Ku2FR25JZOXntgLE/YDhZkHO90//E8NgR0FxDdm\nCUTZEIi6lzKvlOXrKmOvhprsozB+Px7Fz9sgR5nHx9VlUlMtH5Ah62GEFHrl\nhmHQtJxs5G987Li+DJ4nEcblGIBvIdIl0sdTnAYuUnPolz/xRxJqJoi7XIGS\nnunwIexOXpwTVMCUzoQZrfwhyhmMVt7x63MHWoehEwX7w7QBfLlsxBJkZTl1\nPRW+IF2+GG/FOUvXBAkNmBCU6wC1KTiiLPXkL/vXlW3QuPeSG/t+yjbaZ1Gw\nPrgS\r\n=XaHk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-6721d52-1624262725615_1624262769832_0.12436861380988096","host":"s3://npm-registry-packages"}},"1.1.1-canary-2cb6b9b-1624262974309":{"name":"@iadvize-oss/store","version":"1.1.1-canary-2cb6b9b-1624262974309","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-2cb6b9b-1624262974309","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b349f0f5c2535b7dad6ea7b353db8f18720735aa","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-2cb6b9b-1624262974309.tgz","fileCount":7,"integrity":"sha512-PsNcemsA5zC0oOVgHVc1lU/DmqhLUGZW/nbVGwyQax5dUNWpTuIyEmfYYQhxbU1G5tuWaoNDWztzffBoezdKYQ==","signatures":[{"sig":"MEUCIQDri2LwpSMWzF9ZsQW/G7rJ/ZqgabtcIBrnCylpBjSSLgIgftWtvyz355YBdQFY5VT8lAV1qgrp6wRg6U1l7tnbiDo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0ElsCRA9TVsSAnZWagAA+PIP/0I8n2Tkv+NSBW2CF/ZA\n3yBf8NwEb9ps5ZEoOtGNY+39mSTPBLsV0lN80+5kYOG0psriuL/W4Tq1Da9z\ngasVqDk/XaZWPykP+GgCfP1UWqi/u9NMmUBI5GnS9qtLZR54GPVLTLUHUUtI\nV2p3EA1UrDSj95WibulDQ0l+hH67EfoYOSU5eg93dP5Ing88kBfQEI7e0cPC\nSFObjqKTQHHoFQuhtThUJEmfWq05oTgXncwiEI4ke3V2uwb5+r0MKHRLsTte\nmDMtp7ytoiogbb1+4aLzCNjImUKcWykmohv7HSnEnY9aL8m+CJErGK9+405O\nPvHvCKeTN82qzMKj49i+ZT4LAXRkc/n+X9MVezz8yLd+GrmN45uha7CMmouW\nAKf4ewEpFmQU1uh9Zusa/ZAZMR191dDCKlqirwy4pp/IH0CGiuJMIRKNHmMM\nWDW0aqK8nTkV5JtJ0hm3eC6nFV6MXvqpXTOucIqunexbbtQzQJPHO91AGOmE\nIo+CpiITq869dIwwAPMuuT+aTbGXFEAw6zW3bxh4wI8ppvJZGjyWSYyaMJaY\nB9nr39h+ctLqU32KqpZIzabzC8heZyRymJGZJNuDh5x/+oA1xndkTLwYKbe3\njkQK65ScnTX3xMjaA2wvldvlMaT4DIeAJl4Xm6mkDBj3yPK/bQ6kSHPbq1ht\nLZJ4\r\n=46U1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-2cb6b9b-1624262974309_1624263019395_0.0944257257268557","host":"s3://npm-registry-packages"}},"1.1.1-canary-31aa68f-1624263448597":{"name":"@iadvize-oss/store","version":"1.1.1-canary-31aa68f-1624263448597","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-31aa68f-1624263448597","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e9ca791f57a7d30482febdd173a3eb11b141c60b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-31aa68f-1624263448597.tgz","fileCount":7,"integrity":"sha512-V8lh6OVzXso6ey3N7LVYVV9V5DHGDj8nlBGRbwB46JnqZmmk0NgayGTWVi5iFB/LlfMMsDfTPwGQIwlqx6t15A==","signatures":[{"sig":"MEQCIB7JgfLfcNn43BXhggDtz9rxiiEAhZfyG0roF8yuS3s6AiBA9fr2GGfTbCHcO2zMEAQqIWW+lHhRQCOyGBbZbCxThA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0EtJCRA9TVsSAnZWagAAZJsP/2oXMpO/WrWiAYv8nAFy\n46WiYLHhzjf8eKCF1TQCc9SnR1xOc4vOPmC8DKJ/N/1b2s1rdodGhPlNgC8o\nokZdKZqeBF7YBE0QG3IQHVOqhgHBebSiJZFO3+EBmqQ3nZUhiYrdm1DNZudO\nmbyAkRKhXw9VViXalby27resHG3jD/OU2dcToIn0rfVoQ0hqO1R9DjTZOYAc\neoUFybBbEp/H1znz8uHVzIrwFJouOiKYh4fgpGPD9+Tg5oIjzFgpAhvYZ80t\nZPIJIQyGegAL9rwXpIhmCf251Wc93fFZBGR/RObLu8VfRg8q8sYxmFJN7Bcn\nrS4IkcC8PeOmaLbxA4eEa4FdFMDNv8zC6SCjwDSESQ1P64ly7AZzSNgKFAxr\nj39ITUgusyWFl1TvtEa0pPHR/hf2kZu4AQqOldcW1NfIGp4/WXZL7z9cEORJ\nAg26tEEKSQG1mA5Dhlbe/F+ARoIAgIPpuquvz4Hx+rk4rTdNflc2fWE8tlem\naz0JocXAIfZp/BDZCxqMLXmxjs0mzUh3PIE2HsohG06848r7lukr7SdB7hXx\npSZKyx2OGm5hGEVWr3LM4cOSd1UA4vAROqRt/Up5R//9NcKu4Thc5IwPryvw\nFtrF1XSkI7S2FIAkI+GslAhXlIasqOo59Yiz91M+FKHl5Bpisslje/3fPFx2\nbaDP\r\n=w/1y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-31aa68f-1624263448597_1624263496718_0.46522376661384635","host":"s3://npm-registry-packages"}},"1.1.1-canary-113bfa0-1624327300399":{"name":"@iadvize-oss/store","version":"1.1.1-canary-113bfa0-1624327300399","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-113bfa0-1624327300399","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"678c25dba76f0e6654c483096051461bcdbc28f2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-113bfa0-1624327300399.tgz","fileCount":7,"integrity":"sha512-jUo5x60a98H8d17+/tASBuOjqEwxWkBZ8L1FcutEffYsRXm+Vg+qDOdkZQIeBocZIT++UHVu56BGWlBqn5UZvw==","signatures":[{"sig":"MEUCIQDgq25xiV7D+mMF5wNz+RjTxXzajIgEGBXnvswHWQuzzwIgZdwJATwFe5sSHrDTqKvPclsSAUaEJBldbXucso5fzgY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0US0CRA9TVsSAnZWagAA2jsP/395Dg+LgG5uTULi+IJ7\nAt+XUMaUpFI7YIRE7My3+xFBc4usQ95roBfDIeITcQJ/qFMLUO703uFaSGz2\nD89aoQx6fkLg5HJ0RrhDvaAWiN4Bv8q7DVZAHJ0xTu8blErz2DU33oq4iMBJ\ntN00qjqJtW6y/qW9Dja7KhhUNnld/0egbykhBCmud+KLahUbnNDxGkC/UB1/\nn/ov/lTvx7ft86M8xNplrilt4ogf5AH9FkfcHp4+IiPuwRnmGPraxpm04mJY\n5WOZto9y7R655G7XuItIxtETB2xcpZ9MqiS8RufV9YRuM+4Y1h09tA1al0De\ny8HkasSuMjovie5BNN/c0tYMbzRSZdz3fWuvfRosdNevKDlogKu8iIRwnAjH\nocwyXLABAMrUHaPWHW3yIaG5L5nuygYK8gQl1GVP+v9K7AfSZnJ8CVmpElrZ\nifc1BndSsB5P7wnLNLvfqu5HoDLYZge9C0kOpvezAgoPebQ+suHoGd7frCPc\nSIxKDjc/yHhcxu+kWAdpuNEpC18AlQcQSDiZJNc+1xVNcSj4iFCHTWJzdcGD\nmLlz4/B4e76r9TWQbIpwvDHwvHb/r7Wmzm8svPNwwQBApt3SnN/MbFvVadCu\ndA23ONeFsx5nHEoBgl9cj5Yk5hW95/YPxpRlp9IJdeXpC1TCtuLLiB8e4BQx\nZN05\r\n=CUF+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-113bfa0-1624327300399_1624327347548_0.28022522306387465","host":"s3://npm-registry-packages"}},"1.1.1-canary-33a4c11-1624358694155":{"name":"@iadvize-oss/store","version":"1.1.1-canary-33a4c11-1624358694155","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-33a4c11-1624358694155","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c0a77e56b27dfc841366ec9e0a68365af9b19fc9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-33a4c11-1624358694155.tgz","fileCount":7,"integrity":"sha512-Xy5pip0pmLs9zz+eN/Dkssu/DgZxrhWprrRTQpN/JV/ZH56uZ/wJBlFiL9Saoyh5s2cmcEcKJL4I37AtLGVNZw==","signatures":[{"sig":"MEUCIEgVBGWMxTKzsY+31NKupCa4pcWskHzU8Alev9Ia1avNAiEAzbkzAvRgM/DsMNrQM0Xq1Ylv7Wq0FUVLx2ccBnkj1Rs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0b9XCRA9TVsSAnZWagAA5uQP/3XbZryGJA76+1mNKopM\nRc1GavAIcUSJ1KjyhkZADXqePSLPSvK7HZ5CCZz4T6uiv7WgSjDiZ4anz8IF\ncCeLQMoU9oy6m8GF6pshvQjnMmlPIeHeVx2W0gW2tVHa2soGOcGiDqk4OTek\n+XYFCKj2s7UhBI9J5FhQQdS31WI/nvbMsx+b/o7dpQm4ftpucEQeNGSURYC7\na2475cPyDhSfPJHGPpVqMgi8l9WHSiUc0PK3yNTkEfavn1spD+oNgr/EsH5L\nRFSwCgyBgC7eQketNNCFVRTV+Lefz0ByLKwHx6970FtLqF8NByX2wF2HQnTn\nnhwL6J+GXmCn/fZLsccVlUD3kmZjaMlKVbzNn/bk+Q24S6hB8boGeRZkFfhh\nU8JYffaK8A7GAQfSg11VVRSzh9RPkKHnPomGW09CJUhE0u9XKfeUH6NmF9C2\n6UEutIeVMER45C/Pq4kpWF33cvfBEYZMAz4W+0ID7y3VeL+VVjV+UcVqgRXI\nbFOXG86DeuYtWCLlFmKtnVNjQ2uez+3vz9GuXhqIgHb3pVYf+PAUPxCusdbb\nGZVzuQqHUo3L3mWJ+o4HuDQ4/n0xmRiNHoO8z0RSRBE2Sr30ZKy4bs2qSvJE\nELNt+8mO686C48N7qf7DFyBlDY0IkYJhTLd23vvLL7GA26LwYN5acDyieZ5j\nZTTa\r\n=luFW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-33a4c11-1624358694155_1624358742368_0.6474027659995123","host":"s3://npm-registry-packages"}},"1.1.1-canary-33a4c11-1624358730494":{"name":"@iadvize-oss/store","version":"1.1.1-canary-33a4c11-1624358730494","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-33a4c11-1624358730494","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"84df1856da7bbe67c3f97d89cd33a119b53918fd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-33a4c11-1624358730494.tgz","fileCount":7,"integrity":"sha512-IdIp3dP+r6A98ZZDEwJj5ae2tnVDriFrAQuQHQI3kbFjJ/8SLq4YR9vbnVe9DrlwuvB81OmSrOjGCaXBkdfZtQ==","signatures":[{"sig":"MEUCIQCNyR1HzRQYDUq5T4b1qLK4x/EZSJi7HnxKljDOawhqIgIgMGQblAGHH2D9MjUb8mzA0PPj6IADOsxFGyYtmO2E0TA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0b97CRA9TVsSAnZWagAAkr0P/jBPTUG1CLji2LEoHwwI\nDjdYeDubZZakqgLcLTA3I6sr+nWpBNvo7TY2OfvXYsdeahxIi0EaiCb5CUa4\nPXLCDWI1ltuGKyAocyMw6yKH0NHc6YCOw+fd2MaH4gfTiABJce1orO0NGMd7\nP6oyymhH3E26MO85uy469BlDVmiS+IzE0jzPaT3+wFFOMPxZVhUC2HU/RK45\neQcnSXrsBVgQJht+CGjzGTORuBrd8S61ZY8Y7RoLx5/3n78jU9OxIBq/gQ1a\n28hTkGNljNHqDiGP/hSntzybCC1diRg1lOYB4mOwRZpWl4bYxMMaQbxcZ1pm\nOgeXPmFrSzt0GkK+BQcaiwda4H2dXpkULOAjje4URjBqu3zGRML54w0CluMF\nPk7KfeXPNObXq9xEZyAeDifX3foZD/ksDvPmMRraGNxuYMkuH9SWrgdPY4Lo\nT/E7hxzjE1EpWX87tqCUfh6H1Ef8GA3WO7FlRVcXIZAMu/pSjaRaiHPsxD8y\ndt5tJf3CvVKQ6iz580XquaGpyhnX971KmxYV8MoI/hf00LJVVai4savh7CF4\nOe2dFLtIp1qC3D3PuMELmNQeCRNN/39JrRroWOG/wQ3iVR+bIIVEHIkHAiht\ntWMSTqmvYhL+VigEgpktn9UEnKDdeq16C5P2F0XHg7GlUGLkIbmKTSDzmEhi\n7z0y\r\n=dq97\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-33a4c11-1624358730494_1624358779003_0.3345978862798924","host":"s3://npm-registry-packages"}},"1.1.1-canary-8f98b03-1624413719138":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8f98b03-1624413719138","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8f98b03-1624413719138","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"880e3892ca719eab5f833ebe09023a9c28407ee2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8f98b03-1624413719138.tgz","fileCount":7,"integrity":"sha512-BphvL4W1ZEzU+VMUJpGwoBLtmln/WDezkpECqcG8onDDUyadHWHUKn7bLv0tuv0NU6Ej2IDWGArItovHeZtlBA==","signatures":[{"sig":"MEUCIQDgiYYJyLst4kVkOu1/xUSFthjZIwKRz87yMNHgU90eiAIgPCaYS9PoASNq4m9xuiUq5rX4H/0j3l3cTqTpzYBiFc0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0pZGCRA9TVsSAnZWagAAnTQQAI02WLF9bG8R9ctjDk7m\nAPfYtZgVevu8xzM6ODHRxtWbcBbWjj8Cfjiwo/VVzautNK26zW+DPMdSWPr3\nLp3hQiLzRNEsplR4rA0P4g3bMZVVslprGji1olmgbvB4BUGwFOdYm5JJIlQ/\nH5xGxkpO5UuyZKs6MBsP+fDcpwzUkDaX8W8DWxwU6tAJ0hFq5/LdUzh1wq8w\nfiT5dPds2JVJoHxJLTMjUsXwEvy1KeTpcl/B86Lc6uiiRW+VW18P81mfp2Y+\n9C9iVZsA5Bcqvm/Tx+MgxtW4lP/WKJC/qtj4oHKAGdTuT3ltoY6Ms1U+Mg6p\nuC4FyCzEuTLPB+Bo8hZPkvDr5xSuwgkMGFzWgwQOy7cSgW+ohefjwA+N3E9Q\nCKSh59Fl/ow+EEPAg7YxwY9PBasaxCAxTYJ1nFqdfDPmlNToUYeTDTrvU9RB\nkeUTCsMabgDC4dMECiTjTeGmb7FFeAd/VdfxIdZsgmiwV3BaocVb8mY6WRHQ\npKDKRmEYmuAnO40UmPrudJ6s6LVQB7G+Dn5hDoAzhUvVtXtahjm1pqyWCffZ\nTpumW/XqnidKBJTZ5Ki+1Tl6IWhQBZZNoOMyA6c4UBQ7HDgJ+8HG0WqRGskn\n08+YBXILCMm6nXSmOyN1wr2Ij1BDPPn+BrQpkyWBl5r6I/FiD9CpLPSoA30g\nqvlu\r\n=rIAK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8f98b03-1624413719138_1624413765945_0.4082016571808005","host":"s3://npm-registry-packages"}},"1.1.1-canary-28f2a43-1624845714378":{"name":"@iadvize-oss/store","version":"1.1.1-canary-28f2a43-1624845714378","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-28f2a43-1624845714378","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"309ac855bfad5d48fdc32e7ce6fdb417a838a5a3","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-28f2a43-1624845714378.tgz","fileCount":7,"integrity":"sha512-ulc/BTY7UyplNLrJuH6Yiyiq02mwV/A581nr94VgBlFU2B9jTntWK48zhgFB6Zg3IAnytejjDIqur6Bkta/qrA==","signatures":[{"sig":"MEYCIQCtk6bno5SQpj7BcwIBG55kD4GkGfitRKmnONZtl1GxUwIhAMRq3a0HF52m/kjRkHT++rAj0oxsbAMLVl3+UuxZ/Lzh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2S3uCRA9TVsSAnZWagAA06oP+gLIT2EZx0zqDdKw0qF7\neWrSRr/p4SHZ7k3JXJExtS/i+e6oarla5KOOElLLgo9oa0SUz2bRywaLR1Zo\non1vadGCSy5IHKggmfnp08HFh3jBRbw+GswiijngAJT3AZjO3I+ke8yrZKtf\n85hpvwCN2Quarqequ8fhZ3r1d8LVr8HDAwMYYiFo1j3HIXeGAxNrzJQNIZ3T\n5BKQxnymcjPlpvYDArQi4MB+hqdHPn71XMfalXnRm9AceAwmSwykXY77xOKU\nWbkH8Q97imqiP7ZcuiGl06/8h9J80yvzRflgdSaet5TS1lRRkdqGtgVU3H2x\nz9ZGlYymw+DtRNSJ+JFqpwNp8EhpnDs9ijYOG7TaCs92SDU5qwwbfm3FXMos\nsZcdNrgXcv00ReZV9tuO2v8cIDSG7drafeY9Zox06CTrQCQoAabWKAFeA8vL\nZtZAoDWsfx72zVvSkdVogjHDPLorPmkdTnzCH1VYi1/zk2W0aX/KqT2l52Yt\nQ3cNhKnf5/Cc7d7K3XkkfkpT60uXSOiHzeVh5rwkeQDdvAzs73TjYVoXzJyb\nVJyaD7nujMlilpL2ZDroYu/VM9hahhaAQRUh5xOBU28vwdTYr0M0DCs3Alg3\n+RVpEmFkg/S81t+ynKfPEyEDWafFgaxHbC1miBqb9PO2RllIi59uivGnfprr\nBCqA\r\n=dHC5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-28f2a43-1624845714378_1624845805557_0.14870688138294108","host":"s3://npm-registry-packages"}},"1.1.1-canary-f0af1ee-1624880367591":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f0af1ee-1624880367591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f0af1ee-1624880367591","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d2180f99a0a8909b69c23d26ae54ac722b5617ea","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f0af1ee-1624880367591.tgz","fileCount":7,"integrity":"sha512-yso0IODuSzvp1ed+DVumx+IDBfi0ygiK9Gpg4SY/LLQfH5egZGTFpkLo7JI1mZBKm+aVLSIHPCFB6iUuJTqmng==","signatures":[{"sig":"MEUCIQDM/xrK8WN3A+Bv75cqnBFI9xeWeb6KPtlJaY8VdVNPegIgZwRXUtiEpzTNl5mRRRZVgPLg3kilurxJrB7SwMUOMLk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2bUlCRA9TVsSAnZWagAANY0QAIQs2XRFyk7Qozk6LA3f\nim1QyQ3SBu1uIGWpiODj+8BOxGrg+RnQ7qm/yR14+fYMuG4s3FhG3Zn0C1b2\n2+4gtp6AhdS+5IfIGeZBY6vAelxl0cLJY5WioIPV+10H9BxBKnHBLRmQeQfn\nJLOb1CbgNW+pImzipeSSgF15THwZmQuR+4Cg2ETtguePYnQoRd5yPyQwzbfw\nfpurzvQL0ir/cs9DAGyLayuOqzRb0aIFteJg0Cx97NLsaNcg8v9WX42L0wK7\n3oX5LwdRUwafTw7pG9VUFIdsBeLIYXAp/4wboAMAtGn4fbKUrkbtI1nWxKPB\nylyM+ijumP73ZYnGIMPSEXRJZ/9vpNFhS1RsNJy+u6wSx6a1jMHOO8DhosxW\nqU9c1LYC3LwaXlI/Gfo52nLxHT54svskxv+ZCfX0cYtAC0lezwqIJfur6QqG\nP5aMKO3vCVkFLZA/LPgskkAbBYQ2zV806QASrX9GofYpWoO+HXEa/J+gA2ao\nq1w06P6aQCXSecz2iJY0TfoCI27eL5pywF1bS4pQ4N3rnmb33DVO0xmonk2T\nsG1FoV9URsrEJt190TdpzrxqPjFwNllExf/m7KUZvwX2vVEV+wth/aQtzJUG\nKcCUgcjnu43AI4AkVn2HsmzdMqWRNgvzFpkAzxGW/2+2XtEuknE3I0nrLW2k\nWTWN\r\n=lHb3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f0af1ee-1624880367591_1624880421101_0.31362574838676394","host":"s3://npm-registry-packages"}},"1.1.1-canary-4ff2d41-1624880709792":{"name":"@iadvize-oss/store","version":"1.1.1-canary-4ff2d41-1624880709792","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-4ff2d41-1624880709792","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"12d645d7fd2fc45a5cbcce7f9dd9c6d1c174dce8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-4ff2d41-1624880709792.tgz","fileCount":7,"integrity":"sha512-EWnx3vqxRJzc85ro6rRGSPqHmtRHbqOKVImtKBaOQVjq83BRWhfvbKqKOcpN5KSy/GxPlmF7+SwxsJDs6Zh7aQ==","signatures":[{"sig":"MEUCIQCWXK+OHZ/jWrZBTSftuX7XzzKsZSm3bGl/ATJLA3hf8AIgB4a7Z63EiNPoTB4xvt1HCFK46PzrDSZxp1hp5RCS4TI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2bZ3CRA9TVsSAnZWagAA+wIP/ja7pUQQ0szFgg5XpDFn\nJw5w1PF/DkJaNAb8aNTzUsepUqsJvg+On9rHQYTT/r2CV83q4rzdCkifI3pg\nZtiCRGBUquuxjBcykPMFkcAbFilQ5S+pgd24o2Ci3Jon0fzroU6vEDnocCCU\nobTw8kjmLS/wGoSwfD2hZfSsYj/epGbHhVEoTg1OTJ05oYo3eoPy1YYxz8+x\njY7KLf90u/swO9/ZFNioK3oMlpcYliTMLi6+WkJn7buNL+3NdvSa50vS0jVn\nogb04fZj1lP9DlQyW3x5X80snke6ZmwxeUyLhF7yTuNbP1OeemHCWXF51gj1\nCVKo3ciekqny3yh2jkvwul3RgTSdpcu+5WIS0dWY/dTQn6xk7agEs/ave+Mr\np2UdL/ulQzms8K9WTdGszYhU68DvB9R/1LShldkA6m4nIGpCuYPqwzd6VsxE\nMqjZioXW3k1j2ZfV+z7ogRwlDzNLqtrfiFA3DtHCWtx6z5GJVsja9fXMF85q\nA12EtEW40VtUesJByQQm25ZAOKhPByJ9/Un0GrrrHFRfFX9oxpFEyR/Sdibj\n9elZxpa1Lredx+xSLnMMoqkNMYrBxT1mr/9eBwEVxXA6TvEap3m/Am3RIf3U\nLoutuhiex0weFl8+4arw6KP+23j5g/+EuMg+0FY3K/9TOpRZyXLwv4VuL31c\n4YqL\r\n=pZae\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-4ff2d41-1624880709792_1624880758815_0.5134781703815916","host":"s3://npm-registry-packages"}},"1.1.1-canary-1a55803-1624881712791":{"name":"@iadvize-oss/store","version":"1.1.1-canary-1a55803-1624881712791","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-1a55803-1624881712791","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"aae1750435241452725a8163f78ba3a5fe1ae8f0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-1a55803-1624881712791.tgz","fileCount":7,"integrity":"sha512-rU4Fr5zKrWDNFEjDD7tmk/DmJqF7Uc3qjSpWp920IigFFL9Ml5jT3XXYCea1bmvBukaulwbJWPjTdTCp6oci4A==","signatures":[{"sig":"MEYCIQD8bLPPmvjaYi7KC0bCylu4jrbNcQpQk7NXh+eS39/fpwIhAPYOePlIbysTGMjEAufw+OPg08ZuunJ00Qu4z3JPaw1v","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2bphCRA9TVsSAnZWagAA8icP+wZC8EJ/yZYQ+xQdJz9Q\nDK2m2xga0d7EZGKaVkOwMNcjlxEP2dxyguyRExDq+04WbqwAWaC+8lL9HgZ9\nS0EIRGJxTjVvlR7eMSf6bn1r/R0W502134y9V9rhKmuLxxZCgdOsdI0NUdZt\ne90o904TSgr2tkcFBbszd+AkKtd19ycOpUv0KfivxYWZB2KTqAhUpxrhcBGR\n0SVQsW1ktMj7cY6/Yj5fHUMuRXCRCRp9DQpGni6g+HXJIxp3Dh7YyB+V3wXT\nybq2lZaRFkItL3VSKK92NofyptH+9M+WVufdN1GYz2uy4/IQmf2xl6hJZIY/\n1Ai7shMUNZtgpAAvxjWYe1P97q3HXm5jl/yZm3cNC2+jugZLML+KaZ4A8Vip\np0V2XmZgW6TkJYiWx7j8vQV6gb0yMqYjSWBEOaBQn2RaUjhgnW7Kk+I6Av9R\n3wm5MpR3jWI3rwc8hX95iuIfY4g9kNPcE+6aQYmQx05SBDnukIC74S9CFWGD\nQ2P3Izm2EqIiR7KxVupXRWQxuZKlNHfHPxT1+sB5wt/EGmYG9ZOykuXNLgzq\neE8aB6WX0XRWZJU1Oz9EUfIQFmISEY1GLyZuXxuaUXYYxdPmJvncO86h7f+3\nRNqenVH77O2ityBN/1Sd0n6t2r5tt7sxImt1e3xgZdLE2c3WSe7T225FmTKT\nbq46\r\n=00Jo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-1a55803-1624881712791_1624881760891_0.5224419240893621","host":"s3://npm-registry-packages"}},"1.1.1-canary-c71afe9-1624882110424":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c71afe9-1624882110424","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c71afe9-1624882110424","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"936815a61d2d5a24008e2be36d3a9c753a283f93","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c71afe9-1624882110424.tgz","fileCount":7,"integrity":"sha512-8zWNVbudOhC2kA6XwgHANzLDtyemIXTAFEEeyHLzvuf/50/iXtQm9fPgC/mkP/zzWFl4I3zNAXNuYgRD5m2pzw==","signatures":[{"sig":"MEUCICv12Jh5Ed1O3TFAQUHdISPopSW+JATRteG/jmVhjp8/AiEAlzQAeigRGj7WEt58jmR5tLteNq2swmNo8cR0AseP22I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2bwQCRA9TVsSAnZWagAABZcP/3Fz9tKuojtcE/x2hXtZ\nY/h/F/aTLtS4QtqKXZ3DK+Xn/1NQrASvz05D780+pgcTYfpC4f/uMCx9FYph\n+bf9jpQPRy9HTlsoM9hlGXb0ZH0J9t7mGb9VuByMSaGIHSWRxOWkbwPx6lxQ\n5/E5y+UQpUuSHizN0hbgWM2LMZjmFRmuAncxkyHJud2Ca+tiOk4EUe+wWGSK\notuZby/c44Utvdk8+URX+JpGGDjLe3x4BU5SwuVXiEr7r8rgGVheh6TfEMlR\n1VlRHy6VvpjqtCnuvINHovTdxdfheVBzriLwF+zburxTg1Yf7AaF4kPHROs1\nHaGZ3hWkX1sY/5stzveXAej/UUp87HNTCwpXU7s1TAbJ+arFY1ZTTk1TvfgR\nZ3fo2G4OAXEg7AgjJVXMWOYgmc5m5AdJMOFnxFyheTTJcfAOFuLVSthTWO/v\n5axF03eXdljxsBu8Wqdu+Uw7BVTyvLwnsKUS9sgkiLmRmqkZnRHnifZ7YHCi\nd4A4tm4LlAzJ8SQKiO9SjsCZzG0Vzc9wCdkLbnwqmzQyHB4+9CkI/qQc1zuN\nQrjcCTs6mY97r57zc3Pu2yWClFa4R1LVtPJxNe9t7bB1NXyRC1Oe3dzVqGQi\nL6uhc86sR6j2h/hVzdRP7Hn+sBZI9wnz7PHSW11twiymEmHmVA8sm+YdIiq8\nnVTM\r\n=jUeI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c71afe9-1624882110424_1624882192073_0.9405071224172017","host":"s3://npm-registry-packages"}},"1.1.1-canary-23c429c-1624884007352":{"name":"@iadvize-oss/store","version":"1.1.1-canary-23c429c-1624884007352","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-23c429c-1624884007352","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"86afff342bdc1a6fecbf9ea8c43c5b7bc0025ed8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-23c429c-1624884007352.tgz","fileCount":7,"integrity":"sha512-WjCbgiYuZdr74JjHwz7mnhY/ek2AHjsaQ3R9Yw6iTTL4daLMh75UEeeesGt84j2Z5Sssv3qgr/ptZneRM6VN3w==","signatures":[{"sig":"MEYCIQDD9fnn4qg/yPnBl9ojPUy9RrlJolFu4vchaIbfO1YdzAIhALTnkPzsOPj9fT+cV+hMRwafaQliVV13Jit7nUGu7aWM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2cNVCRA9TVsSAnZWagAAGuoP/AwxpGPbftemOaGfCo2j\nyZzOMUwkRBAHkgHiaP55J51Hd/T3xEZ4cG4DxqllyZc3fzQmyeWIGCsu78V7\nEilr5rsFKwQc6w1quWZrzn2+wbeK8hBxJSZ1NWub3w1+g1tckQ4yBNsOOxHE\nH8487g26eIQnjn2o3YtROFfcWqYX5WGMqh4sqR34cPsAb5WyYhPRTPI9oVyD\nMY1HTA4kaBl9JrrFDVwdZWwYUm1sim1czACohVDn5iTj5gCDJljHOx4ZH9At\ncoxxyDeu+M8y9ogEaIq5oaAR7sDhj95eTabJK8NWPjboRQbyQhCqMfnjCjfY\njhzjkgbysjSPm43wx8i18Y91nD4gH+WPYMBnVziKFzBvAVBvQO3hIRZ21NG4\nczLvniZhSLGiLIjGuuovhkiw1HNibg90JW8lm9TXxtsyHscs1g9J13bKfL2U\nMDQC+H5Jf4pJtyBw6TRchAKIx1HTH6LTnjDsHJOdQ/H0bCghqrjnxmL07RC/\nVqki1XKT5kCPUPBMqkfkpE2a3zSetV7JSOkWCjghuzsgGd3hUaq0d08tT0E3\nbmsGFIcr2syC5iH1AQd4Yo7BdJTw2Tl6BSuDBJHVcP5XXGZqj7taMkxHOGx5\nUATfM8/9fYBtigwScGUtp2cIwnIEi8ogBZtd70ihgxjaGcK7pQvBissQDIjk\nZd6G\r\n=DIzF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-23c429c-1624884007352_1624884053309_0.44974734068465083","host":"s3://npm-registry-packages"}},"1.1.1-canary-29c10de-1624884270175":{"name":"@iadvize-oss/store","version":"1.1.1-canary-29c10de-1624884270175","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-29c10de-1624884270175","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5b84cc94ced3acae041083c01e21e021a5396ff9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-29c10de-1624884270175.tgz","fileCount":7,"integrity":"sha512-AGEhs+LgM8TdReE0xF+Jiioi+IwEbhLkbzimPhw+urK2J+cW4Fs2Ura79LMDNXlMIhUWIidaCwgZYRPQbJ1Y/g==","signatures":[{"sig":"MEUCIQCFqi/nhYOZurXeqSeNC2TQ45kJQVNLgKFushrXTbQdDQIgSFx8GRRYM4EQ8M/oPbqJQDQMiJHLogaC+2+poaM6Th8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2cRhCRA9TVsSAnZWagAADHkP/0WuP6WRBAMn9+ZTHccA\n1YFHGPh+NBqA7Ib0zh5FGCLmyc35du0x8vuJ/rL1/dtkUKg313X1i5HpT7Ki\nh0/wI9fcrcGLPjIl8uJcoCXKHYqQppYjJFPtEuRi6mFuz4GHAYbD8NJU2GvJ\nsgv2hGfutU7vJg0or8uR6QQByCqCdumZrI9bAWHwZT8mMR5kJTxVraTMJXN3\n1vW/pb1RcRgioK/UdsNpxa/cF+ygAIHGaVhJkMFHuoejAchF5xWH1u3KXcfs\nCLBQozGaB1bxfFKAKd1f2rmbZdt1YWSc1SIhkr0J6Qp6Q8H88HyhnY+f5VdF\n6wFi0fSvaeP2ibl4QDy+ktDXOSxRSkR64QacdjaQXie8+7pHh53yJ+WzG8kJ\nXyvmBvp0coEe6VRb4HaN6Wmb0XdQe0pO+WcIvw89r2VbbCSjwYxeFgOqySFl\nU6oX5yVrOxy/wvyLXFNRIsu1+mJWXdpJWkfEAv4aNSBJDwRwmy07q4o0e8uh\nVaf+dL5J3OOMuMhFsQh5KPDGUHb+x/a9Kfux1R/M34VZwU/tznt1Lj2MpxUV\nv1TTji3QFl8qus3TImH0MWa0/aLwCMOgDR9n084HitjLASYCHvKiYP2rtgm1\nWCPbyMeHt+k/tN9Wg70fRmb7HAjp+iGdN8hw46Ah8T6roy6bVP1kVbPobWVP\n+kjp\r\n=/hQJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-29c10de-1624884270175_1624884321433_0.9830960413550645","host":"s3://npm-registry-packages"}},"1.1.1-canary-29c10de-1624884299465":{"name":"@iadvize-oss/store","version":"1.1.1-canary-29c10de-1624884299465","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-29c10de-1624884299465","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a7255ac84924972b620a1658be201adbdfc606ca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-29c10de-1624884299465.tgz","fileCount":7,"integrity":"sha512-85Nz+RuWHYM1+oaLy1GlyGy9yv5xnIi6qI05mfl0uEExr3kWxlZdoapI9bTKN3OgixDOvwfynbaU0Cc7+bVwzA==","signatures":[{"sig":"MEUCIQD5dwbC8XS6Mjopg46PoFGbQbPwNCw0mO/vbMbcdPqVXwIgIJ6ULm1vAnr7Bo0hNXLJS0fRAy3Q/yaPpkQZGi+tVlE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2cR1CRA9TVsSAnZWagAAnz8QAInTsgrIMBOfpqa81VtX\nBh3CU8fWibrqyW3fpTNXwHXCgzQKO2iQOG1N+xxjXHtXUmrz13+1ewHuTuI+\ncRnkGQcRjEuEjB77xG9DT7EhkEhUdKRyPOhKnyMYC1slDJXOa6wVXOLUGQK7\nE8TUqAt1NZyVpCN35hz97Uyt9SnpWWqrBcXLCTYl85tDDstQF5WOJiCsHZJV\nWrNrHz+up5X7fdxjB/m8c33zrv5oULsAqr4aDbgU9Y9yClvL0SCcfrn/x+QB\nRPzGRf0+OiJn8q2hw48oCY4Pc6diERwzHKJXbJC6v20O/kLImaOzR0BpjTs2\nu+w+z5SqxxU9hwroLICB92ltYVYqaPqsrLtQT4X1KjFbTNRJxqIsFMXixM91\n6wGUBDx1UYb9pnK+eJYrmqKYDBdv+zlGM6x6QvKEN338IOgjqTGq21w/Krwn\nLuexDUtPSlmq9wHO3O095Amwoaf31I8KvGVWIBETeXtBr+GXniQqkN+cB/2p\nw68FiiAHY7SVRXG0UvR3zSxGJ01Xee9cTxwOJm7Ykg3tzmzTkGvFeHQkJbxq\nct6K/Bkmnl82q8cz5k8vIqilWFzeUju+Zw4IvcPm3jahZcOIoDUVyUdGnOzx\nGFEW+kKZ1ZCPlcMYmtzaBa4D6Nc6bvMsdCfLCcIvJEmUZO8mHXISTMgmpW+w\nGWed\r\n=USNw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-29c10de-1624884299465_1624884341129_0.35748850009160105","host":"s3://npm-registry-packages"}},"1.1.1-canary-026e962-1624932103016":{"name":"@iadvize-oss/store","version":"1.1.1-canary-026e962-1624932103016","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-026e962-1624932103016","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5301adb371707f95f084531ebbf88ec91c41903a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-026e962-1624932103016.tgz","fileCount":7,"integrity":"sha512-fW5TwUQEEp7PjtwRxq4/t3rhxYHnCoAwAdjg7eOMzlvpvHJv2saYIW8ugpcPEMKUmGXsdwqhLHB6pv364FZOQQ==","signatures":[{"sig":"MEQCIFiftGN1R5QOQRZzYlB//a1uqloP+k/uJwn7xfvnB5QjAiBI7VOAFPQ3G40hefiYvCHLNqT458n9FOJ7rSadbc0e7w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg2n87CRA9TVsSAnZWagAAcSwP+wVlJXilImDW85Rm/6i0\nicgRaaOCnK4fHtlqqr1ijZURFaTv6X/2mgXHTrsfNtteCEn9vrvTLG/oZ96B\nMGZlSElvvbUMvi8d5FjOu5ia6jlLwoTlczMWGQBBaRTBbJDSZJoasH1Tjknv\nQSFdk94ayfa9j80HnJC/eyjxRv6MGHrGqn/5bfZ0xClNu911XniME+p0RF9F\nC3u1rwLFzOC3keZkwvWH5qyZa3xqg8zvP7ItUtFBnsK+pUEwH6vvD9J6g2fi\ncUgKs0D2a0BBTwNeHBrScKOfJmlIhup2OMWzAgZZtu1eJwuSu74hvRKnQd24\nUZbLTLDmrzqe9kFGEFKFlXMYa5t8tfGfLk/L9gi99onqcxvCewA5EqazbNoZ\nZQ9j0nsubuh5C8nEdr+vSHhgcOV9Px1/0fg2LJOFFbnGjaWewdINX71fQCgm\nQhCxwF8qlAEGH9knEUcJgBWnQx4AhTxzZdJW993gtRJ48vBMspsz+qOMbmY+\nM2b3N+VwpecDLHVNuMhZ9q4ozu/c2vCmEqmIAScEySkV+SXwsUBC4hWyquar\nrP+DgZzbsP4tvAydiOzYyU32vwRAWWZvf1UWvEc4oCucHzqhFWLsOu09ze4b\np00+qhGNIw8yUDqBbBy9OT7n9dep3kjOH6Pgwha+Y8++dr5j+ljWhhRsH0Iq\nC6qh\r\n=oKya\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-026e962-1624932103016_1624932154183_0.2452390519650196","host":"s3://npm-registry-packages"}},"1.1.1-canary-a0c26e0-1625104984196":{"name":"@iadvize-oss/store","version":"1.1.1-canary-a0c26e0-1625104984196","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-a0c26e0-1625104984196","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cc52204c3e32f5c26a93147496e0a620ce086ee2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-a0c26e0-1625104984196.tgz","fileCount":7,"integrity":"sha512-C+81ELbIINO1LUNLaIEU1owujt8T7gPV1seUZ7WSWTHLMxmxQyqbgJEZlw6iYxfKTRAcVLg9ric4ZL432GQz4w==","signatures":[{"sig":"MEUCIQCQbYq0dnJul71bzU1UDWF5fvhJUP5lX8L8RGOHt7N2xQIgAdnVtYBM0KMIQmo6qNFsGlfg8J4PQf6yviU14QCpoD4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3SKTCRA9TVsSAnZWagAAZiMP/2X34pww29rg25WWxwEo\n8+cgxBOFqVcwHIA8uUG3TKBrwni0pi1CMIv00a6nHIiKA0ppbI1ZVBE038TH\n2HmYsRWEw+jNCbAJc4fvTE7AGU1IZK4sIwDS1NhfZIdOGXNGKv+WcUZPePz/\nea8nzPu2ZKx5CmxSjS2huL6gwZSTlQaHFbz16Mfo6oNb/M6GyebLLcmpj0Oj\nhRb+ISXtJ+4oxwGkcLbipA1obJqBTkXwcVb+1bgQRZ9VKwsCylXOzOMli5kK\ngPK0Ws3Sh0B6CvF7EfoEKUV8p+F+Oa40V/dpTdlX8FSim5ov23Q/P+bqupXO\negwRwSWaf3p8PGtRKr0OHwONkO2I5JJIrVKCd8eNinumwuJnC+WJVvSZfFLL\n6C2aoPnEptR+KwSUm/8c4P2SICRH6ynqDUEouP2SLP5+KL8YiPdaLf0E9q5g\nGXghLvbaJL9h7e2o1uTVhaOdriR3Lb41fJ1dXpLtMkw14SNPrDJNxxi2ktiG\nEOzaoKsgHayFDMdLfgEM7ZLmDEODuNJc4tjKjp+pgMuYCExS68OOMAFTak2G\nffqzbRlYp0c4ynWovyd5/0aVJP982OB9K2BxC3fCDWrPlwiwtYfgiBlsPX2Q\nrkGk4187TaK/PJa7iLNbc2Z/i0Q4FEXATMGcW1KlSuDXaNXrtAmC/l2nRuv8\nv0dC\r\n=wsUY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-a0c26e0-1625104984196_1625105042808_0.692767144239532","host":"s3://npm-registry-packages"}},"1.1.1-canary-a0c26e0-1625104956732":{"name":"@iadvize-oss/store","version":"1.1.1-canary-a0c26e0-1625104956732","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-a0c26e0-1625104956732","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d40c00155e889e1f0eeb66046c8de774c7850153","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-a0c26e0-1625104956732.tgz","fileCount":7,"integrity":"sha512-HAao9CZ7X3+JESwMTUFQyKUfP459OsMm1IrVI+xrLyghcrJ+rqU2Z2bDn6/MpOGrOKhq5WZC5+rEDol/cnfbMg==","signatures":[{"sig":"MEYCIQDepjhJQ+pAoPlQHRDPV0MYgG0IA6Eer41LzHZfOmlsxQIhALvFzl1a9OSE/eCgasEROZfSpYhz46IA/iX0m8w8KZso","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3SKbCRA9TVsSAnZWagAAifMP/if5ku1MMBsxiWekgr0g\n7siVuaJua3UMw3WSXeoHH6tQY19hD3MW1/SDT/7XmdU/VubJdDA2CkJ3bgKT\nIEG4nNu3ozjr4XOB1z+pYZU/y8AkZ6/4SZ4E46Ur/DcwmJ/Io7lrkEe1mejd\nDyJs6HMLeWyi4+3YdzTa3bmMyD9QhxUPj/lLi0LaqzyPh+bXjLbEcX507WRa\nVLrGh/r88+2K3Uj9bPuzeM4Esmp2ALAvFOZacPRKJ7jJEwIUe7FGtqXaq6M/\nD+XT6DnK6R10vyCzMA+48wyKZZ6BP4iOtA5doTHjUHRkxnHQE+47pJdeuF01\nECgNQrP1DrkZynlENSWN+9eEpgQgb/KEK0LLacHZNv8arN++QXebMbMttV3x\nhYvEYgUUIlr7S2GPl+uAotOODIQvazDuxcPxms3L5L13HTtF8ECA41OcL23J\n8jaRoV+ZK3HjHPcQlqNHSHQ0gORwFWmcRVosD4eYLvAx4BI4O+/2E6kCkGA+\n3E1UGNAdZikgzZ+CfQnsW5AJopK+k12YLa+QwKmeDCW3JSy2K86nMhFd96Z4\nSNmoB2Kbui1MzP+ZkaBNRjwrPWgxPLF7maEsJxHK8Tw8V6/fJ+5jMgVMCMj7\nYcCNBr6J8eVNtXNNojyl4TzUPTdul7rGGt7zbuRK03Z7mvi96rmChkUVOBxS\nLcte\r\n=zJaF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-a0c26e0-1625104956732_1625105050708_0.3318301433185529","host":"s3://npm-registry-packages"}},"1.1.1-canary-a0c26e0-1625104982062":{"name":"@iadvize-oss/store","version":"1.1.1-canary-a0c26e0-1625104982062","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-a0c26e0-1625104982062","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e98a37c218a87f2bdfdb480b8f99f58ef2822348","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-a0c26e0-1625104982062.tgz","fileCount":7,"integrity":"sha512-8hqCY/5zzzjcrEe2chgckaV/TT/cM0CiCGoivWkkBfAzhOfSG53ZKf14/g8OQypWT9Jf6Nbzvl8doQtaRgz+IQ==","signatures":[{"sig":"MEUCIB0CpMdc51yj/Na/4tiKhuMuRMFf8D/8ZpMI6/FTJuKfAiEAq5n2UVuiKx3DB8/RHUNeVu/8fLoh07YDtgGD7Oz+4lo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3SKkCRA9TVsSAnZWagAA074P/0lUWzMAf3Zl4seHIa2P\n7AsXVg7TCz+kw/U2O8jGHT2QPdVogbyxCzwUdq5TisKUfVoSaPP0dqZUTPbN\n/heLmRXaWGgwoLbm82eGjBu75CYOusiDDCmaIBUIJ6Npv+RudC4EOnoHG7DZ\n0k+K2zJ2jNiJz8DEh63aktEbxBvQnbFCWFKMnK+QXEdt0L9Q6n1hahs91j73\n4Joii6uHiaJSvP+YRPjEKMBHTwOVIECBabvKXWbAjVDFy2TTdOjIoQ5Vk6+m\njIf4U/riWHMnNVRrYOiUh7Irk/JDyKCrIhjMPmmglAuKcc7gZwkXKgNr0OXr\n+xEwAnj9NXb3FN2DVEuPvBV7do1q9yjMXdmd0X3K2/edzjLggC+LopJK+YUh\nzCqP99HaM27wL1VukJjrBK33/plZLOKpAYHTh+H4WkttnX/g4Vz3tZeyMDAa\nXjuxUmYJ/WtbYHnTehrlHKGvZAbXXTT4vL94XwZydhcfGyAHYVKL4vHSOeVf\npSP4dOHUgfbz6YZ2Kkmkng6EeX7XgF9Ac+Pmjspu0EDHDY9YyMF0FNOUP5l8\n7BsWm3at521NaMF3zqbeYj7JbALgHnf/eW1xVNyN78YR3XBPJ2Gkmsl3BCAf\nnULliTcv8z6Rlu+6CUQ09UU5ubrfbWZtlUOqiJqO4Xohr2QdSDIQ7YQaItzY\nrCY0\r\n=LKNf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-a0c26e0-1625104982062_1625105060224_0.09443370505747661","host":"s3://npm-registry-packages"}},"1.1.1-canary-7798cf7-1625130697854":{"name":"@iadvize-oss/store","version":"1.1.1-canary-7798cf7-1625130697854","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-7798cf7-1625130697854","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ff7652fc2b42638f923a1e6b69f8351364655a12","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-7798cf7-1625130697854.tgz","fileCount":7,"integrity":"sha512-UZ0haGdRJwCZ35jE4fRLj/GvZaHy04+5UXHasWUcjwzCS6bV8EjtDcifo+pygEwiT9pIiY+X84M3gLxeW6HD+g==","signatures":[{"sig":"MEUCIHT2THTXO59x3uVSM9RRlAvVuUV8UPnZKJoZwv6mWTdqAiEAumFCht7gQbOoq/N6zv3c5wAcbxCN3BQRyPhivGyVZCM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3YcICRA9TVsSAnZWagAArAoP+QGpimgvG+VLizQXRJEu\nsPVrbr6ffsSa3ZttBZFSAk3Lj22aH3NJ/NOyBZMsZok07KZ2z6fJBfA+2Ull\n3GWBfrjvXvF1deoWIFqnnKCtk/H9wncYVEDhJ9UQf2AH/kpZEb7UkEE53VXW\n8oTlQ6jC3mO40VHAJnVj4/OEdSIDP+V+9DnpLYm0iQjqz2BSA/zb+hvvAazs\nbUdKsk1Gh586BK723Cgsbb2EPlfDb/yqiPiLGdczwDv/EIiJdpTYmkjEEFmC\nlM7dM1PBu834mnGUheYHOPBAo0Ik9FbiVwYlulOBNv5ys1+H+omM8YqJYr67\nSI4y8GRIowoGNuW/B3mPgdPJ7ZQcmlKN6BPVtm197dCSnjTP0s0dmYbR4Yuu\nPPAKNc/fNdmlUYA94tWmQQDkbrstpjVz004AQNOXw3ViskuG3KiAORI/4YYD\n9rNEasY30jlLqlbA60XLZsvCPfiFynQn2800d11vgJVVOKb2QIwQTH9v1uod\n2DFGjFLW5prY+M0eq6U7AWoygXnWD3kEQetSUCRzIuRGilHoUVNzI6V4fgzu\nhDy8w7F9hy3b9SzBfTw5G7Kv7hSMup+rsNSwnJhE5sQEmBDxoxIBpwo/d7r+\nnpGrrm31O2lRjQMHo0KjBS94CNd03GJaq9IzA6iqVDZ762tgo38qp2+eENok\ndRWE\r\n=wi3X\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-7798cf7-1625130697854_1625130760019_0.5517436687126211","host":"s3://npm-registry-packages"}},"1.1.1-canary-7798cf7-1625130670385":{"name":"@iadvize-oss/store","version":"1.1.1-canary-7798cf7-1625130670385","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-7798cf7-1625130670385","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b4a61687dbcb5d0198382d6e013ea509bf62e413","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-7798cf7-1625130670385.tgz","fileCount":7,"integrity":"sha512-fYcDCJvUxuNz57Thz5EtkF0GpeRns3UmQ7K3tWMMvF4TEKTWs0+YrGHnaccRwL2k1IGyx2RbSftLRlM3nruCrA==","signatures":[{"sig":"MEUCIQCRdhs17dI8S4Q8P33QfAuZ9UvjKXfGDpSzVs+VGO3RkwIgKtcWqHQjFNhoItNGuIs/WsPS/P0AM4M8b95S54JBfhs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3YcZCRA9TVsSAnZWagAAtm8P/AnCgKzNg4wLXM4OXD/l\nG2aK/J4NcXDVWAaHOr2RuNMVj6FsPRJFi2xVKP5MpWjV9tkOxdnZz/0zAH+i\nG+N798IpFjcr2z3QMzBTJWns537e5Mz/azT5K+aYX5aWpkpfxry+ThJdzM3P\nqs0rMDvXxAk+n+CcgCPtGWBZ1Ua0nnwqBVSr7sO44W9nBmjg+JLy7rnaEzsh\n6wDEF3/3I19TK6NELinLk1pDS9pv1itd/YMRjP56SmLJPWRF5bsBHaXwNmus\nayj6X1WtSNHMU0EIKGMshOndtWPGOdbnzKXuMow+HHPWfG1Y8lhmEfKsqF4p\niz5fs6pAuaowBY5MEw1yRGEVnecrvwBa6WVPiCMFC9PjbitgboXKngnESciJ\nud9xRLRuCxmSzZXPUndAbnV654L5hw8jlcoc+j7FYUGfqum5XmPOaitouQ/G\nocKkBeA6ko8uQa0ww37QV07ouunICyv8D1hTunsexWpc9/hqs/rH5jRuxOKd\nYvZcyGdCPSndsTii6ZtOEkaSdMBtQxbYd0CRjNaf0F48Rw65x/iitQZ8S7KK\n5cNwcfXpypRHlnJXU+YO4xag44blNe/7FocP46B4WylXDiAW8GsgcNiH/sXQ\nMRYKyiquk3OfVvqZ9JLKVjQUZVzqkNcllIYPW8RH9lESS/e7R1bpd2pwjfWx\nKO2o\r\n=fM7y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-7798cf7-1625130670385_1625130777406_0.9667013383541276","host":"s3://npm-registry-packages"}},"1.1.1-canary-c87127a-1625131293699":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c87127a-1625131293699","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c87127a-1625131293699","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2b99a67b0e4aeef9fc5230c2468b29adb41f76c0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c87127a-1625131293699.tgz","fileCount":7,"integrity":"sha512-EIP8ns3EG5PY+IwRLD2UpduHf0uyMcGWYByStKtII6LmYelg5lSg8yIkLvwGfn56rQ13gm3Ss0E03tspiuw69Q==","signatures":[{"sig":"MEYCIQDz4JZlpUMGndBbxCwla/vjbvivHlEF1oHRjvBEOV9IbwIhAJw/zwW6gTgojEWEGAi2A75Yvw4B30OZswdD7uamGF1n","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3YlNCRA9TVsSAnZWagAAOaoQAJs7lDctmjLApH15inwD\nPcIRk044vzi3Qr/dSAo7dbK8uHiybPBmuQBR0NFJ9f+eoClVqmUeTt7bHWPr\nzVuZifdA5m/qdWfkG1jaTWpO7b97fg2yRkhkCpYtzcEQGIhAPtgeFriJM2pD\ntUSTjDN1aiioOc/17SDniEdm2A8c8hihv5L4GAS6wRDZv39tDk2tACOGjR2Y\nuI4uVCa1x3p8J5iwMB/HrvEwaJSiqxM8eAPV0aVms2S5Su9/rqbfa0etEtk2\n8WQK92W7sWAXT3vvxFlg82Cy6WfSMtN+2W5304U8GSoLWoJlJQ+nEzAu9PPw\nvKpP2GV5uib910dTqy8RAxt9rYzead7BKrENji5LJBTEyuf51zEz/KVOl488\nsQsikfUUwQZdi3KpxqEPfW2/JJvEiT3sSNYoXzQyTK1tUwG31wytppTKnLUf\nNYPgtO27YIytbK35KYjJ5cRc0zbBwI4xTh6ekmE3CdF08ir2bij2pa8cJsHq\ncEzONoGi201SwxRkqodWAaZcjDyvObUuYWwPRjtXJWdrCOMDlaNYhCc+PEFf\nWPJbjdNrVb/r69rexrHREuCqTAZ9BSLKnJTAFr5zm9jO+93LOncXH4PY+Nqp\nfjr8sv4K+Tku4xs/yGdwZAFyG6uukc1xvl0ulyHxxHaGF6TAothIL1TggYtU\nggTT\r\n=zxY/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c87127a-1625131293699_1625131341003_0.7627256011212591","host":"s3://npm-registry-packages"}},"1.1.1-canary-c87127a-1625131299564":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c87127a-1625131299564","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c87127a-1625131299564","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8acb22e87130db213f00c1dd5910301db2fa98de","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c87127a-1625131299564.tgz","fileCount":7,"integrity":"sha512-8uKesVpo+5gbuqwJG68c1X9MBjMOLT8ZlCbWq94WkNBuokw9FuAu5ZWC7uotaOFcQgtFGYZjWlXvbWSIZlygKQ==","signatures":[{"sig":"MEUCIHL1YOyt82hFOUgWBxY3h6y1y2SzxlNk3X9H9hQR5k3LAiEAvgdgXJqZW78FANSO2OdkgmajelODscSqyKNJv3IfHj0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3YleCRA9TVsSAnZWagAAU5AP/RvHp/nnKAjrAH0lFs8g\nccpG+0WMWLDlNo9ZxPmCfJpABOJCrtG2ouy7Ac+y93g4Djhwp1XKpZ1J7LF1\nkjiwCmCiicAWdU932dyqevoTfADyTKh7UHzIiQ9jyhpghYa0YLSIJlSUb+Nj\nFulQW490CRXS/PS0OiD3guq0jTXCX1y1/vuhkxXaJcw9uffg9KZHETJmt54l\nhCuCcAOL5gj7Wy28a9nJZ0vDODICxoHNTEObtlcdC4sKrNeyZwQM/bI4stsV\nfmyQ+cPXzg6f2AykpO9A/PYYPGk04RsV8bJhGXvhwhD7XQ5lJC/G03IV/arQ\nxPeuy1/6wVOlrDTwPJffmzt3kZ2ZFeph5YZeJ78/oZBMDrAvqbq5CeVIGkKK\nxsr66o3QdCSQJAdGp4z5s4/AmeNUCo2ef4EwpicDgH4ENcWCxxZuwLslBtBf\nChD+XhBiJGhBcz4IEJJj5JcMkHBH5XW6yp5A4A2HczgyXoTZ+TpMrb/TnXXs\nYZJpHNsOB7UN4RcIiiEPsXKsXsSNn5+FrinvdbJRp6ONFvJhxqawm6Gn/D0Q\nBbVJY8TgGpb6PKglZao0HTsMPkCIx1WkyBHtTeR8TfosX3zM14L6ebnFkur7\nufhSxx3ne6Yc8Qh28p1FL4Ef+IMQB+SDwyGlnG8pEP2fR2CCwUctO7KmDTXR\nIcIM\r\n=Bjaz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.4","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c87127a-1625131299564_1625131357674_0.8798399133729455","host":"s3://npm-registry-packages"}},"1.1.1-canary-deb426b-1625145920232":{"name":"@iadvize-oss/store","version":"1.1.1-canary-deb426b-1625145920232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-deb426b-1625145920232","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"91be7410933869b739f0901f040b161020c1c049","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-deb426b-1625145920232.tgz","fileCount":7,"integrity":"sha512-wGbxtwsnNnIaR22W+ISnyDtoHf1ws8YSoFpX9XKSKbAMEauUrBEjTCzRTZvO+wPW/HtUwUZSuQte/RlKqqSbTw==","signatures":[{"sig":"MEUCIFdGEjIlNwvnLIBkgkuGQ3rEMuneoByCmHmjYSWmeAhQAiEAyqaLYpc2VY8cXcJA3m3tH3JzSD6LnZU4DF1OTN0wJ2U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3cJ0CRA9TVsSAnZWagAA0C8P/0x+n+z7NmoyM9o28FGv\nvmXVCgsD8sn6cY5xFNp7pMptCAufw6xJfUwGgaQbgcu+y2nY1FavQRLoPkZm\na9bGTOc9nwnMd+pcFfWqlQ8uB9gjcceMEHJV9Dwr9U0XI1YwJvW2Nx54cfCk\nbwMEwpBTCVxtGhJsM9aOz9lwPXrGhd5km7Q1DpMyyBGncpm7Y0QVju3QSnN6\n4TLJFydzPjb1accAOpVq4DIx3yhbXRKf0xS75rhWYbONqUqtTrAmmvc7gM75\nEoWM8Y0uKtLbShM1vfmIsDBCkUDAezbRip8UYy09xH6LuELtOGTlnc1wr+WN\nqutdh7nSaOjeoLrc8RliET1Cvg9zD9dDKQ2P5idVej9IDfANMx9tzKneQsR/\n4vMBQX7RvLlqJLX0gFCpg/7/L3jKzJp5xnKP0efuRN+Dqaw64LbSxmO9URL6\n2pCNkQIJXEeRTl/n9MNkTiJeUeAqVJnPjyfElf/iZAKwehz9c8jsi00YY3Qe\nQUmbxDrqklu8dMgdi1Fa1L7D3bq33D8lkPAunob+qOMGfJx89toUycb6PtyM\nQgeLKXsvG/jtg6phl8ZZS1zFRC3gnbxwA0rNUaVh9GYPhjMnXbWLHdLdPRZE\nXxmUTUmfUnDR4/i/EeVq7AgHOJH0/oBbzqwTODQPiZqu+lYdZQovgRRtRTwG\n4rv5\r\n=VDZE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-deb426b-1625145920232_1625145971800_0.7947724518880857","host":"s3://npm-registry-packages"}},"1.1.1-canary-f609f25-1625153818777":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f609f25-1625153818777","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f609f25-1625153818777","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8fae4cc4ad61cfc7a011019bc272b7ecd846f495","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f609f25-1625153818777.tgz","fileCount":7,"integrity":"sha512-rGLG9T/DTlLUlt8mguI8YtLg2pIIluBY4JzdKzSppmOlPM8tp4o1gAubMM3AUf/xW3Fd9foAVlkgkPyYY7EnZQ==","signatures":[{"sig":"MEQCIB657x71ZTkrSyDp5rMPN6n2V8gZ9F7SPH9P/yn5oO5tAiAfV4greBSPEuIl5HBbiK4wiPk6MJDGYZCSA+T5c0EpeQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3eFMCRA9TVsSAnZWagAAaTMP/RHbaWCcLFNFqvNFGIMV\nty3IX+T/PYBjat4iX141PqbXjSAuZ0/MtR8yWMGlDcCAWCxncsDQqa7zMMsv\nBaL1GOm7cFaOL1JiKcYrrZlk/Fc1WasSkv0Ie8Lj76qhhuscvmz8rZP+FvPe\nHfHAuYZZwIMbz5WBRCpYBXUUXm121G+aL34Zb/m9bdC4a71Y6wZWuSSQOp03\nAMpRNGGcavMhRUCcEALgJaI/KMs2KggMTB0RBc54siwmNwpomriZilitxlQc\nMkYnVZKtNZK4jaJf6jljwnknLzgBDytXCdVfq1wymNQ8VWO0cqcPflIb6QpQ\nM0rLkJs7YT6dkbalWBhoxkNGm9CMt8X4KzxR/04Bvnt38C+VFXlBhWhqiMOX\nOFdLdrWkIhBD88GGyUrG4GiT/mkADsPDTNIdv+YqYr8HrhuPku07ABeeVq10\nP7O/hEnzKNTlEcBlpSW8ERXVH3NzPFkkIadrO4vrOuG2Un7982thBGj0DpEi\n8iGxsEgF9e3Po8MHO1zxQMKANu4RgW2UEbRwyvzcXLFnT0Xx0Tl5OYJA81ls\nWf/Jc5c3MH5JXWyjANwjq6vj8W8/8UcsutjsgRENu6+XZ5pVmbV9GpdItIz/\nBgM5qOGvLPjvJCVUK1lHzeQ1MWEeAjIyJpX2jK27pRewSJQx0TtWi1JB9J5K\nOl6Q\r\n=NvRR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f609f25-1625153818777_1625153868087_0.180528128624299","host":"s3://npm-registry-packages"}},"1.1.1-canary-64bebd5-1625154280714":{"name":"@iadvize-oss/store","version":"1.1.1-canary-64bebd5-1625154280714","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-64bebd5-1625154280714","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b15d710aaf4c3f40743706d7f2628d657c63cc08","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-64bebd5-1625154280714.tgz","fileCount":7,"integrity":"sha512-vaaG3LWH5bPmHSMdS2+G8ejmLsdunqvVpP3v7td20Y+3huWWEfqX1i7qCNobSO8KEVKftAcrFWetoxmRhSqRcg==","signatures":[{"sig":"MEYCIQDcDVGvbRvYPAa+E/cYjPLa+p8qbWomVghKcz/qmm8l8AIhAMGBRaJm0+RBB1uceCB0p6CwmT73DESHWZt/+zunSjMN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3eMYCRA9TVsSAnZWagAAHaoP/iYyhrvuN8coQDcOvABp\nK5G8C3R1m41A6HRSdL7Ta2gqqQQty1kootCGyzORVL8soo2K7JPk47jTqKar\nJwPplhi0ltJeDXn/3XmYQNFK51fHP8iVvnVyfNunAd0WCoWok3/JIA8iIokV\n9peMgh2/Gai1B9cX4C2F5P7OqFqAKmJVxLQ6/SLgQ9auz7rlrglo7ByGJzrf\nmv4i/9Vq4gKpP7PMfPELgOeW88zaFI0qV5hUwCTfhBr15qygNskzyer4E0Pj\nXv6tu5lHEr7bgVSGWTI6SziIrbBUoRjbk4CrWCNjL4tO6eqputiahj3jwGS9\n7wualLhxBWnwc3PrJ8VN4J7Cdnji9an9ZjKBqbrhx5bg1cyBpeuFMxg0R6ee\nps50K5E+QaLW9lKj9qNrR+2B3gOC/drWboBn8D6dGRG7YJcPsnyfMcPTuKzA\n3eQ4ja13wWNT7qLrEbMV/9ix48y9fyyjoAdPp8Vpud6kGQcfxDIGoJ8yLbAG\nrZLMRQB8DS/DhuQE66LwMDydD6jv5EZ8aCoae0Gm9KG1FFH++fQ0Pu3SXlFP\nfbJ681Vffc3uAKEAeWT3g1qsBwrFaErZ+Bne/hJt0Uv6NoMW1mqKQDvtWtm1\nRPqXutnBlj7dzTVA5sd/Kp7okpLcY9zRyrFKZAvrNnNFBpGm2UJJeENv9rEx\nsFxh\r\n=D+19\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-64bebd5-1625154280714_1625154328329_0.008337698649118597","host":"s3://npm-registry-packages"}},"1.1.1-canary-1120031-1625450528281":{"name":"@iadvize-oss/store","version":"1.1.1-canary-1120031-1625450528281","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-1120031-1625450528281","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"50b6988a2aff673a02f7024011d3c5041b6e1031","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-1120031-1625450528281.tgz","fileCount":7,"integrity":"sha512-06bYL5IwJSJWbyUuSiBVxIy57FbMKjo2C4Hay6XC+Nc6exLY9wW9bSZQdlC876tkdv3hvk2LSEMJ9KOTE3JqUw==","signatures":[{"sig":"MEUCIGbX8LnzPbjmcV3udvPlSimMtrDrRP1qu+LHWG132jWPAiEA24/6mQdfmwyxS21GnxHdMzyUafi57Fq5bpPxQb1UJWE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4mhcCRA9TVsSAnZWagAAI6sP/2uR9Te2BqdwIHikKqM2\nWYjKe4118hmH55CWHac93ooy2FagxbTt/XeZdeqsPqp4gRoSecFSsnR3AC6t\nTN8wqzYUCWY9R8tplSEy/bkcn9d7LF3RUf7qzAZ2HpgRcqeCO/j1N8Nf4oOf\noVihdozO+o7Kgi/N4jmjkymCxObceiVTBWsq11YoSMwuSThJ5vS/3otJavFP\niOsWB+LnCXki/0xfrAlYUeXFIIg0RTq7YpcOLGxallNG/Yalp6CSCYwL/Wb1\npm0ZJleo+yQI+DankYkiMlzmw2nk8tQNrPgin4EZEXO1dyDKXAU0brVXSL0X\nbaXBWeRA3COEF4X2/vvRKKfQ6erk0o5uFZ+Q8l5m4Ge5CvMoakq+ieI/BHM1\nDQeOtC3LUky0iGCVOlIbDOejmt3GmUgE7t1cog/JM6V/0eIyQQmjzdULBLDs\no4wyFGyWfnu9WE5zlRGCo3r0nuS1Fr7L8kP1ywSr/od7FiI22NjfMIMUfLoQ\n8bWPnZIiYAuy+3UN6L2qEhMr2UUsZPEx3EoOFSxxpoRl6nWL6pq38KgAR3rx\nAQB+vK5XLmps1OfIXP6ISEZqd7ap0b12j1x/Sz10x1Gao+1QPPDgjHsHvSKa\nZVUcI7KeAr0nNpjEHNBSSpYHrLmD4ll9/jBNhJobm9V6gqTtXrOBLa8txm3Q\njcoM\r\n=HMBJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-1120031-1625450528281_1625450587881_0.8025687319994377","host":"s3://npm-registry-packages"}},"1.1.1-canary-714cae9-1625471947816":{"name":"@iadvize-oss/store","version":"1.1.1-canary-714cae9-1625471947816","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-714cae9-1625471947816","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"77e5dca5d3196edfb61e19d3c9a7c174352e560b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-714cae9-1625471947816.tgz","fileCount":7,"integrity":"sha512-s1v2aX8g/jmusguDNXSkQY9tvL9DbVHvCPttTb4r88VYNw/Iryz3HBMuKlzYb5I9El7jQKVDBfmu91HHxsu9zw==","signatures":[{"sig":"MEYCIQCsuD6PdX0024aQj+jTMQDlWiQx0BnSoDUqJz1FGoO/xgIhAOyR3GLtgmoExfCuUhduWb/5QlBHCjLSiknVca/ZR1uo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4rwKCRA9TVsSAnZWagAAAlcP/RmXYW0L/4k0K7g8xDfy\nCixZfB9Fn0EoAL/dFCc8Ilvpb/UkwSzP8WY6cQhwyizukDBOpBhMfjchs74c\nRhd1tyH/xvhPvIWvWpuFWdDLRH+ZMNdnWhe/Gfd4S2f9vq9mCI8QGLK4c3Qp\nI9mSvKepyEBzOeIsN9XniOXemw9EVdp2zQuS7K/DcrIo9QNOxV9Q9pQAhOLo\nS8SD7RC24jny8IYRHrxHuONNvqyGiXlufJsxAxMyAvnRCsJCrFDixXS+O/VV\nkzksd6LK1pg9vf3J4dFaZC3yvys2VFDqLs3I+0KM1ck+w1yq8NgIZkz5hm7A\ngUICO+wVwHHxTyJv63GPhnNHr7zWw3E1Hn+gwrdeUeVvL09oaVGhHHkIrSrM\n1NmyqoILmkdIgB0ZbqAQo4BAwC2oUYk78P91sN1UIaB6I6nuKvBmTIyJuZq9\nUZvot//agYkUS/zTu/AcaE3ukN/BazJtWYw222RGBI2sklmMbVwHFwmgFM/W\nT7r02+3ZaNTbuRAzm1kVGUTRYhn3Os/5wHciXBL9QZNYFq4AIbykT8nSzb8g\n4Dr4naSrSjcbngcEp2kywEIZlMoApl8WlYjlXBcJMutNrkCuc/3TYLB01na6\nUSv+hkwgaCjH73/rk1qZfwM3aGdQjcuNCTDiKlyJ7K3Rh81shGGuekLqh/Md\nxeg5\r\n=ScmK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-714cae9-1625471947816_1625472009994_0.09737760501305948","host":"s3://npm-registry-packages"}},"1.1.1-canary-9baaf07-1625472423356":{"name":"@iadvize-oss/store","version":"1.1.1-canary-9baaf07-1625472423356","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-9baaf07-1625472423356","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"97f7a9d1ad9f5d9c1591e892e91d704a567b5e04","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-9baaf07-1625472423356.tgz","fileCount":7,"integrity":"sha512-59mNjTJ13/OmQXL3D6bfo2DHKDkyLElfgdN/IR35M/ZwFnxMBJ95mClRgrHx+BkzO2ISzxAgGRP43hBR0dy5/Q==","signatures":[{"sig":"MEYCIQDGYOff6H1Y6K17NSZqUp9NdwRsiPbsj2gvxUtuZzf3YAIhAJBgVsmwp33krHVZf/z+DdOtToWQPYhKTG8UBxc+HxDl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4r3jCRA9TVsSAnZWagAA5O8QAKN/+jcxBA2JBYugYWAC\nQgFmfX0wpjo5kHYLI7GIgTU6gsH2EKvlMmN5QFUQFV80jUTU+HG1P17jVcby\n1R4Qyw3PL1vU+J2bnWQQ9n1EATFGNlps5i4YgLamA59iZnQloSZUfXv7i8F9\nhe0bJGWQx1MSidDkIU7VG8p00aKZdSfJesj4Ewiqxg0C58/0MPlntyFqKxUN\nPEBSAer5VoQzBQFrWwqcEtUomP2TH5CCfz8SJk5lbuco3Cdbai0ewx+zn3TO\nm2aRHwKvzuXQCGn7/soOsa22Ix9aLZTboEBOLKX/oabwD6Hkc45m5haZu1UG\nM9649p1f+uCXnGsLTm7OsX6QKsc5QcBA0o8lJAGb6/wsy6C+9oMRmzMSrjW2\nw9vStN8QktwHCn43UlYj5HEOViJYsyZP2cHMQ1sF2XOhpH14yV3mKN8ZJfA/\nu5rGAkYkAeTXrA5AZCpJe56eLbUnkYMeeim0SadlA9Y7iIgGI38TriAWkYIq\n0BFulHyox5Ca3g5HQSQXBBsDDpgo0h0yxFZ7CiXkmClBUnOSsiiefaymsek8\na164XugYyqYCN/oBlCAeOp/ObmG91nmAg4vdehyY2CEoClWwHhghtAt27j7n\nLGd1tVErmKSbR6KNMdH0JWNM12rLlGUex/KbySjnkixDIDAbLMZHlyLOID1c\nvn1n\r\n=VG/G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-9baaf07-1625472423356_1625472482961_0.19973920362151087","host":"s3://npm-registry-packages"}},"1.1.1-canary-57dab38-1625472807345":{"name":"@iadvize-oss/store","version":"1.1.1-canary-57dab38-1625472807345","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-57dab38-1625472807345","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7ab1cf7ce01ce2dcb786dd5cd519ac7542b84d0b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-57dab38-1625472807345.tgz","fileCount":7,"integrity":"sha512-jI4oE7nUVK88P7eU7mQjcZvAmm/UvA8vah+vLN1C9+BvHWIom8j7l/nCDlDAgVpAmCBPgJG6RyICXVHJAIQ6sQ==","signatures":[{"sig":"MEQCIGf2tqZx4HJep3PZ906gJ59/PSy8HVmJSEcFL8C/5b31AiBVRUrGKWf4PL/I79MwNSrNrcusI0EFRoK7a27BE9IYuw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4r9cCRA9TVsSAnZWagAA7AQP/jq2sdHHTF90fdSNgYwP\ntDX7iHFIVDHO+fPZwwt59bs1fm5+jf9ksFV4gCf2JO3ggFdA6xGypcllLs0e\nZyXzjLWPZvPC3lHoLoSa99/bgtZs3oWHu+zlM3EPH9+8MOk6VOzsJm2Q0EoP\n6QzKRlUu+ZX9PSsKadLqf5VkZn7rnyZymqtobXM1IbO9f93Es9nr9q5Hh4+b\nhMd3prSYvLU2fK1cTP4V2IMqeVCX0MIdu3Of8E87+VJB/82btY1Hk0AtNBn0\nvI5byqRjyV2FWEdSgEdwgBa/0FpHnozYASX+Nb8l9zKVxGWMlEfMi0jVysn0\n7hz77sYbfUTtLQygwBXno23+CGyMnNgmY7MUVLKfgxuSUWZxHuCmn0M7Oom+\nC4dBpcusxFCdWGORuuJA+65vi6wzYSnY5gbTKg1LNv8ZH/+EfDoOZZKxBm6+\nrCJ+VZhIGqeGQEZMk6NsND3igiBqSmLOpHdA8Z5o2AR2pqa3OdnN60syg8vS\nhxlRDul6jwxyR3vJ/bhEptrJn1i+x5+ReNHd7BLHxvCaXiqwyHH6qd883dAT\nrxn5N0uCuYbcTUymPqmAU1phrJYBHR80EdQVSZxKNXNrwcuinDk2835Pf2VT\n6CVoLPxkq2JBol7eOiiIVf5oE5dvU/v6pbu4+82ZMM32W0idlz1Zm0BaHDJF\nPrFh\r\n=XmON\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-57dab38-1625472807345_1625472860327_0.6277913614190742","host":"s3://npm-registry-packages"}},"1.1.1-canary-dc8fb96-1625623309137":{"name":"@iadvize-oss/store","version":"1.1.1-canary-dc8fb96-1625623309137","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-dc8fb96-1625623309137","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3d2b7344fa3354d9bdfe461c735233bf3e64f242","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-dc8fb96-1625623309137.tgz","fileCount":7,"integrity":"sha512-FmH8r91XWzd7iDx13E6BaOopXD+WNY9+Boa/3ic3wGdkxqIgoLZpxesFlN5aMd3xFH081XftT3pCkLaTIpirlQ==","signatures":[{"sig":"MEUCICGGsZ/+tzw76QDxzHL++NCoeVkz6KEgq39fpKk4okTVAiEAyC7wnLLLw+rwknu5djSlriFZJc7EnySu9LrWAKHOhno=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5Qs9CRA9TVsSAnZWagAAOl8QAJyQTjjCxMb2uout4Y2d\nSjgGTXzaEDi/2MsADIkZqUioDCNe68XOTFVVyBnGCNt8jwbzD/PGmqNRcvBw\nSroJOJIii3t7/WgnYLyN/X8j+RMok5DqLpzgTt0s4HCe2ZEgyHGxwPPah0pj\nn4e5MWJL8BiMrqaHWlVXE2lVzqJqchSFxEv3V2rm53WxgxFD3+9ik9tjo7al\nZyJ1uT4K/yn8L3rVbop7yAKZQvnPDJgYjjycoBjYkpwgJVaXMG+I2Hy14V66\n0XX90/5q6ieK80s/itoZUpMXtXfiYgc6NN09v0xdb34zRq2f+a4n75N5b465\nzYRh/CaqYhIXaxF8qM1dKum4jkQX3/ncu2Qnc1rxp2rn3py6ezGXNxjwm1Z+\nVcxeRzksvJxRvb2MRWp9O0yqw8f/IKdc0fBQOpyJAUGqzoFo/feoxeusohfI\nW2+OPOwpW7xxF56k6z3ym/RFHkFLkUaSFVcum0QKq36lRzxZ2mfsJobyDJtC\nDv4XfCfalaSzItEYgie73zBKAyiTQMkSva0m9vPw72yj4kHIFirJNbma9Q3o\nrGE6W5f7dkbYfRRi/BPctIM9XSd4zo7z09OA2a22EX0c6jiKZIbqzfkT3Jn1\nfR9rQ/QrqHXrqDvmySzQ1xEtJuo6CZH7rehvcRCx44MeYtUVzDlBgNlwL6C3\nQA1q\r\n=ST6C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-dc8fb96-1625623309137_1625623356916_0.34292019731219336","host":"s3://npm-registry-packages"}},"1.1.1-canary-e77fddd-1625709744467":{"name":"@iadvize-oss/store","version":"1.1.1-canary-e77fddd-1625709744467","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-e77fddd-1625709744467","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7d9ffe71bcf030104019745ab54d271b8dffd147","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-e77fddd-1625709744467.tgz","fileCount":7,"integrity":"sha512-TELr6XON1aeuvYUDnQ33tLkAA1hjUeR+w4tAr2A1sVJ87Rl9/cEIkXo2rXH+VCLRanMVDSX7mnckjcdyUuPY1w==","signatures":[{"sig":"MEUCIQCf22Ik6z8RHf8JZ2AdZ9pic43d0t6hYLJvylbQ24UZmgIgVRRPHl703rYAbFFe98+1z0AE7BG/+AdH/SMRfjlRdgI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5lzjCRA9TVsSAnZWagAAp3sP/ica/Sn7AIKzTiVrkJOJ\naEbFgA0B2edOLI+PAIBH/1PJyCXugtX2D9Q+0X4qvCueXg1d7vlf3UsKPjfW\n9FJ8Kl0gbjLwqmT61VpCdesAR1QJx8lX6Fg7QiI702kuUt5L8TO7a07cwCTC\n17sx0pDbMeXNI8otpGK5jpOteCEu5zyTZi2sk1v+VRU0d3uo+U7cSXdvsro1\npd2BG6p48So74dFVGI3YA19V2qEZaO63K7vJ2OTjYOe5gXQ6GDnlbRegUrCF\nWztBwoIjcIkn2H4n9OPOgrt4b3jgF9Y3C3drKar+r39pbsQyA0ZMMMi6/9xz\nar0NRYznDQDaWAHkvBuT2NIKrGHYb6Lpp+Y79qQCgskpNDT+Mbd8VX1gvHuB\nkRoM8s4kHlJe4Tx8KzHGwL9P2wqt3AMJhaN0Uq4U7mi9v2i6EGPR+9P+LLuX\nbbAilV4lfFkHQZH+Js8BbUZMx0IxWpyIFB7OnbnZ/fVqMX9kBlusH9Zjif+s\n1tgTrNHyRGBheqteLHkWEjggOmYbKYb/cJzauFQoZXU3by49ZtxliKN/PZ1S\n5+ePNUU/vsa6NVrWF3RMjgEkCjetoRBBL+jnc9VMO15Um4PHZdAdy2UFuhaZ\n780DN8Up8PILQsESy7Rp9y6qu5fjn/IeChwZFb4U22yj7zj2Qwc6VWrxl82V\nNWmP\r\n=Rd60\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-e77fddd-1625709744467_1625709794687_0.4432602291949066","host":"s3://npm-registry-packages"}},"1.1.1-canary-ba8a7bc-1625735914322":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ba8a7bc-1625735914322","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ba8a7bc-1625735914322","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f5a30745736fecbb48e0d8f53b75e7da34930419","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ba8a7bc-1625735914322.tgz","fileCount":7,"integrity":"sha512-3YH8762pz2WZqp/0pGIh1mJMHu+9Jm/J9aJcc4M3wAAoP8CIBwgRW8qJPE9Yb8oiVBy6L31Fr2NkF7rfDRUmmA==","signatures":[{"sig":"MEUCIQCcxjzPdTWyOkGMLSlGzZYjy94yfHKEneTLILK9PD6fSQIgdwLpm444oToKpt9AbphB7Q8uNM4Sq/rTs8orYI0cjMM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5sMZCRA9TVsSAnZWagAAc3IQAJ4EeqjbsU2M3mjTltGR\nkRjPlVrZRg2j+y1uBfpFuyjk/3VuvrSKd0/5CMsyh6hE/GY5O3lWwAAfTwet\nLDI+9t7VrQzJxff4noBBe/aDZFDVCMw0FLnTz7rZyf29Bv+sBY+NPHVsCkTc\nKorexpWIArU2B/iQemF/1IF7Jb82wZMMUi6/yZqa+AVcnn3hTxev3ssEoD0C\nqlCZyLVxGiCY7oQgFwCs8xHhSXHP+unxFy93bi2UcpOc+SlEbywV/4u43pBW\n0IEvhb8T8CBTA0e4h4puFy/nhjwU06upCsFShgNiyeyVzk2HSKiF7pWprvh1\nsm0oPKph3atB3PY3GLqPdz3adMKbw4WHUoc/BQXCJgmQBB580LgaWWBlyiFQ\nvlMcRdcFmxIqedk42rLS0YXjTho3B9N1KB2SqJDtuYfTqLJnhcoC0YfSYFry\nxEufT2yjj+xFYTXDgm6JGYU3RyuDfkufJd3gIGli9RVEO3yeHzwzty8MbW7p\nk9QP5VbHgAw291J80KbDHr9I2EzOXN/6eJ5QrwaKK+AGG/s4M8X2TtCvLR+U\nJ3XHjtXBbFqWa8uPW4Juvo2xxbPVez9Oh/sBC+wVBTc/puH6WH/xJ3JYuOtI\nICtZiHNxvGLlg/4m58YJmxxdlnjStl7afh3pkCz17JhRsUzFXwQjmXf626Zn\nlgJt\r\n=CREG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ba8a7bc-1625735914322_1625735961253_0.9868833253808607","host":"s3://npm-registry-packages"}},"1.1.1-canary-fe80256-1625736427078":{"name":"@iadvize-oss/store","version":"1.1.1-canary-fe80256-1625736427078","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-fe80256-1625736427078","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3b9903ece3f83da86da9e523ddacde0da9099edb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-fe80256-1625736427078.tgz","fileCount":7,"integrity":"sha512-MDXuKBpkEWjDhpXYRNu5GDwdkGQ9Ttaim5z9UDYe1zjg6Fb7wZg9mFeTH720R8o1BoQI5tMvLpLGCMf3p+k3Tg==","signatures":[{"sig":"MEUCIHCK/9VzV77/B9ElQizAQV32nBQf5frBQGwGrpZi0wVeAiEAkdykeCIHq4QSBomdFD5Aao0qvpuGFDBbC8huBuR+n+Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg5sUTCRA9TVsSAnZWagAAcLkQAIXNkvJr/jcX0f6IkcCp\nQOV++TvNvUmDHlGwtKX4gS/+2s0Y2Wj8S/y5hJfFXyy7uyzc+1APdKahy/M6\nGhqjuiMgQz9Bw00la1VccFlMivhzu6lJdIZikoFziUBq74A1YyxZAJid5MRf\nqNF7FArwhX+6k+pGFfAZ0bCY3MksNXt02PqVOjXfkMpya3WnKttbX+c9MTvE\nuAVs2BJl93w2fqZ2wgAgoE8lAdSzKthKU5eNNIN8hrQbVtpFHLJ7zvbcA6EB\nw9CWPsi+UrGZlp90BHXWgtSu/a4bY/MpiQ5GhkRSWCqPshkwBJL+NXllYySu\nSEV/8kqltitFh8jkXBns+JuAsz6Usfe9XeifzRMH5ulsyZq2hg/Hqbds6eiX\n39XA/J9HlNFDO7y9UQeXfDgsN+dQK8v6EdrPyf2H6fVPFZXKa1N5lYu8Ln9y\nBNPxVr/2Y+xSscU1dd4VhkiiRq/HVfLaBMoXQtC6QNnXJq0jwp38j1FN8GzL\nDssjuMWSIm8RAuWAaWYzULVpfgbU22fOa4/ZHXqmsxiS8pvxkZqrGk21fnXP\n77Slsg1UCSyjJQZg7AdpJ01IZFYGD0kMoqotXxxXBi+VOtVZaj/PsIuig9pu\ncaal3EVe71cNX9M4VV2USlbHNIc6POntrMD44AL4wQbWSNudFpjr54wyR/zF\nQiX4\r\n=wBKF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-fe80256-1625736427078_1625736467364_0.542715256170643","host":"s3://npm-registry-packages"}},"1.1.1-canary-c1c3e4a-1626055334250":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c1c3e4a-1626055334250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c1c3e4a-1626055334250","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5753af56c6c44dcabde0bfd3bc16b1075d965c55","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c1c3e4a-1626055334250.tgz","fileCount":7,"integrity":"sha512-Q7g2onlDPiFcRzUymDN1fY+SM2zbBh5/CE9EaPzXJaw+P+FewY/zeXuiugJLDCDSxn1gHQwT/41ARHMjhWx+BQ==","signatures":[{"sig":"MEUCIBbgWnpnPlVED/Owgoqy3V3Ywu57WUSf7iOyT76sioX0AiEA3TvD1ZGrdjnwc8K9LTqYuyQsy/2/gImRp4ER9kHEirg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg66MGCRA9TVsSAnZWagAAGNoP+QBoUVutO3jUu0bQHfJB\ngezgb3N4ixFyzEFuDUulylmzvnkpMuvDKXdK32t6UEoEI+EzG2XWuN65vKRT\nzyYe0oM8pNfFfdLNnkTWBXUahTn1s7drdBxTJr2uEFUQHEtCZLMXIg7+BtvW\n+dGWM+qlSux6F4a69yZbUkutYr3tI6HMv4NjoH4QPFhKRkH6tClvpALxI0T/\nC05Qj7qH9Gt2LjP/XnL4W4RBeLLQtY73PHnpjRgkqEV5UZ2FMvR8COJh60I3\niiP1vg/0T72TsOzL2duCQjZq4DMLZBXuZ8Uy6Zoys2HtgIkIHSxDadgqMePC\nh943oQMQN92+cbLAh2jiabML935RyShlJP0dj49VxxBTNTTn5bqbKBukFlZv\nL4Cagi5DnZtfhOeCfr0gMWmetMqYFU8fT7+lrol9D04S8tYzrg+gyCPksrpC\n6BbNoNEqFKi/nXq0/mY3xvD2slVdNvjnx6bLyGj1gYkHA8B9ucWCqZMn6Hzb\nmI0f0d1Did69vqSNi2TkSaz1MVi01vt/XZ9fL9YA0LK9vBYrmJ/PYeiMi0B+\ncb80wJ6WhQlBVAF7p7pvduT9L4zwKU7FXQl4TxmKWMUJihu3NK4tDBOAQokP\nAX6NZk+wve9yiKTbF6IzOwktDGrHG0nU7ar586kWp9v4z8jzNDCrp5LWg5aQ\nWKd1\r\n=FtWL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c1c3e4a-1626055334250_1626055429693_0.16918743790288482","host":"s3://npm-registry-packages"}},"1.1.1-canary-c1c3e4a-1626055334303":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c1c3e4a-1626055334303","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c1c3e4a-1626055334303","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"93691c60cc356f1bfc2b97998d373d4f33e49edb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c1c3e4a-1626055334303.tgz","fileCount":7,"integrity":"sha512-qoqv8zTtfrdEKYuBxMl6kuBJDybwbvIlrLiLYlgsT+eNvKUQ5ZrCCBLGPBqpl/kZQKMWuhiyBnYxe8uzKq636g==","signatures":[{"sig":"MEYCIQDcySLL/rmPxmeqMZeT+VDEb3/A3sA0EERKeESp4kWnVQIhAMmwYJuseZMYXwx936oVlGI6CBa67PE0T+tNIZsBreg4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg66MNCRA9TVsSAnZWagAA8DsQAIEIPDKGuvIW6LEHodRx\n+HyWkNycrsGFZXLXxfV2D9DUFj15gtZhe1UiJ0kornZAcq9bh0ppKmw90lvM\nrY2CH6MH5iKnUvEtU+7XZKjghAEWfYi0vC3W7FNSl06Q7punhXz3aUX0yvil\nISlLlCS0A+P3bYFo963CwAZISpvX+g5VyxCN6d1lAZmxH65VzndkDpla+wY3\n3Gu5jQLOJgepY6NwEb42fHgupvJlI65mF5ERxVqLr84DDZrOYoVSTZ3uVTiU\nQ9nNAGbRwWHxGGYmsRJZXygEDybgmJqrwFQsk8wieezQy2aHdy5Y7KvZkHTo\nmT+O3J3+p5WC0eeDK0Bx+tSps6mVCG8mPB130oOZtqHN1cLQ0e3m5It52a/V\nFW93LKBvcgjy2Ds2CKfalyUqtKdz3dvcnp494SV/zTxd8PTiSTHsK5xh5BuS\nqNw0Zr1Mp0EZwf2GACGdwM1Hgm1VpKtu+gciULW9jEjvwbPlte4G46uku7Fq\nBEN/glC9VZE4t6diyQrlYOughKyLAI8ZhxNXO1vQt4TpsqGRuA4I/l7qXK2g\n9rLTPP1+KjFZycU2/iVY5583Nh3rJEwGjnXDOXCgQysNgjAxF31q2KuJY2L6\nT9zAF17DdZCHKa36cBKiPXuEuZDjLwOs3/TRbMmj1JmvEMR+EEu/Cmc07dpq\nnalr\r\n=FfgE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c1c3e4a-1626055334303_1626055436374_0.6645707852345477","host":"s3://npm-registry-packages"}},"1.1.1-canary-81a1526-1626082525383":{"name":"@iadvize-oss/store","version":"1.1.1-canary-81a1526-1626082525383","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-81a1526-1626082525383","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1207d41c22203b67063da91c06c459aa9377202a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-81a1526-1626082525383.tgz","fileCount":7,"integrity":"sha512-Mjq8G96aEtuF7TEpyG6DKEzcdMGgmtUu1ajNGjUHj4ocAjzAXp9jwovRYvrOW+p1JUrl8E9h2lMeMmEbAPxUNw==","signatures":[{"sig":"MEQCIBPe8TcNIjxtH+EeRWzxYvdBFzOrblgd5x2q86B3B59WAiBvCqOYXF1n2UpCtkTiU02m0Bs8wRB2TI7oHO3UWz4lnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg7A0PCRA9TVsSAnZWagAAob4P/1uan6Ff6h/hQp5zl/ov\nyBNmBIoMZSKDbo7PXV+59hEnYozCVKZ07eS6oMYb60CoEUlzPC90m2FGvMwg\n4xs+qD3YrOTYCv6rkkp2DS10f5FuZuuJCWS9yhhYv9timIuuGjOFlPqC6B8X\nOzRiacfkoNZqvA7XvAR7NlfLcE+1BsM8nqETQygtxQAAXoxK2G3h6Ws4nu7b\nnV87DDuXBgqaULaswlP7g3Za8SKkYbsO2GifAkvqXUSKF3rDy89ezRWOLkxS\nnRqE0idKOB/LIfkUQxystHednzpsVIT7xT8aK1+7gMLqdDxvbpn75sRPJkiL\npveZt+rOIUVl3pvxpLgr1ytuLxVtbVlGAJ7c4drE7qpS0dDGl5Yy9o5YC1B9\nm4qnIVgZmChd1rgsPilrGTFRJkn1vG8F8vmAQ+GL/PYmOrK0RS8jInUWN0Y1\nzsKKqTBva5aK+xvpFGUTvaVaELnO3Ay+QqabDfMd6ApD5c4y54V3WdavWr8C\np+SBdnXDXU3zdGNklZO9lK5ry8BZVW/gIFgEU8IpbSwe1wXdA3mLOCbYLu2u\nn4F+CAkSnfMjxgEdWK+eBfJuxgZk/VfjMywy2+w8/JXqGGBvUuI6WiHuCgGb\nPIRz4i1flcQhroQhdJmxhNpQZ2VKdtZufXMVprVXigHmQ7MLIlvesB8EOxQi\n1y28\r\n=BJE2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-81a1526-1626082525383_1626082574825_0.8466799682274087","host":"s3://npm-registry-packages"}},"1.1.1-canary-4bf046d-1626082692818":{"name":"@iadvize-oss/store","version":"1.1.1-canary-4bf046d-1626082692818","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-4bf046d-1626082692818","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"23841f2dae97758fb495c23ada4b6ed022d1ab7a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-4bf046d-1626082692818.tgz","fileCount":7,"integrity":"sha512-1aVC91vs9RwddveqRKN3eToXV2LZnljCQZR+rD4vfuGd0DOv2mTUOHy0DCxF8sAq8w/Tr9m+ZAHEbGioM+gENg==","signatures":[{"sig":"MEUCIEydIOSFfSic0mjL8xX+QespAZafH9v0EbQHQqXwdlr3AiEAhUOsIIstrbbLiklA+3TBEoMK4zsWcIPFJdaP0gjKuYY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg7A3CCRA9TVsSAnZWagAACPIP/0Z1W6ShDFNLqBFuwkOo\n/VG86voMqJobDsiOyU6Eguik+Vp0Atzl8n1J/6Iv7J1t2bHpypYXUBjWQ6a1\nchU4u4+c5UnvqO8xCzkFm+8si8WgOmuKHy0BpxgetP4vmNRzfuti0NnMltt1\niGbMHK8WxFyOgzP5H0ZepvWwPDwrY1m3o+RTG6r9ewILU5Ai60WWXo6kTUJk\nXchcBDW+EH6KwDZad83CTGv+gcZ1j1v5+ZoGjNzHmTZumqYRB99hiLTQtv3g\nbKuhOw1cbKmcsVRXECue8cn1amMDMrAIuMhdn6nagpKNr1ynFtjRbTPjYOci\njI1Iy+RGZbe8iWT/aOFgQEhSXLRvLoBN97qEEYBLZASvYVr8i+ag71xnFdHg\ny/oUHGSpSLJqECNFoHrFMYk2ibYB86SCIZ4u+YoW7n6Kqu0jCz9BE82c/PGR\n2pg15HFdoHiNVB6gVqXCWkBZ5CtYipHvqI5V1PoDI0cFgLmKFN4jPaCO8lWK\nDHefe3zRi8sOZ9yzZad716e/z0VOrNM26dD2kk+4vjnknLBZ7Z0ZqFd9te2t\nCUDdV5Tx5Pxfj1j+RpcJjmaKQzbkl4f0k2kYdkwfJLbOcakm6vqc4mBsmH2x\ni63zfcT1QcZMQFXCcDwi7oUNBy9S59WngfOtysFb0qSusPJ9NBwPhYjKOTJn\nP7YQ\r\n=5SVb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-4bf046d-1626082692818_1626082753609_0.41998365695287077","host":"s3://npm-registry-packages"}},"1.1.1-canary-915464f-1626400960994":{"name":"@iadvize-oss/store","version":"1.1.1-canary-915464f-1626400960994","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-915464f-1626400960994","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"440bdc887ad89d73b0e5bbd316f43b5466640bf7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-915464f-1626400960994.tgz","fileCount":7,"integrity":"sha512-TSxhmzuhwzr0r2a0UQBPYrLllmMFT13g726+5vfUMHAp93HFSMQxxBVi/xv1rj2RpSpsSfJOk0PCycIWRYk/6Q==","signatures":[{"sig":"MEQCIGZ+YWGHaq2LaS/FGbBPG81h7BTXjR4WSIZ2ixDugtRRAiAdXi0Uyei4F/mgk42bneIBbHw8P/v3bZtOlqd9Ifr6HQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8OkDCRA9TVsSAnZWagAAJ5YP/iETNI0KC9Jg4Wpf8XQD\nByGRxyli3iPWF8O6vEUY94nZZWUNA5f81O0yhBf596GIHq6s1xsSM/9DuiG+\nlTi3C+QQVbclAegFqbjR3/9JpWzCSAlyUcDxkFTXFN8Cpak1vLURFqD3fHBp\nL++r41XlG+DV6ThB+5MNq9gQmpV9zplWY+qSJxr7F2lsgBgeY9A2qcW6eGtl\nUO7zfkxZOjB29Yrclat1qd64otUbxXh+qAeoZeHdbEySmDzabamg6qtlwa0T\nmDHiYedfGgRvnG2BNrOfbk2G499vs8DLa7a6FN7FxXDv7Lt7Lfeepx3F/Jkm\nkcwY6TRzeZsN85Hyd+ZX232QeSeNbyQWcYwMsAc/XJ1/xjm7G7PxSOJRsH/d\nnRLYzn5QdMq4v/sNCjoZxDWh4cGOCKl85dZB4q/7vJK50z0PrKtNmcoGubh4\npOFJJ/oooA+FstgN2+1gboU4IgMnLu9USgAP8QiatEP5OpA/ULmqAK5XqFsX\n2hO8DIPoLxAvRNeCIfHVroXjxcSA6Foyq6vvJtZJBXCp+pd7tdxCeT/HXV6I\nlQmRl/Wu5S7LzuAca84bJZ69+k9xdNxmbGZpLlyPVlVTzd1pmjUIL12HOltP\nal65bIvYOtXBJ5ILU6MPoqpZGwfyoQ2CFZa5gHa/BpL1PIu4DNeui+oVz2kH\nwLVh\r\n=ENkG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-915464f-1626400960994_1626401027785_0.7536068370735589","host":"s3://npm-registry-packages"}},"1.1.1-canary-cacbfe4-1626424806706":{"name":"@iadvize-oss/store","version":"1.1.1-canary-cacbfe4-1626424806706","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-cacbfe4-1626424806706","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"15852b2f05aaa73aaaf439f5373a7e25b6c2cfbe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-cacbfe4-1626424806706.tgz","fileCount":7,"integrity":"sha512-GId3HgtwFOS0nNlhN+ODRDd3A2KgsUoJ7ZD2SLUJmzHSCM8FFzmns5UwPY6/XrODa9PYM6VJkGL9fLmbTdqYhQ==","signatures":[{"sig":"MEYCIQDJTIFeNGEkOJf2FGUURWChu9+TZrpcVLMZ4b1iHxOH9gIhAM3O1vWojS/MeprJdEbEdXUvv98PIM74W0EHbAsPwEce","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8UYdCRA9TVsSAnZWagAAnT4P/05UFrRUZTma4n81vFtG\nQUpHkZU/Ptd7r4ObvNhWzy2DE/nl2e+GT8Z7XzTlCGdmWLOwr27FZ34TBRWa\nYspA7ykSimhGDO+xnO4etrh9nTiAzx/qxzxmj4d6Mn7kcyXdmD7DZA8K1qtc\nuUw+XNuy49xP8oloOgnbDe86h4igntWfkYQ9+xvp1j64hRBecqlhquwfb+WZ\nDygDtbum/cmxiDmYJc29NWZIRbkcTK8jCiEl/ivu2dK6IUxBsSAAwABKZFvr\nPpk6AhoKn1JUFPf+r7NZzHsLwStNJMKB5hkP0PF0UuPdV9iP7Xd6sNit3gzF\ndvurnuT+XHlAAWJ4l+Q0TzGMSGUvn50g+f83WWk1pAPDBxvs2fNlC3w+EKR6\nIstRDnjhZrKY5WrBxXRrn9Pvm350BJ/9oJKCPFqFQayf+BTwgk/XcomWG7l7\n5cq+BPxUH2VAiDYTNuHUk9WtSQJdRckECK7ZjzBh8xPXVuZP+vUed8SI1iQJ\nlOtCBmPqgvTd+IofR44bZEdJGpdEmGtai7wWR+xVkSUS6YLDdjnogL8vN6FP\nJcBmLFQI3gPg1jGHrfnvNQ/aJn1fsr6THYXR7R4MIlqa+LKYWIYclj4jM9YK\nLG0ZBOOii/tPO5qUzj8iv/cCUkjfukR30s+1IQ+DnN9pCefkQrBod/3X6Qsc\nJoFv\r\n=lqGL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-cacbfe4-1626424806706_1626424861818_0.17931492312038233","host":"s3://npm-registry-packages"}},"1.1.1-canary-ab4e76d-1626435190296":{"name":"@iadvize-oss/store","version":"1.1.1-canary-ab4e76d-1626435190296","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-ab4e76d-1626435190296","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a0c5c0260169cb59dbe20fe492e4e8154c61e193","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-ab4e76d-1626435190296.tgz","fileCount":7,"integrity":"sha512-uaX64AlmbXvWU/MmkTEA71ODpqbZZng0WYq0fq55D/mQIiSIJB+3gGYVDMKrMlJte7ezfnphoLClk69NePxVqA==","signatures":[{"sig":"MEQCIDqbr72cux0cOx4KC3Flt2N3+DyDYqNhu9t5bPblURhqAiBQP+3WXysgP+fjmCLsRd+8KgUo+FkPzCfuPjtuWTZokA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8W6nCRA9TVsSAnZWagAAw5gP/19zxKWRoLcTynFBqKbw\n5gzikAYfMZYkoIBrD1HgWhIkdSviqkujCYn3I8/0xKiKGrNnSd1Jj9MZ2d1q\nDb99EQU1jnGsVFMfpIRxQARxL+GP1DgupEAbcJpB/26iaX/OLd0275EBtOyy\nrcRJ/KbM95aVNKa5KHKzLJINEEbP9050zOcpdfBRBSxMIV5SfASSeswQG6vA\n0gIVcaY5btFYh8QQoFNdNkWcQprlaNMsMqKtVOOAaM1g+IG5p1lbeke/4aKf\n7zjV4IxIplYhrg7Md4wwRWN3W90EWGvzXAFYgbyyuMa/hfBFVdOyeyFsK2gl\nHa+skrsDdlJ3rfCUwFRZSwYx3PgW1Ix7gGqrdbdA8dJAV2O3JHtlNJtfIXDX\nZzhRqNpK/tOHYPhSsLKRiR+MXW51c47BqNfBwuZ5eePYLbCFuuunRJyoC63q\nmvyYsWHSE8Sa1A+h8d7fGegOQNKxy/DCcxNCwOx5NJEO3Sdslxz7d9hoxp82\n+CktVXbxMaDLWXl+00dkDFKAsh2WtObmVvkM6w7yZYvVIdlcxsc9F5yD7WZu\n6PwVv/y2aCUmfUrMvHdQ0b5FFko6GT5nOoV2zxxi6+ANn6g3s0XpL1rLaVxK\nvce0gynJYYiORJq4lsjfyR95sLE/XY52G93UO9IRXf8vZDo1tszpPf/+ickD\nIutU\r\n=SNko\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-ab4e76d-1626435190296_1626435239051_0.9668323586082852","host":"s3://npm-registry-packages"}},"1.1.1-canary-0868351-1626435344673":{"name":"@iadvize-oss/store","version":"1.1.1-canary-0868351-1626435344673","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-0868351-1626435344673","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"32c2b5254d6219369fae436c3e809536ba5792fc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-0868351-1626435344673.tgz","fileCount":7,"integrity":"sha512-Kiqn02IWqhUUUzN5s3/hAlzBs5cNNeLZpSmvgJ3KdPOArnuM4LXRoXhGSoLpjcdPA2qIXeURbV4mwUAq5zOAHg==","signatures":[{"sig":"MEUCIQCIpdobRhU2T+7Dti4UmaW2TPy4TTPGgBuygluCpr430gIgL0D1CZVXdzaN0QZ5brqcngB+84TU2Hvg18z/xN6/9i4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8W9lCRA9TVsSAnZWagAARYUP/1CpRcynqYTnoTQuVbZO\nlWeknEptN/hfvLo4vm5xPdPiBYbi8ZvB6zP6H3rQv8DIGX9vMzU47uoSvrOm\nsi406eY0nPjDqv7xQ/Zrzbp/2SA/dIkZyJUIU6PXBfNm5pKs6zOl/tSwqEYS\n2u8DGwsvq1kqVgGR/HzMXjvuAbCMgmrtSplCEk28jq9P3gJPLcXKBpPjLKKE\nN+QL0P1DZPGtd/rg6Kr4WVSwJcCC8DD9b/5Sf2g/w6eUH6uhc8oVHF9a7oFP\nnTT3Bsmdt6yprZSIcjyB7El3X3EqrQUllcq6TnxwIm0aL2OXZCI//6eXUhak\n/0V4sE1FxkAEDWVUQ5qltd9Gtcs3Baf3kay44Zs10xQPcopH6+Ojs4b1+PlV\nAEq6C98u7EEWJ3C3wxgiDeGBoKU8BsMBFj3BcV9ICN5EkRDLvrDGqkMoTkub\nifMV/3BhWxLNJ8xQOJaf3MnvyWbXgFVb3pxrrj6DqZlK+xaRHvVkO+BWQV5H\n4W1vb/G/NVvSwUIBVG7jBFM1uS+1kXXPjjlv5I9hJzbyl3krXbTmjl/A1NJa\nG19gS10CuUnX5J+idbhVooKJ44VAoUW2Nz8OA39V9IVtlgVPTt6y1xepOiXW\nrk+P4BEdis51QXsepo0mFiynrbnMSF6z/99iNLe6Aa3xY/PhdYlCX3vfwldq\n1Z4q\r\n=aDub\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-0868351-1626435344673_1626435428959_0.44709886993498626","host":"s3://npm-registry-packages"}},"1.1.1-canary-6977596-1626660563558":{"name":"@iadvize-oss/store","version":"1.1.1-canary-6977596-1626660563558","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-6977596-1626660563558","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e8c48698fd7675df598b3d79664b31a095bd25d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-6977596-1626660563558.tgz","fileCount":7,"integrity":"sha512-N23Lv2ruIileRe2joKFNhjcXKHDDEG5QypqpFg9Ymw9zN/a7dmtM8d+B9AIv/J3FJwF84ETPDuir3z0dpvMXAw==","signatures":[{"sig":"MEYCIQCNQMdQO/frvkyWO2HxN1Jb8NtsgjoW7WH3yq/1BL6WhQIhANNex9EXYqpWX5ZGiJ3Dht+AGPbLTg++JT82CzYNso6P","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9N8CCRA9TVsSAnZWagAA8noP/iNP9ww3IhsDOCSGEx1D\nR/eYSeqkVrSdWTsaJMjuA9SlaCrq6Ims8wzudHa90l0JuRFuZreUwdA/lfYj\nKw3F6gEj+zFlyfX4ATTyR+/ck9tzx0SeJFHuG0QBDcYWAURNovaTcXpfyE/7\nkffQWPSEHhruuxQaTmFsbB8cmiWzR6J1Icx7Yv5SIIrFwOHb6SXenAdyrPTQ\n8+VoGp56NVdphGFy6617N7fEFirwMY6OQn1jhzTvHJM7DgeSG75kTeVJvkrE\nmWsPZuvvGlf8bAe42KeCHo3qgQmFxD09cZK0P0YLIyBwZ8oc24e5VvdB/PY+\ndEZ2J1CM/WeUiD3CyOQffYW0slxbM4uCNW+KZHhAgpPWzijQGPKzR8kUNSjd\nuHbcgeeiedbqLcOXZT/xJt6OU4Pne/5JDJ8OHB0NJsihXvNRGfwOGGpdAdBG\nnDj4OfGIzVlQRjiDZ0ELtOrelsygvteXrfBE0pCxOlF0Uf/sOf7xUUyHdbWl\nExzGFnjcJoNU/zujkKoIf9PHHjx+IaeJFpt6pvIdeSxyCX8wxyQiFvhS5NE5\n0RNQ3XyD/LBLjZ016j0wmOKrr6W4Wxn5BHp6sUxEx2xM0mJ3yDedqxjXvRn0\n6D3bcSHjvo++rQHsQbOETHoV9aDK+gszLZCFd9boDhKHf1xmkBe/gcE5BiS8\nEUef\r\n=CAnl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-6977596-1626660563558_1626660610238_0.1407606406460955","host":"s3://npm-registry-packages"}},"1.1.1-canary-6977596-1626660566315":{"name":"@iadvize-oss/store","version":"1.1.1-canary-6977596-1626660566315","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-6977596-1626660566315","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e28fe13f59c0de8fc0d1bbfa844cad03b05c2310","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-6977596-1626660566315.tgz","fileCount":7,"integrity":"sha512-Kgjt3BTRCs402Bp3vsAP0PEheRIBFZwEBhQZ/vGDwkFRJMKgC2wM32+TWYuR4F+Ot3wnzPQDCDazU5ozpnGyjA==","signatures":[{"sig":"MEYCIQCWw+mw0HlvKR4Femh/wwv8mrDGxmVgbpZklcBm/GU52QIhAMNApVUcyg5fC58Qo+Ovc2FiiESUbZwI7rGj8khWj9GJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9N8JCRA9TVsSAnZWagAA37MP/0/JAjQrWm/zFg8wNMSZ\nF6oz+EhmfshnhriO2y6gNF1bZYhaNyI5E7TyrYdzoqihYIzgCQJiaz5Chy2o\nuTkMN33J5+vSk7jQFcedG2mOK4UBE2r8S8yslYfdd4RYkFC2j1gH949itgK/\nq+/F5X4Y1jbvgDiZTdfXDPYxq/re9qCz59y5AZzb9tSMjlnDMQAEaqfBf2+a\nSOXBdmXrkFxtHBAWqio1o9NuKDHY33njY54IL5X35cMy5bXm6yyf1rD3gTyN\nBBGAR9k+KM4l+qZDtbFoZXj/sIRGGjw78PS8ZSkTqu4F/sKWIr/hI7W3L9dW\nBLdBSNcnew0gI5qgQRVEgsm8artf3ORYGfNEfjhXjeoYMITP1sib4UUocWLU\nAlce88yhJ14Kr6UViAejfC1F8xvmVT3kqwa79NTnOreYCqvehsABf23B/I4i\nqCtwExiL/VNkHRPN35MHREYpvTrU1+wVcNr1iuHvLnzLBzGmZzXQpHn3FhKm\nzMeYN4s/oVIf+GCny91HRZv6gw8pF5W/7JwWoP1i6UBX8AC/4VgZTyNLQiO2\nGHexFMbFWIcy5+pKiBtcoqOH5PXqjQBZ0rqlWjZgZiUEXcy10kmym//8XZ+p\nV4BOOczje+yvDhCIEtYWDqMFPm8+jew9Q3HfEQecIcevwNyBeCyaRfXW3FJK\n3htg\r\n=7PN9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-6977596-1626660566315_1626660617412_0.8323494410692269","host":"s3://npm-registry-packages"}},"1.1.1-canary-8c247e4-1626919318505":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8c247e4-1626919318505","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8c247e4-1626919318505","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1bd2d2f66f83278c8f64d99cc2af6720ad2186dc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8c247e4-1626919318505.tgz","fileCount":7,"integrity":"sha512-7Ss9pzIzj4VS32KPoNEPnCqFW5x0etU/x/k9vAwyPMS+8TcNIQMq4dVk9t60wCwQppxaXJ4nqkmvZOH3pEuT5A==","signatures":[{"sig":"MEUCIQCHgaC0h260Um0Znnhxtzweu/SCVx2bX2CCdj41oMKHlgIgbRv114xwzLwqR12+KoAc03yLGjxQgcXu4E3O2vY3jLU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+NHPCRA9TVsSAnZWagAA6NgP/1XSkpYI0hEMwkMO15La\nQBH/eFsO2f2toA4p5MonoNJH/XqZ8Y0Eve/wlkvYPu770avbGih/lrUVp4iB\nta1FPP0RoqU0kPhGwqu5RpqcUY/KZyJtsxqy55ud+F2PsO3jVCYq+gqFOJ7V\n4IQafwBlLOr+jdj9oyy9Ybj6Fczz2U5h8oRtDVyXj91LDBskCzrfkWcETQqQ\np8J1jfyeGcZAJtKqSXVgf/pj3cSlHWC6aXHSorgrEqVwVag0JGmS/diAbGMi\nLVdtpsjKq417Bu42dacJQ3rxfH7bcwL8Bsb0jXpvGcrmQpgx/uq6QOzw1C6f\nolvLf0p5Ggek7un8bP3dSXiQZkgj2sfRGhYpKlviqIqhFDw1nJCmL0WtO6eE\nC6f93rD4/SwCw1lXiTOfbKjWHxukqRLpTy22PaO5wwbKjybz4n2PJqswki5M\nsQYE8jHRGQWPdnOTnPqB4eB7TpU0Gtu6P/G0+gSaoVAKjSJL5PXv19lj83Bo\nbb/a/BIOB6oPwsPWRZIhh6a2hC5l0uSxBQm8j1jL28cqU59wRbKWaHq9Hh5y\np2L3sV1NAmLTlrnAzjvqhkh1CvwfNQBGeKtf+Qj7uQ+FsDxSdmCQgB8JZLra\nsZyknfme4cxUJzcfU38AEYcbnatFGcBc4JBE93MzbChxuV1QrhzFm+o9XY43\nOg0a\r\n=nPI8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8c247e4-1626919318505_1626919375012_0.3412429195268407","host":"s3://npm-registry-packages"}},"1.1.1-canary-8c247e4-1626919337079":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8c247e4-1626919337079","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8c247e4-1626919337079","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8f5729a01d6e01fa592b34d5b4b0129eb42216e9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8c247e4-1626919337079.tgz","fileCount":7,"integrity":"sha512-6i7cBU8TC0x4TRIUK/ISIevKG9ZGqa00SYIMO23xWNvZbEC5ptPIkQIxnUGju6UlouopzYL+L5ucVgTVlTZcoQ==","signatures":[{"sig":"MEYCIQCKYR8ajbOMlaa99QdvBCox3RNYx5Og0ymckYwwJIw63QIhAOg9AE4kymZcbUzBD9FovBFnzSTseCNKNg8GKuY+1WJF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+NHfCRA9TVsSAnZWagAAUHgP/1IIaMiszzTedlWJStTV\n/DBQw1m71K/iTHurHcyVkY/kvPpqFhrjk/1b2uXf+J+qZp9QdvjvZU8dADla\nbzZbkzvureWnzDbBI8+aKrkTK/cnEF+EE6FV6X1R8Xb9E5M670AaogSvx8Iw\nGXlluhg/D75Ro3KfbTTlL8WMb/tRClQvQtITod5jLiCBxzyUcedfFb+aZKlX\nRZ3S5u8YONfJQXkbejkxn/086rJPTYjaCVKm2qdxPBoI6pRS9XAgKiKq6ghk\ne0lNYDLiJ4HQSctcAfuKOkFCSkhEy2beER0Ny7nla8M3xqKRa+lSvV67k8sR\nCXhNgeexeoSGq/jr5wE5kMOVjUCIbcbP5b0KC9TABo81fdpDYbKktnkxXyFo\nn80040kUZIUeH6eUxVe12TnkgxfSAqKujNdUbZPvAsSwAQC5wrBdUBsH/kAV\nhBadBBVBNqI++uRJ9neFaHq/K2JTV/aT5wnLI5//Fi9Y6WHbYKzxIhLmFHGm\nazoJppZu2q4f8oD5hknFRiE2stxRZ3oWGPhekEiSNZH9BCtitv6TncVJfAs0\n5AptnMVhMwtnzc448qaCzxKIjvGoYjNMd2LtWYL2rAgVRdUst5K+o60/QHJN\n/jL53VFRV5OnsdcojDEp1vZGZqaNN93O1YWJaJLcg//Vk1kuKBY4iUrM1D0Y\nHZZ+\r\n=HxBO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8c247e4-1626919337079_1626919391227_0.05258615952107015","host":"s3://npm-registry-packages"}},"1.1.1-canary-8c247e4-1626919343331":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8c247e4-1626919343331","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8c247e4-1626919343331","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9250486fde9ffe8d601df565d21405d381955722","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8c247e4-1626919343331.tgz","fileCount":7,"integrity":"sha512-nYpJcoJb5iiS0agglaoG189F2YIlA+qYv23VCHs0Gp2L2HfYj3HdGu73/KrgrU90r6k9Mfh4SzAjb5Zk+ePdQA==","signatures":[{"sig":"MEQCIFZNL+Qk81ZH66f3WXdsN7DtZcaps5vVAlEIif73ZJhmAiBc2cM69B61WgAHK2BQvRrJlka4i7ma/dw4qUlEmAk+5w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+NHmCRA9TVsSAnZWagAAYnYP/irqC6ybQkmFjm6vVKCZ\noq/XxvfoBLKCVeu9xc6kN44Oz5ZIQ+24glycgCyOb/Mq/wjVtkejBjMZcVNv\nB6jhL45m0Z1iEs+mLxvMGgGzrb4Ol8SAvGwdp8nyiv4qhBAdjAGZM+GKfn9T\n5rvUfS9yMEusFk6E7jhXpz7jatvR6AMQ0fVlRVMOyg+z8Vq3vwk1CYz7VdO0\niZJQsH1JYFlzS/tBCFAmByE/wihZSsPOn6mwWXFzoIIjNFcTl1StDq2HQrIX\n5vPp0YwszqVvVzcw6CwlO40o7QpqQFRoW/IYiYWHNnfhZW8FqWIuWjo5QrQl\nNvth2/dVCzS6NYHsvU0Kq7we0vijUNEA78xx8xTPKiiyMi0Z8K8ETNj/+Fyn\nv9eMQAsKQWfzdON9/Wno93IOvqGuINMtV4NO86dGX5ma7HEVP55DVov99rCc\nx2nc290PhF6LcTttcnSCUrNFp5ff1pJ60qrdcILxBnAJ3eGTkczr2981Ne6C\nFiPXkU8azI1qo2WLK+7g/Omeb+v4djBlRtTF3DKQKZdkZlNo1UjYx+FJTuah\nT6BrBh75XzgIoAhGYZdf4fy978rpH5bOpmnit+2snIB1l3a3BClFnd5nhStJ\nRFh6I6rv5RaElAIAd+wDr1hF1R3vXoWcyx2B8TiLocTOasNIWzKKw20jxT0l\nn4+p\r\n=ODl7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8c247e4-1626919343331_1626919398468_0.01657635171661398","host":"s3://npm-registry-packages"}},"1.1.1-canary-8c247e4-1626919318122":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8c247e4-1626919318122","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8c247e4-1626919318122","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e12b2e8a1807eb3eb3461af69ec9b62db5172bc5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8c247e4-1626919318122.tgz","fileCount":7,"integrity":"sha512-tuyGwOm6WKsBUbsih7aJvnzpm/06pTc3kuUEKaFtMZy4jtv7kJYpjwijM5b+eOxUPMari3R0vwlNv326Xi+pPg==","signatures":[{"sig":"MEYCIQCDvQ+hiL8YEIfGQptUWtaC3Sx/DjMS8K5bRs19Ank8iAIhAOvD4UYu6oULrLrJTpkshOalsCdR/yFHYSNC1JRxyfZp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+NIBCRA9TVsSAnZWagAALx8P/jYSo1xHGm6LyUGiOMaQ\nTgRNyi+Nzm/xnWwTRjXpNee7FBWfh+6Oc9Owihno8TbNQVhrM01O9Gj+OgFD\nuRjf8Re9ZY+8VcH1fCImTU+kZ++7Wq0enQfWevDdQ375W83zlMPNJL3VOXnE\nKJzB3sAdn1OuDqDpPyiUyXegIyS/ghmtR8hWr0mSJzWExwP2Av1nTz/qMF3z\n5d4s6RrTelZDonuqbDnpV4Y8yM+M0pWt/SbPT8QiOdT+Xjwh2WB7fpyBdIW3\nLkLa+0TQ4NsK835hIQYK03NwWOjBcbV8n+JmKPhXTv5pOtJks4z35dj0Df3A\nTkAM10sAeAoFtxVY5qVceGdIvsnkNAfVdM9L0ChuMRiQiuUylrKPYhEW4xjS\nNS7xSxQN4I0nmJx2yahTGWWUd6QMix5059fVVY63T+d+f1mhW+5kjx5fHrLc\nxkQXl/KTXtXtC4CuuD9RT24uWY8xb4XSIHzeKXGcvZSqzMJOwU1zVWkJbmsW\n/11j3iU/iG3hMQ5vrZFDKMByF29o7ofTzu606SBh0ClB1eq8b4C5ENyxxdA6\nULHu4nMtHfljJAFpsb+tlChruOhRogwHW0SYV3+Qs9sQN/nUuIbevoqF7HDw\nFr7PuOQaPvwGQ6m9+q8Jc2rtt5gJXdifXZau6Pta6EZeHCr5Cbv6lclnZvND\n8Cu6\r\n=0ckS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8c247e4-1626919318122_1626919425230_0.7421196243110995","host":"s3://npm-registry-packages"}},"1.1.1-canary-f46f94b-1626941035998":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f46f94b-1626941035998","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f46f94b-1626941035998","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"37972f1d094a60f5a06b561bb440d19b2df29818","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f46f94b-1626941035998.tgz","fileCount":7,"integrity":"sha512-mZW3ylNhlpcBu1kT1jxv5Got21DABRJqln+Inox7ctjRqnIV1Sb6i0siDfhj28JD6NOcOcGsq8iOw+FugFMhVA==","signatures":[{"sig":"MEUCIA5nK1R9cnB/Ddzfi09x0W6TRlt4W0Hp66JHSpIEVZW7AiEAknvm+J4EW8A+uUrV4yQ1RlO7dOQn8x++aAhmgOkzke4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+SaeCRA9TVsSAnZWagAA2dYQAJCSTOfKOOL6FljL+VJh\nOZu258xlvuREg4U0lz+GK0TPp+smnv1auK0Op634YuccHdT27l+WotWr2wwj\ntuO7UWFNNS/BUjR1BCQnEGiCKpawN4hQn67kwPAl286jk3wolmzt3r9Y8SgU\nNr8rVc00oIZ++dtpT3oknQk5BaohrvdVQimWvArhN4nqPQs11fUY9Ktbqjf6\n5SU++r0XPSOh8w5V95pUcadwTU6stASUPFLy6i2lSXEjbgCjthm80RYvqz18\ncT+cNMrVvNWmdoPDMjsk72zhRLigdir8/ebBtzmMbMwIGGZmL2CcSIIjBAwG\ne//JUWNnX40mBPXc9+et9R+rYvmpbQ64YoRFPn+OQQC1uiqOpGy706J5Boha\nMcz2hhqpJCxqKeodwXEiOKZ3QitPGaCcVpu0+3T9Lbm0UR/kKSOGMnQ4deII\nGTOY6UjTXCPclwePgr/tDpZHiKwVjMECMCTwsWYpYI09EYl1gsoXHFfGGdVT\nsilwLFhU9dBUtSM2u+bzynXn6qYn+Rg6sBV/NM0D/y9tMjMD8sx0NJPk90k3\ngJWIGbHkPbnb/pJ4vzak9v0apjbO1qTCnm778kGDuRMzlaXmk/DtXK8FmbP8\nO9rj0gBx00QTVJDHE0FeNpk6cr/yYkez08dgbjsubqlAY7QqCpnhE+k9kMI5\nfHkm\r\n=v+x/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f46f94b-1626941035998_1626941086416_0.8009617649877945","host":"s3://npm-registry-packages"}},"1.1.1-canary-9a9224c-1626941899477":{"name":"@iadvize-oss/store","version":"1.1.1-canary-9a9224c-1626941899477","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-9a9224c-1626941899477","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4a1a07df25b8307f418923a4c121f0b143cb5e03","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-9a9224c-1626941899477.tgz","fileCount":7,"integrity":"sha512-7GBJz0C1SDELF0kbb9z2Vi7nQxkHB9OL30+5YXlvNiTRDeZJsv+04ueB68OD1uandpMfMg1Knl5+hNQwyUZECA==","signatures":[{"sig":"MEQCIFOSV8Uov1JO2+O7jM7lX9ufQDk6PJ8KYDlME96FzKAxAiAbiCOeSG7KXPUz65d3DYVNcjpvAOff8COqJfre/u2MKg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+Sn8CRA9TVsSAnZWagAAmQAP/3ljIFSFfcXjdTD1n4Qg\nmokzOkYsgInC0eGfqITXRUT+TFxAUIxh88YEIKFpXOQRxGGp21fyjN1zdqi7\nmk7+R9l9AOI8Y4/ysjtKPTGAG5PZpqLAY7QoWVtl/nRFL+DkmVB3aMexCxWw\nhR+4D09Q+tkdwoZfoQLR0agokDK+eWt2NKLpuoXuhW95/FN+4iMS6rlFRDks\nTQ1nJ97Z8ntZ/4kBss4J8dJn6TDqQymbl+VjUzvvhyzA5LJ8f0Vwu0yDg3kE\np6lDXXfSWi3UlBkLQRVq5Z0Zm32ogdo0svq7Cthub8OJABFpzeMwYIIQPtP/\ngU1sdKuglehcS1OTUd6WiqX17M/aPHQQdy4jaK7cUANxHKPwPOw3fCf0J2RR\nj4YE40lAVy6jqlacE0ow753ydtWP/k+sXGFrx/XNVCa7tXvDsTyrjYKkeI8N\n1t/RE/2B3y5F2MkRJ4zS88lMuNt8pmT65vPfGTYrYKnkTn6SDYqEgf5ekLa6\nEp9vio4FhPLGrPEZI6fVp/cR0JV8FuLOPhIo791xdpntOk6xokjiKJoB747f\nuRaE0tyrZvQQUuEHGBkBXK/6epT93MSLGlyg8YXGN1sSnM+4TFiClillfrHi\n0Gr4q4tZSnJGLalsPUxpYmcOIrQO1Qb9D+bHHabPfzRqy663mkU/AfHKEvv4\nGA7z\r\n=f8eX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-9a9224c-1626941899477_1626941948042_0.19767869779491787","host":"s3://npm-registry-packages"}},"1.1.1-canary-7142b3e-1626942114395":{"name":"@iadvize-oss/store","version":"1.1.1-canary-7142b3e-1626942114395","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-7142b3e-1626942114395","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d47cd63c643e777d2ab5792a1dee210f0199658a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-7142b3e-1626942114395.tgz","fileCount":7,"integrity":"sha512-MbpfCOJ0FrSe+tYbiq8ZaWWKdzJfmfjbNGlz1n3wqpSHPqXHDOPgObv7RfAAitqBj5Np6IInl5q31sXu9yndWQ==","signatures":[{"sig":"MEUCIEu97FzZpSlEs+I8D4vixRqOpjJmBBYMu4XGgX+DFxeTAiEAsM/HXKgBoglgWDN+HwbCzszNCS0ebs+PEiclvav142Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+SrgCRA9TVsSAnZWagAAfkgP/0cjJ6aeXROdUvsPHnQd\nSjriEGL1pPOx7UywdTvf7+U2UUEdMX97T+o1Y+VSrzG1sAPamRzxvo6DVoKt\nWh/UwUO6LlWx6pgBr3qLb/G/qx5MFqhgFoZp1rbCYvEgARYQ47MszxUUaxMA\n8HvyHm0X1UBvKXJE1+0GxBIgMNlfCPoeqBw2yQTVDNH/J9EjX1O91URa9/ZU\nMsHAHyciJknZiFE3CZyKwYa7lP6As1i4JAd7OuwdnUHvFh1/uCjddzOSZ52H\njQaTCUNKr5oyJX6umAGWMdSPikKbHf4h9Hw97rg2YDkr5h39g00mGoQgSiyT\nnXx4GK2x60F6T4TyDJvpLJo5caRJQnIz+lchxnB2uPv4sFPgziqrh298ABO+\nv4IOKgo7L35+ZZbp/Tf6vsUDmxLZrWHRRbftauIub8T+TjTN7lI0w1eLZiwj\nOdIDnSqyOIcZWvbFPqhP6pZsoadGMizJqWGya5Q5cM/i6X3VOPFbY82AqU5l\nQ+XyxbiVPM6GvFvBAoRe4Nbr/Lll5y70IXRA42Emi5Pd7nq5+mzevgdG/0/G\nrhRygBvKlGHfYYN4MIW1g/dm8X/FrXDy/mgyFoZnWEPe3R7K6R7Bx9qeLf54\nEdrD1hgQr8m+WqXrcQnQJ12XYOMqCt9oHAOVjovn9ESp2BfrVY7rM5/tBGOP\nYd35\r\n=hB7f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-7142b3e-1626942114395_1626942175955_0.33759045914419095","host":"s3://npm-registry-packages"}},"1.1.1-canary-39a7cc7-1627264911976":{"name":"@iadvize-oss/store","version":"1.1.1-canary-39a7cc7-1627264911976","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-39a7cc7-1627264911976","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6a454c416ae91b36fc9df4b7daa2246266befdd6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-39a7cc7-1627264911976.tgz","fileCount":7,"integrity":"sha512-3CpE9jABDXD5TNS1ZFNJW56SDdhLx3LsK5MHqtUchrJGvcmTga6mPAHqDVhaoQm1qNnEB7W4Kb5J1bOcQKGFVQ==","signatures":[{"sig":"MEUCIQC08N3BkxldmVCVSQ3QHHa5Ao7OM9qyU2RFMoEEGxX86wIgGzVhNesNXQ82kmOGyXhUMcxx5jkgzilyQ5iH7m37wio=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/hfNCRA9TVsSAnZWagAAuO4P+wUedC2wiO7XjFry7dRY\nrKcR1jXUTuYNkdqV3bMfxJtm9GW4x+ksTQyn2+dsCDNP2IF+8KTgZfZjpzU+\nrZl4DUShVhXQmamVlELU6xcsRZieAFbCdjo07YIj+f4pT+8s77tXyU5de8Ti\ns5ePijCa8LVvpJc5sbARkHOL1T20Xc7qR4qiqs83KVjHCrKdKuuf8RE/v3Ly\nrBw7DEriuvNYDGR9YTg/ZE5V9BRBprVByCAjs/HsW8/FfJcPLuXE7JK1FyXE\nMnSi72DCU4d/Bx5LW1sKHKKpbVSZZz3vJXI2Ox1u/vD6byCEm7h1D4CL6W62\nI+qwVbO2kzAdriqB+OgVJFoKjC51EF1Mgb42WwcIdO5yMVNZqrdZAZkWL0eF\nemjTcakaraPrzKwh1Ei876IhA7/olmbrCjyjpLbec+p6YAgf3WH+3qNPNoEm\nl/DUG7GPtWwdKPsOdeSoKwUQnJtfENQDx6JnMk7+tMd4ZmQB27bUfWpJYavo\naZXGbP2wxC/QQ5U2k1jOCx1Li9jZNzqN43PewVo4Bk5C82fgT8qIXtP/Gg30\npA+0wCVJnJeAY3rQtN+NUJ4OII1YaY016IpNAFkvuL8Zsv9KTYKctZ7OnNXw\nXn2F9HJ9DDe39Pw6H8YcjPGb7wWt77oKDDS/x0kQQYEQKoDnqoy91FVlJ93B\nSZi3\r\n=+OEN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-39a7cc7-1627264911976_1627264973584_0.2694050681221909","host":"s3://npm-registry-packages"}},"1.1.1-canary-c54119f-1627287692208":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c54119f-1627287692208","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c54119f-1627287692208","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3e33aaae8d36ce7d9b380679ffd2a98ed87eca8d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c54119f-1627287692208.tgz","fileCount":7,"integrity":"sha512-jqbAxjFaLBGcz24bJ3eQFu2Srv6MKsw9xJLRlwPMWk0BBjcCj31Nere+wge+rBoIBdRnnzW2Fv9GQMg3Uo/E1g==","signatures":[{"sig":"MEUCIQDmlHXUiLvJsKs8LK7g3sUMf1s9M/LpNbuMihmffGChAQIgOSx6Ln+Fc6DfYIzvpoioATFca4vmMnwQORFbmy6INlQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/nDJCRA9TVsSAnZWagAAgAoP/111PKtq1PCAt7WdTr6k\nOhlSiv7VcJ+f3qgDVd/Hi52rqh+aceswfDDkXOwrGTNw/sro2oF7hSioZxVY\n5WdmS3s6FKtFByGyREP9KiXYDo8gHD6qSLy+9Dm9dmoO5rFO2okl4VoTrt6L\nYQPws5Qenu7ORMf4PK4ouW3iPG81R8nnYZEe0GP2/AQqmLS2VY9/sG/LMikK\nq0Rxd4k8YHAwVVIgqeMUuIOs2eG84AyZVS3QfoPVIJ6M+Mj8i9bSk/s1pwkd\nqQlr35NRsOUvPs67rMJtJI4xw3bjmllAKVxV9quwp9fGG65cyRJD+H7+z5BL\nF46nAO1Pjsk+F13C5XgRmDFlGM6ZpXYet55VfvuvXLVDC341a4/1TkYHAY8r\nQt1BQZJL/sixnLnK4AAJhDTApMPxRl/zLXgivRtrpNCt/fRzOxpjf6JlMg1w\nq1CPtRmFcjA5Z2f+Y6m02oDb7J4+FVs7YSEmSlmJyWBLj9CFpHldlup4rsun\nbwSZ5kEo+YsXqcXD1h8D6f5B0aL2lFVqw3pbBC9/w3GGhANSgI1dv0USu9Tt\nHjvwmeA/oNDDSNiprEBxWGmxWO8uD3oanuEz7XL4FQ4gEO+1Ub6zaa2kGZHm\nvGfiEKufdLGkzc542zfIOMifbTGcjZZbTx0s1vyyl+eJlRWQGldupFYXR2AC\n5gSe\r\n=+5R2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c54119f-1627287692208_1627287752996_0.8900430803735682","host":"s3://npm-registry-packages"}},"1.1.1-canary-c54119f-1627287723865":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c54119f-1627287723865","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c54119f-1627287723865","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9264faa4c5577b0a5f8a30b22f800d6e6d221d78","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c54119f-1627287723865.tgz","fileCount":7,"integrity":"sha512-QRZNPiXuTPHMG/39WlYLuvXqai1VsOE/Tyo1JMZH0R0SKZTBHTJk2VKXXObKHWop565Y2qYhn1goz8M+1thuEA==","signatures":[{"sig":"MEUCIG1WRzxlCEELARk8evmxDwXjgjfbJjBeeX6HWglrWzOyAiEAsqhN5InNnLucOzRinN6ixW2fm9Kg/FvEE5u/akb4JjY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/nDdCRA9TVsSAnZWagAAN8oP/A3jfIpYmeZ421hHXxxq\nY5Swn2zSm7tunmRAZrxYo83uwfNUDDIEavrey3pkYdWE526KxD/GvrZ49Acx\n2/E7n0AlSVRZl6U07d00rpPnKdEvgkU8cPqB9KDRa4CJnW4a0GsWAUaJGTPT\n/aQ9Wlng9wb5M7dlKuOriT3CC9oExwYEanQXd9pPzjgsOsnJ6tIObxPkBD4X\nOz90afbMVEUshUhzkVamMD5/TQepDU3lLqK8kC4k1qezXz6F8n13CwqrvCDZ\nsFbk8iWyRtTzc6ktQa9aNz6VLbvDyCSgOBhVbJjXNNrhD7Ct5Omkv04DJ5il\nqwEiiRZiRToD0vPjHptsUCpH365LIPVvgWc4BCBY4yGrmRYTazXtuycP6mBs\nh7nPozf8wio47j8U76VJhRM19KrglHLhga2CTX4OEdM7gBT0R2A2Rz5KMs2R\nhSxRRL+R4RfCK0r4xoaTmfobjwvub0KvUI/0smdME1cdBXm6Wn13WXkaPgul\nrEEz5tstPgFbZh3V2b+i4zUzMZaNMYOcWkDYjwOvMdsssEA10BgIJNUCGbwq\nd80ks0iXpqHm+eeZNX+AVP+fdTYAvonM8/veLCPwiS2p7NaDwbPfKWeRKN3Q\nVbHrQQcTsQuv25A3x0v8B5B4ye3V5vCFTfM+gI3/ylu7BDeE2l60sddQNwTl\nXts9\r\n=zRzH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c54119f-1627287723865_1627287773186_0.48943608822904183","host":"s3://npm-registry-packages"}},"1.1.1-canary-c1f0c3c-1627292766135":{"name":"@iadvize-oss/store","version":"1.1.1-canary-c1f0c3c-1627292766135","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-c1f0c3c-1627292766135","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4fbd244022a22dd18437f35ab803d759f7fa37a5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-c1f0c3c-1627292766135.tgz","fileCount":7,"integrity":"sha512-qDFT841OZ85QrpGfMSflLY1ATvFhHgVxW4OjUrTd/YYC/3hv/dcuj/I0NdJg3yLzWC0Ong0HGK3Rjq0NJVB55w==","signatures":[{"sig":"MEQCIF0t9s86oSWwddkMXxvDvv5cPM/ib+6z6UJqqFk9oGC4AiAcQCIiYSpkVcZEPtRwHZT2HLdBbOsE8hxcrC/4gJO9UA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/oTUCRA9TVsSAnZWagAA9JkP/RyB5xTEb1ysCfGsrslr\nUmzc6KJiRHeF9ggAz0xal4QbEh2uuP8SzqtQkcYYKPvtg3gKA2PUpMLkzXUA\noBUFwe84MggyjorFP5nIEie9cfGYOzjXfrU1lAVh4wSD8JiUbUcy5EJ6uw1C\nBYoJWIb5oMqaw133VhQQMuT+yrzZBPVzidP0BNrr6Awy+bqznS/NSgxTxDT6\nT68aNjtDzH8KR82MVJL2UtBhm8quaCE7U1WcWprThrORtpsZiQBEhfgk0KXX\nhI8zAaCDNOmw+eHUylTXIfYrYpK3FTvkE9sdvAfqQozkMFJoVDybibvd255V\nVB7+Qlnf1dcQGio/X1V/9StET38j3YC8wBa9uweq2ahGpBStGo9k9Gq2+6zB\nUBzBhjOz5lMlko/VGE9Lqk427R8VsLF+7ctrdc9vIVoc7qN+eE88Zk8llFnY\nTCyWVRNrY+lKePp60yMDBdLa5hBLPU75ptLKjyG1C7KkbHiYVC2A2W77jyJ6\n1SXrzVp/3s7EmW3eQyAnvBo3aPHBSiYRrOk9rC5Eyr5CR1C6OmQasWguAEM+\n6KzAk3ilOBkZrZyG8FqSDCB/g/N0lJcn7a9X7NWJ1l2K+/QKUipbJdLOLRfv\nn9NgXrMQ11bcTH8B/+JqcIByRQc3uXFgztYT6LPdfqz57Gi9LtkWVAKW3DfC\nq66M\r\n=d0DF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-c1f0c3c-1627292766135_1627292884556_0.49545739900694485","host":"s3://npm-registry-packages"}},"1.1.1-canary-38417c7-1627351337514":{"name":"@iadvize-oss/store","version":"1.1.1-canary-38417c7-1627351337514","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-38417c7-1627351337514","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6d26cfa054ac3e254de9126641dae4a6dee0221e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-38417c7-1627351337514.tgz","fileCount":7,"integrity":"sha512-PyaCSwadChxIGH3bI1GLL6+epy6nCeY+BFlRW007lmrJImZ2L10t8vlrna8u8iR2Q9Tog2bndBDOdG11F5zlEQ==","signatures":[{"sig":"MEYCIQDQBOIsHzv3hqlT14eNDM7IF+qSriqWVkEOcib4u82xTQIhAKb4OT5bJTF2kPQ9aTApeFrzfd45WEJUhCnmwzUs8dHJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/2lYCRA9TVsSAnZWagAAgDsP/Rn8PC6PlTuVcFoY0skV\n1Ao7R4X/+vwkgED0+vgDg/uooZDAxNY5Qy9A5Jhh3dYAZV1yChq+q1ygfkse\nYGxQB3GotpQpaW8Ow6h28Xot3EpmyUEeirQRuE84xxWfkMpx6DEz9CzpcGxH\n7HQx1N3gjxj20AYFTm3wWCd1upI+52aYE1qcTstxqhoXrfpKJINl/B5XgciN\n3INAKWOZSYtaoKy4OH5VIhrQpbakYASruBzYHYrtGedcNR+3DSxa37BVWjV6\nLNi8OOY7w3LVB6SxsgRKD4Reon1Vx51JXIa/j4At0amtEtFJJckdIzihkQCn\noBw5zJ9NZcJOcQiYYLO9qruDG08fOApzpmtgzryocBto2y+LXcpTfJk27cT+\nxXTqco1BaXysqCoxrkBFBaTL8q7IKz7xmgp3ObCPEfVEm2WnN+dL1pBfproD\nwNTI5uLKX6PyxuilKMl2Hs8ooIOF1dbaGaYqqs7caJQa4rB/l9IhBeq9eII/\nBAtou9sqIP/ZeRSZa76mEvdVbZXemHuK0j99PWemwZnXf1udjSUK40YbOfnb\nTt56MsKzfMyamw7xclD5Ui/6fOiRUR3UXe4w3Wir3E+2PeE1Uh3TqB+ASn2i\nBkIZ7/MvCOENQASInJnPSCyTAxMRo0VfwzBxJThWBVKJwk3zKgsKoVL1GHsZ\nmJWB\r\n=A/P3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-38417c7-1627351337514_1627351384544_0.5696937210651716","host":"s3://npm-registry-packages"}},"1.1.1-canary-38417c7-1627351342201":{"name":"@iadvize-oss/store","version":"1.1.1-canary-38417c7-1627351342201","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-38417c7-1627351342201","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e0a045292212d6f53b8c4128cf4ffe78c06d22d8","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-38417c7-1627351342201.tgz","fileCount":7,"integrity":"sha512-p+6wC1MqENIH9910XkdSIAlYXq0p3eoM9+4y45kL3+/hd/I2rTCyTyyB2+iY4rP2Ng9xv6D57epVuzJbnl7gyg==","signatures":[{"sig":"MEUCIGAVnM70up8dIJyB3AIOr+G3brnpY1c/714XjuL7wGtrAiEAxPnkJ9SLP6Tb3s/PK3YxilVOHJ8u9QFA0M4E4FEDAOA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/2leCRA9TVsSAnZWagAAQ8gP/RB4c6GBctxdGlECwArS\nJUUQTVxqpvCb40cJFhzt+gATjNj85yky+ZudjTNL5jTxGq49UG+PndkqBLYS\n8mZJQKECl4lfS3pE/yIsdhbqEo//3IGxesJIXRuenAROrWxLialcEdw8Gbvl\n/0GjArNaccIZilGiWkxc3gUJmSwUvi9MkWCRgq7a3HTPaNbZtnz0O1Ms/JJu\n091phZQizoQf2Tb+1DwXpEaeHqpLu2fpv02i1nXR+Jt551izAO1xDFFgq2Uq\nWRgDnb5hNVTG7vX7/JV2d0UZbbXtNFeWhkPspOJLsrOLFt/qCeOE67jVFRdg\nNhitou2+m6+iNXCzwAevBsY8NY2RcfPL8YY2z0Hf/bYvdHXwxX7Tnpd+SOgo\nBxCc2q57AfQFG1tYPxXskUN8F9OTgZQIqOnGdAO1keNiLow6WyohpfrcDzay\nXsORubqurTzcAMhau9apNlOSHGoGQjJLjAwxAWIQFKNLNWOVXnr3aYbks9gh\nSi40G8j2T30pMFCkM4jwcqMwxuKW8YEh005OFfTXKAjZymKASjbYyH9ygBk4\nDeoJgwUVEnt7umZyN0uu9hy3Rqob1vgLvxjbs5uXpQCpusqgDdjVDpCFBzUp\nLr3zk9kB+geIKmiWBzZPPVV2BYiJ1rzs8QGPVXMyZFJ6V1ws3KiHU0pdtcSH\noyAR\r\n=6UYA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-38417c7-1627351342201_1627351390066_0.3837034652987721","host":"s3://npm-registry-packages"}},"1.1.1-canary-479d536-1627371654622":{"name":"@iadvize-oss/store","version":"1.1.1-canary-479d536-1627371654622","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-479d536-1627371654622","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"453951334e3c12c963dfa81a7beb08fb91980a48","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-479d536-1627371654622.tgz","fileCount":7,"integrity":"sha512-EHI69V2UZ26lXhQfNpSgstLrpPvkqSmGln4co1Mh9+wwR4J9Bg55QcuIWoFxci2HMSpJckG1IooAKmpd6falBg==","signatures":[{"sig":"MEYCIQCPQlelG573vB3Tp82FurX29ujLUCGSVp6x71YLtHTi7AIhALXSKDVmyCT0DYazl+gtWTarZe4/Eq4Pqc8FAOuMSbis","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/7i0CRA9TVsSAnZWagAAOt0P/3EGw1i+m9w5kbz0gGjU\nWPoVmqt8Q/5vYxLVxuf06Z7LplNtR8KifkNhUAHG6V3CROjXUR1bVrPSkMcH\n8YgC03FD4FZZ12mZn4K4eY3KtJGe8Mz5mIInRf4tHMhRPE+gZhAt/UEznaKw\ndJIxAVCsG3BGj4PdO9GgAiP5eQi8BLUEwVJPimXPlbKbCGR8Do8KCYPwrRGi\npDpZIaXe4Qx5CobyF13jBkkp1q2a6lsXXcgPsu59f+pks0Z9gwLuSSFmZrqd\nfa43rGpglg7tzFpM8KxiEadZPjzXptRSbgDGomPqvgeoQCFC4kOKbkOgVvu7\nHKLuqmNHKKHfUx5EWfUX0xbUCAdYbpeLWX2zWRp7cZqMw0Q3gZ/mrSm83LUG\nyK8WRPsIFTwFvPOxbiNXs6BHwXw6v3OCX5az/g2uRx6VmTi+VsBkkiwHpbbv\nZTxCHaD3Ou9XqHq00cMuf06CF0wfsLg+sqvgBaAlPiZn3r4DgLXtJkuLyfG7\nx8ILyc+vkgh7N0jVPLqE1iz8BaH8voIQ9iQOlpG6IKjPEBuUIjYotoymbqTP\n5u6gf8Z3UCM5y1Ra7ADo8h/dMwblmSRZC3MIAcPcFSEL0J0a2Bc9N3hJroDW\nRMyqSekoOsCJKGAf0EvksuBGkF/P42hlxjjMjqcg64ZflePivE9w3zvpvYPt\n2TNe\r\n=bhxn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-479d536-1627371654622_1627371700815_0.9205616110869232","host":"s3://npm-registry-packages"}},"1.1.1-canary-8d8264a-1627524132243":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8d8264a-1627524132243","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8d8264a-1627524132243","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1171ad19831bf89926404e0131bee41c2f09402a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8d8264a-1627524132243.tgz","fileCount":7,"integrity":"sha512-y8zPaThW2vI4YuIgSBgwnB2kNg46v7J0Ogvj9e5Ia3jWG0lQsGD7loNR4oko7IEiyNa+QVWtEKUYdWgcZv8VMA==","signatures":[{"sig":"MEQCIG5rW5Hc4s/F6PAdxDHK3jhhsvCzHx67SzA5n8BbpnM7AiAGatIxmny5PXhhtama8O6jIhl4ni0g74kCHRsAznPj1Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAgxWCRA9TVsSAnZWagAAGeEQAIDfHEAci9Kml/MtNyZ0\nLfMtYX7+HpofzZYaEKmyTR1efiVSHQcizgai/Q19uCyNdfWLQtfPQFJicSL4\nA7oHwbZk3yH/ZmQrf13ZIQ9r529zTUmqZTKlbUrcSekFEyRxCS1xR5IFuSG5\nPYXT7rbstOD4Zk/U1tPUu8YhXG4TIsJV2jPO8tXhSfTjNIHGujeFwoUfHVRy\n6vPtAQ25Rk8Pu9k9NDr7VZAc6iXiHQKtwNkT0eduMsTkiGYkEJNMjsdZ+suc\ntzG2LP8BkQM886aUQbogSF4HNjax6zRT0Rm/ZVJ/SKmqeHYLtGlRfe3uYcgl\n/0Q42FUiCGbK9ASVo4+0X3aoCtcm1oGCh7O8zfo/CL1GYYpYPWwBwL8RCscs\nl3d7+T9kvaEQM0jlSJIWaLBhYTUd2WUH+5qK6/o4fzvjkpFJGqy9y3SIXzqM\n5DOzUM5oKBpwzpUBHpXMQUkq+qw362kHckrvv6Icj3U/EywvUUV+WgH5S23+\n+46B8ERSXsKwvgSAAUAhlAeIgsUd3StjnnppZ2aIH65ojZLCRlba3IUmP36t\n1E2+nwTuW4siYbyhaUVFM4BRKyTlVcirvARL/9r1MwXilYco7JlffYm4dTi6\nBRPJUi9rZA5t9HaQ3fqKw+RDRL/TPpztSDb8ZINTzcMDHkucjkUz1V6ctpQV\n72V2\r\n=WgTN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8d8264a-1627524132243_1627524181965_0.26290960144923115","host":"s3://npm-registry-packages"}},"1.1.1-canary-8d8264a-1627524131846":{"name":"@iadvize-oss/store","version":"1.1.1-canary-8d8264a-1627524131846","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-8d8264a-1627524131846","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3160bd2db8d83b13fa0ac8f2ea55e60114a4a18c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-8d8264a-1627524131846.tgz","fileCount":7,"integrity":"sha512-BAqvVL3FQJqXMrEFAuJ0OSG8Q38XBzgV2H1IUuee/5s50AVw/BEUzUx5+0a9HKcR8EKB7h3mr+eztd44AZaOvQ==","signatures":[{"sig":"MEQCICKeQt66Uc4XZ1QpehXyu2FOp7ezSMRiifMMFfyaKrtaAiB7A9c7AFQICl+1oC+QRmtkUWTWRDbp8Qe/9WPcKqDQyg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAgxdCRA9TVsSAnZWagAADpAP/jCmcHDxo4JU0Cd2fIYN\nJ9c6bRmFq0NTaCMDckLsNd8pjRApX7hNgVB3ucHJEqEmmLpiUFQjsQfCV6wX\nTAcVzDQd42eETV8c2IZPC5tDls3m79pa1bAinQBucUWN/YyrtSBbBDoKM0v5\nfBaO2GcViXXvhtSX7Xd+7gcyAhAmVTyvKd/Vk5G6QuzuTQ2/oweXVbjpc5uI\njbphiTyKZZkIkCCSq9Nnep6h5Tr86piVTkC82un00bB/gHE4EPbxu3/3COxx\nNnUEFtT3N9shP9WpUPNst4Iy8QL0hJ1NiTuSoBKbc1G/3e1Sv6WZ2IuyV9HT\n39e2jOUzW8aKsURs3iMu7IRGUtE4E85O2HFCimakJkpr1IY5W9rM17er0puX\nP9ScwWxQNnzqxyiGUAiwhQvAPD9IDUj5pnToMkS05MBgG69UKCNaT9is1Qyx\nk3bvBEdr4xFMdrkovse35+06PTt4+KMqeVIS+J/w9/tOz8gCOXbWhwLPUGaf\nlVx+mOBRRqB2m+xFlPy1G9Wj05v0z/vZw8A1RYKLie7Ibn4ShA55w1bywv6z\n8AnNZENfjf5ZXnfjnBv3wH6od8/9CZIvehFKxuyi4OmErfwEcylGFJYUo6tS\nKUUKmfrw3SBbL9Wbitx8hG2MrOOWb1g+9KFcms3yww/w8FJkvj4sGCHZz80S\nA1h7\r\n=VkmN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-8d8264a-1627524131846_1627524189239_0.9372476032791381","host":"s3://npm-registry-packages"}},"1.1.1-canary-afa0236-1627547982076":{"name":"@iadvize-oss/store","version":"1.1.1-canary-afa0236-1627547982076","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-afa0236-1627547982076","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f3fba69bf07567731bf402c1ae10d4644feedebe","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-afa0236-1627547982076.tgz","fileCount":7,"integrity":"sha512-vmAXwHMrWcR9XM9sUGHzH8wXGUMM+msw3t10u/67clKqoU7CoQVaO57H50ODfyrKGMSmMP6QCZ/lUMU2oldrJw==","signatures":[{"sig":"MEQCIBDUkr7YJQAQfyeu9ultNlw8tTqUDaDDusqmgP6GePkpAiAf8qZT50Z6Sp1O7P9LIyUjADQZMT6M00FaATOlmIAW1A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAmmYCRA9TVsSAnZWagAAxSwQAJ7Nu9Gjt/0D/wYUvo/C\nbIaaPee9kWKu05/Fx2iIpo9d+OhBilEyFg8V/MqEfHUzpztrnfoe4qEDoaFo\n+kZdif8LrYNwf22XwGRtBAvouY8Z0RFe0YsxiAR0N9Gc9f+Jd9cFjMurThQ5\nLFgZlJ6uosXiTTJSapuMeQg2VeJ/5+8yKnvcdjXQS+yhZ7HSy4s74yRYzPA6\nB0GgWhkQWXxc06dRzhFs7Ff+/C39bO/CexYPSznSbx3/SCZd+v6SE2CrrCt8\nItSQxSOTyDLMQw2nE+XqjkVt07TxJR3W/ucw1YhpQ/HR1P2bY0RgRByiROpR\neW8EvN18mSIDR+EaIZ6XvN66kfAZPBOa/B5Gdnb+fCpkMLgIn7zJFFsHXEH4\n+V+HjVQdWytymA1+YPPY4qXak7vy0pVNzWGSoaJSkQnKeyjtpQwuwO0o1+yy\nyckcxnbY12qSFPPmSHdfqoik83fYjNrFDfKDzJkvFVdcC91Rq2bFtzg0upD7\nxsCs0G5hK+bsJ5yiJt7mmkNsJqOkx7kLk2tkYuxrdCg04DAeskWRvF0K9o1X\n1cq+aVx3FEcPMOG9l+ndrbh8OWRbJWZdqsaEWvDzFWFDxujichm91AQhj8DI\nOOXF6vT458zfMXtZ/CUGaI2byv6B3GdrR6aVMO1nrzN/t3E9hpMhUbAkSWfk\nxhRS\r\n=qAXP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-afa0236-1627547982076_1627548056422_0.8622131282625816","host":"s3://npm-registry-packages"}},"1.1.1-canary-2f8e72e-1627548240189":{"name":"@iadvize-oss/store","version":"1.1.1-canary-2f8e72e-1627548240189","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-2f8e72e-1627548240189","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2e83cd54b83cb67c0b1a7e13f999a9b0894fc04c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-2f8e72e-1627548240189.tgz","fileCount":7,"integrity":"sha512-axhMwb09wpeW6MvqT5dsVEElRfiXnRfY6quhaJiXe92mpYxrvr4sdPNC7A1y1RvrJDfMYeyt6iqNLXkWk7iGew==","signatures":[{"sig":"MEUCIQCQ1o+M99zAdg5XzS/nOKgLC0MTojFGuhTMbIeGVHkzWAIgBQhYrQJnyLN5hDOMr0FxIkVuQ+z4qmpxUgOSaIlysQc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAmqECRA9TVsSAnZWagAA/u8P/063ugjsYiZXAb2TDExq\n1pXZawzblJenAk4U+cFKrkIPKY/gtV/hWHZhuVi2l4n1eBb/TZ/1jkwg8llO\nXpxYnVHdMqoG0KCOZnDrDDHQj9QYeJ0iUERrQpgW8MEPpx3hzEcWKX4Vw/xh\nOJYocS7DHPEfaLhfqCqbYiHFwNWdDZSrhPDpNlk5Jz3BwneODVC0dKi0RQfN\nndbwqiR+y0OFMOOLFUvIZS+2zvmBffLX6c85kXdwi/bRW4UmP94DG4/XahdF\nuHqAjFvEBFs0Zmcp93RxPIrW0k6sqiZ7uud9YKxTsZ/p/aH089VlA8CHY0oz\nAQJMPHs7bhJ6o5k6epjf2h8BkbBwPL9hyEK9Q3imAj6OOEDTC4d/79tpfDjq\neJJF4l7oURZKIf82+ZoMtIJ9ROOsn421hPmWycBJupBpayBjPa1Sq+vLCUqP\n1Cup7MAqM77Vnuh2aKdI83l440NmJ0osW//OJkpLUMk/onyTVBm9sCp+pcpK\nGeKSw5eurWj5skt9EYshVvgOqLBguxaEI5h0FCix6Zarz2USaozKd/CIClZY\n8kdgFwm6YOShKp4YqNTP7r8jKXBZepl2YFdwZGxRzEyerK8xf/KyS1a8Xa9G\nV2s8kJWi3W6Qu9W32f4B/Nj7NxDz63ooCVwfiOUBWVGuYxBGzlxlIZ6N4Yvv\n/BTZ\r\n=9Ht0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-2f8e72e-1627548240189_1627548292607_0.849929447899268","host":"s3://npm-registry-packages"}},"1.1.1-canary-4c7308e-1627610527028":{"name":"@iadvize-oss/store","version":"1.1.1-canary-4c7308e-1627610527028","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-4c7308e-1627610527028","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f1b945344c1d2eda58e9e6225063f91baed8d934","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-4c7308e-1627610527028.tgz","fileCount":7,"integrity":"sha512-DBarKMp+PUpkDuDncgpJCESkHuh31cXzoKoVQnyWquie6pSAP0xA0jzPF1NPKINrEzOixVJJYQFxi+kZUls59w==","signatures":[{"sig":"MEYCIQDlqCOFqcqac/J+Gdo8tOh83G50TVag9iM2p8PC1uDXCwIhAJS/DbUesnfZstDHKt3WmTn1iwLv7Sjl7SrG2hbQKIEt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhA13SCRA9TVsSAnZWagAAJyIQAIkeXNDGYJfMf+8xeVIi\n3hRvqaAFSmhZtka4bM8R5g7cBam/UofdFHiAeYKt+TGGJWxtSoGX2xz1aHlt\nw8rhqh5nh1fZyU651uJgQb5UITJJ4jQ7ZuEP1/PSyNpJClmnoyrEB7j/w2EE\n+nLQ6Ze09v05q7+yVtppk8hvGntVsi+GbcHBvcEek+Oj8HUYGUz/2m4qmCYK\nQWTdbfOBGUDmUHyotN9w5JETBlrTGe33ggOnsobnMrvTmtQmqlJoaihgSTz0\n0JGhWviuXCPaueTyoVb2JwrhcCzOdgKeihrwDMWW2fyBgApyN4DHSvFTuL51\ndkT6zcrJd1eLmSvN9ksbBGmniKpV+qPP7DcxbmI4uuQkjnrMgspV0yfG8U4/\njAPCy+r15F1zH+e2888XyP/WSb1V+PVv02FK8LPXKY/AYyRHxcW/0SJfY3qx\n31nbLhlZf0tl4SVHZmk8VQbNkvmxj94crcpFHy/F0nwxcmgaCPmbdItKQHh8\nybbMA/WgU5dUt9dE8jKRCTLr6dTjOkh4GOkvmdBvuqO5hHBWfJjkkhGRVYxF\nLm1V1BYZ3je8nnIIffa5vrE0piRhHNlw9tuLf1AtOhPsEkeLOUn8zukGTad/\nSRIcHxwFLBqfEFI54pt4NNVDvm3oGrOk4IuYFVcNuWUJY2pc6gjjhI+A87mk\nMfOd\r\n=Kwoi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-4c7308e-1627610527028_1627610577921_0.48513796799370557","host":"s3://npm-registry-packages"}},"1.1.1-canary-4c7308e-1627610523533":{"name":"@iadvize-oss/store","version":"1.1.1-canary-4c7308e-1627610523533","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-4c7308e-1627610523533","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e82eb7e8c6d7b0b199862adb9f2424cabd5c912b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-4c7308e-1627610523533.tgz","fileCount":7,"integrity":"sha512-RwMK2WYuXeRGel+zlaj5myw5ST6ucMgULsVP/kxe75L+ruLIF7b8l+wAIyn2H4SwQkPifGI35SsMZJ+sMLy9lw==","signatures":[{"sig":"MEQCICOFV71qtaKd3RAnmhxrStpt+vBtS0P1CSnqfYTNDeuqAiAtmd1eU2J0aLB4+czIHDZ/Bqp+l1LNeoQm+DMd5DNesA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhA13aCRA9TVsSAnZWagAAUisQAJqzoIWHbRw42PK1KDbD\neONLB/JKhE2bhnYB/VeSn3o2THQb3Sku6s59rc2X6SzenRNVkh7jvmlmNyQ8\nRdoVF/ycLi+lIMVrCrLvckTE8uD3H6ny3lLaaxPZvrJXw3JDFmxl29DtS+DD\n4pZysOdNQNYHtFNw+CmuOvIbavfADcNmYg07a72aSCX71QBr+FMjbhUlIhsN\nj4xO8mgekUBXMP5E7r7x5L+jQmNSSJ12lRFqXXwfXeVl4ru9oV8b+tAcODVr\nvB0i9F4szOScl2zq3jrneg81AHrgbXECDlquwzo+IalIkuxoFtC/Iwb8YWl3\n4IPrxaevKmbrClH8+zRuzHc+QesXdq6FLRWnfK9ymr59TdiTUUekIq0w8FM+\nAH7uG8KfGdAcWwmfShH4807VH1bpUc1bDEC37ZmqoGNjAKPuZRt6OuKfaEvb\nzrpEE4xbZY6drgbD+VeHAgqymgSz6MrSljgZYQ8rk4hmnEd8MX/0V7bpkmAI\nPe3LJ59RCi+yNOt/FkAQXawBVak/csHhqB8pzBHm0ZjfZMAoGbH0c2lY4eoH\nBcqIQD2UWOcwpe74zvur2zP5DPUNnaQP09eIt75YDmmxfBn9KzNtgS+8mLGZ\nOZMcwzeeu5pGiDYPBlwrRMxISmeB1GqsqElQEtnmP7woycxYyFpjB+nA58kl\n3YuX\r\n=HQBX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-4c7308e-1627610523533_1627610586047_0.6463824181034066","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1627869757476":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1627869757476","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1627869757476","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"02f4b458dab6871f670fe964dd43524c3e60e816","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1627869757476.tgz","fileCount":7,"integrity":"sha512-tIjenrrxU8EsW1KA6EJWJ+8wacVpMt1cirH46+TZwssnqYCNzg3FyI2Q5/EQBvO3+8XVjKttlBWND1WWhnwZDw==","signatures":[{"sig":"MEYCIQC+oDKUh0+KaMpI2YP5CO4soOJ4s+gAFwJgaQjEsl5zvAIhAMUI0AnQOLo4Y00NpjySDN1LaFaznqvrVpYspQ4jI6TD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB1KBCRA9TVsSAnZWagAAe34P/jwT54fPw7VU/2abH2lp\nfrxLbXS5DfYHom9ecbwwVplHwHk6ixe2vI4UVn9P3yuKHE8HxXzkj1C+BvAW\ndr6g2Da+q5XRf3SFKKXJlmttTEscWT9lwrVo/MuSQV6Aj4bEQP6mZLfETXHY\n62ArTFWEIZ2gJH0c9J/18zOdkCJvTLIA7q7ZBHqp2abdRDl1gBImXRu51dZf\nXXYh38fH85fUbmIytp+54CSA5O/Y/rEXwPyBKlwUNuektafU/3X9u3A3cWh8\nilgMBnHlBt1ffQtMFy+FbJ0AC65EQDqeCn3rPYQgxF+cmE+uAPTzlZs+tygu\n1iL+RIa8erhMbzOq7nBkq7GL8y2vm/topret/Zw9AxkGuu714EaGKNV6Wvly\nqtf6/H7BmT8yqVFVQnuNrE/MAA1wPQ/IdDnvXlKh4oYzi48P7ly40woxZjnv\negXnmBVHQ5nyNe4CdkCzEkJ5JnJLbLDoQq3iTG8hkKKs9BRe1sO6V5aLaeDQ\nxezWtGMTtALyJO+Qz3IeQ4LFDWcEcbihEak0/eUbNtCbYN9vAI7bhGf9BPDS\nnjV6gz19BiocJKB2OlL8iUi+TjLH4mZVBG3hekaYrndjDqQgf9LLbN3b+Er4\nNjDk1kpCBDn+bwgdgl/P8cA2rRjBBAjXmqV3kphVTd9LYi3PIzlK9tHnVFbS\nlgB4\r\n=sp4O\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^20.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1627869757476_1627869825765_0.761768015251209","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1627869730106":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1627869730106","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1627869730106","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"99973cb110d2a9fefc7134b4045c86f58f7cc6e9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1627869730106.tgz","fileCount":7,"integrity":"sha512-zWdFGi00S0liBs7/rw3MVV0UXDCcbM/dgxBeq5LtiDlQJNBz1nELxs34OYCmSF621Hb3awD6pmcScR1LWditgA==","signatures":[{"sig":"MEUCIQDo2bzvLBR6ug/PM5pRvgUaIE4MdL5Wdyo21KZ6MAEWcgIgNUC0MjvJzFS/dgADeinJQN3Rr9KpXCPC8BlBN6r5Fu0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB1KUCRA9TVsSAnZWagAABqAQAJxkbppxuB4w8YFhQgbN\nX3fI5/L5gEDbIIo0aAky+LIQmQK/ZHiI8a94yIpSKilXhqNPr8Q+qBLb4r+M\nbFmb0ODJWYd7Y7Wne7mgBsvVgSeufx0awGPJxoWf+rVMwHRcpocLD7ZyIXQm\ngbzaaHmOeeUwzvE/0YJIaZhcqPfgRi3wlF2MNTZV1I4ZRgbk/QHBGwCRp3Bm\nqB1B1drQ6lfCq7S+yOfp2qMZ3TBLWgI7xFWUVVyCGUrXJnmm7BUeLl1rKCm7\nTIfyJ7ISaRxckYJish5cVGXwWaJzxTfQ4bPD0H3EK52HNf/fBoVxjYKTL+er\ny7hcbj7QlWb1QCEQF+Btv7LMobRpCtCSF48esP4DxamhQLpZrpHqSRupLfWN\nNhVQV5OrtR7uVlJADcHI+0ZHinx75BN3ZxN31vRjyCl84bU0D2gsa83IgXWr\noG3PPFj/nOnnr+EJUWaES0ddDll6qNT+NSzZZwYlDS854/iAJhmPWA3fs01e\nYbMzECNnqr/EHF/ltwd/bflEZq7XsYauGrQvGNhvkZ/OmLGmeRdXVMHH9Io/\nRl/K1lGjA6qwJPEpFkGA5bLLqsEVTrjg1zZ495v268F1pSDQSmHkkg1idD+W\nEeXGnA1h/0pEhXr/sRCrCOwfLrwCFgN1UgDlSWC/FxDhmo2wLZToz2muDuoE\nN/g8\r\n=sj4Q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1627869730106_1627869844080_0.6429420678033961","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1627869826566":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1627869826566","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1627869826566","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4da1ad7283eafe8cd5faa9bd42784d759c0c8765","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1627869826566.tgz","fileCount":7,"integrity":"sha512-2ZjQ0c89HH70IrU+1cWA6T3FtXfNOBe/0Qw1yBHvxRjHvpvx6hN5RemPrqLQlH8Wy5o+aVnPMChrT/bt7jSGEQ==","signatures":[{"sig":"MEUCIQCuxlJ1ht84rovs2A6wLVHwiaEFmYTohZFqeOjzwPfXHgIgSD6eBozZvM36ldoXo8fFYG/bzx7rgxwYtJR1hUnEg20=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB1LPCRA9TVsSAnZWagAAcu8P/0mVtHXaWzGGSQ6rtpCI\n7WuuoiLSFfbnB+JWiF7XZzEkK3IRLqseC0XGFEpfuC/Qx4rsc2KPwO4b+4Vq\nXOhyqSwbSvdBxD6lrhr9Rg8fNGOKcb0DbSC8ylx0WZgCpTI6k/odIZ0lC3HR\n60/+wfru+hlGMO5jocuMdPrPwBiGNxXBtclUreB4vvaFYAkwqHpCED5X4RDt\nQs/ZY6bO1js+3+XHR7oKP/aga7YNodLwNEY/O8EgBooGJVWEDDf6JFo3+1Ia\nZJ/5+vZfzCuQftIUq88aIj3/BcpqAUaOcfvsm3yg9g5Q+i3e9hs0yuVpdf5G\nvBufNJQnt93OpS8rziyf1xTBd7JcYNaZ3n77xxyYRa1l2r0HrSWitzlVwwtM\nH1vn2xshQ2+7d0efOj8RbzLgSkOit+RpNAAk9D8DcZ8FbS7RglYPSfCqSPN9\n4Wdl6yOMJPIwxGgEO7C2z/LnyosJUgrb1QAFZcD66oVZQ7BR332zAUcgehAl\nPRHfOe7U1Q5sGqi1+GaeRf/wY2dZ2tjtEtbG3Rmtb08UyJGE6gIvkALGpbfq\ny22sQwQlGqtiKKb3YK+KGtoP1FkYqvvBu9w3KVcR6/n8sgzQQNNHeVlWTamn\n9GRykHK91nPiTUHRxzP+KgcyfsxmsgYLFnjPY3gi3U9Yd4rZLs8gnFCBM9o6\n8lef\r\n=omkv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1627869826566_1627869903699_0.1302109387059167","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1627869826934":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1627869826934","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1627869826934","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"99e68ac878f0d8af832a0fc6e735a1aedf992b5b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1627869826934.tgz","fileCount":7,"integrity":"sha512-BV17qHjaYmJ2Dm6cRgcgXBOdTCrPuTa0sC3metLp7sQdwYB7NCaPafP6XRk/QdgdHL8kYqGovAq4t9/5pFhgqQ==","signatures":[{"sig":"MEUCIC/oFpXEyICTOTs4/BLy8QTJCqGXSQGmW2DO1HG3Z+FoAiEAoxEqlcNtEJ68X9y/N7fYj5KbTOHRo8botIQt11XC0A8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB1MKCRA9TVsSAnZWagAAPngP/jQ1Lhzo38kCbdYH84pl\nljXLGhpF3oBBKInFIgA6pOM03tfczFiglGJn7QaHIKDw7spCDnLvft6BFqJ0\nDut7vdd+csWtBsg1CIGr7sUyAJEZ/KsQNZz1NL+KeasQqipa3PaKSdZXPfYj\nwEk2iyF3fzrbyEduZnR8XKcDRLQD6v8JVzo7PLx1VXLmXQLZSKcBpVj0QAZx\nSkXWbjNiWSCnmyk+M5Ssijso3t0Mob8m+IPRONDde9Hcv9B5Zss39umrHDCa\nr2Jp0qf7IsV3qVeM4SmFCpHKO1GzOvo5IyblIWnXDan5TQZBk8C0xwidbzDx\nktxZnDoix5eJpvJTXkklVe9pV1tsltevK2aF2Ycb4XCUcZ8C7c/zqtmOTLRb\n8MrkuOfrpsc7AwrS4u+vjoR1UNCWM+XaCdHWWSearA45RZ1aIThnDQFwjg0C\nJAFkHGC1tbcsZHDTlcVETrrcYFQqkZe6e9MjYTbBJvwEPlG4czq1OJM2CyHd\n5DKPeXl75k01W+naYxvRSn4AYbGObCBIO2CJxcosEXQ7/nrLYSc8A3y+hxqu\n3NsTFmEALxKTQJhgdATBmGPpgD8ATqmDtAuuSkMwfkBwoIykHjS5x0vWfiB5\nCGBLc69+5pU0F3vlpW2dDIjSKYjvWMVDXVR+PkD5u4mZ/nMa8RhD0fndtaA+\nhCCW\r\n=Ec6s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.13","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1627869826934_1627869962659_0.9907635262857675","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628215327314":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628215327314","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628215327314","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5791b20e5554df6520c63c26a2064fca4218081c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628215327314.tgz","fileCount":7,"integrity":"sha512-MaKKuc+IBsxxHIh+ij+xu2c7cRNppLNSw+F9qin9r2pUnXxdW4CDr7ckyqR8U/plrw2T5LpBNNMHXhUPsQtJtw==","signatures":[{"sig":"MEQCIFaKT6e0agTfbGbsSWCDlCECB0pn69arKAbGE8IPoyhFAiBd43f2+gsHNpzwTa5qvDPFsy8gfTb77tPGzxbr5h7d6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhDJhPCRA9TVsSAnZWagAAXogP/3HT1RFAS9/rRONmaRGy\nFsSTox2TNsz4aiTiKUca/0XOlvEwXvqXS+XYs0reYJMItbWmvJV6jydYRRAt\npiTl8WgaMV4gGCfur1eSn/cpdB5IhPa5Wfwke1G3ihUzgaZpSzNHzHosgKLk\noTYaYjjH820ahL/kA+jXh3xTw/xJ/dvT6917oI4xGSN6OmDAg42PwjrWyE3x\ncei1KIlpOkBFH9Hy9pWunYGDl9PynlsaR6r18p6iVA/MRdIl+GvXcboaTcNN\nO69YLCYRQ9aF2v26EFOcQZa3LjLMXdmWh1tFlbfrD/iOQeFgj4RYqkbASwYg\nHRJo5vq4++ntz65ShHWLaXI0Tda4RX+ApHsaoli/b24L8g38N6nUrzhhFnkU\nMsKfNSMw+lderzcv68eKOKfVFBic60NB/elAm2JFbCEA3IRXlqP3TXiLNP1G\n3JLGse+aMpWHgG3JFcIUDn/pWWesyTzZbBbJiJS8I4IElmDKW5Z2sCptBuCg\nCkQVzD//IpXXFHdwAg05UWsxsEpLHNl3AqVFbenNmZDmPOjau2mwjxdgLSJ9\nDKVgXKoHjiLuKN08S9NZWxdWLhNUSpM6LPmbGMYn2vb01U4GO3KvFPp2Y7rd\n8cbAI8GfMdrYuMAaJlQsaWAiuQdhLtQEyO9Cu0wsEiTmflaO/MJdiGxvVJfK\n33iI\r\n=trfh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628215327314_1628215375511_0.6682167628034994","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628215329590":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628215329590","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628215329590","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"76470df80a11155a0e5280783cf99a2ba31fd19a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628215329590.tgz","fileCount":7,"integrity":"sha512-fi5BEFk7H8bt6y1p8Zp/B2EsnFj904DxiuLz4ym615tYM65N0elc1RHbGck8PMQ1L3gqxZwJs1P//tHqP9vK3w==","signatures":[{"sig":"MEUCIAn1QoSgYSwdlRnlPyU5V2+7FNSlHR9JvBXbTADbRDoiAiEA3AnxuU0LXg2rdhx71VmiRKv3JTnevuzsXyFDtlAFaoM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhDJhWCRA9TVsSAnZWagAAaCkP/Ro0JznpnOCSpyjq0rB7\nQLCL3HGc+LGYxiXnuOVyxLSpqEmjMdsvYz9XYMCbQNiqItHVYpqaQvFyR22H\nKsGgepAQpyZERMtAFb12jYfWDlt6V3hCdCd1uglHqugYgMRtQSDTRjab5EZy\nDsZTx/NDtPDtb0vidX8RnpKHripNKcBd6Wr4LnGS/xz+FvNiyQGZrK4XJZGP\noUoaNEEuBVLurdNBdHt31jZAHDY4fSsVm/2ZeRSG4HWuJMqU/x59zqRszKiE\nFm36IWtZQdXLqgCJAWVdp+Y2nSn8m2r0ZNz60hT6lw8xp2eKlIbxfP3q45cB\nqWixsrjOwbYuYLtbqenesabHNpQzUpgD/LUHT1T9xUt0U8Wf3iy/s3TlElwZ\nf5IxDfU8l7Nt3/WmYyS9IQnms9n8b7eR+YJd9f/r3Slyks84ez869ostDoeV\nbiyzUrQex6rmvBkD7v8I67off56657lgVZBm6cGrUOcKmkg7/nMLi9isy4Wx\nw4X6uwbS7SW0IKUd1CQ0x3cWB2eucau20WOd8oHpSpClUEDeNjrxUfmGmo9+\nmBlx0nYy8j6sbw6NfxFsf1ymHGhg0SGv1gQ/7YXFa/oGC1mmnLaxCV6/uT4e\nSm7bJ5j5x1OTHjPf9yrK11vKj8lRk/vGn4RRPDo2HCxvVZGk4BBpRN2R6Z3c\nCMse\r\n=MKfZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628215329590_1628215381852_0.6557235491667646","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628474537235":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628474537235","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628474537235","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7b17e58ed430bdb3d65080b38581580a30ca99e4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628474537235.tgz","fileCount":7,"integrity":"sha512-0aHnd82LyQRRQekB9Pc+OlRrxpJCHs2u9av3hIvhuUzj388mZGrEvV5WBle+MS6N3nykAcQDGyq36XV8VG3AYA==","signatures":[{"sig":"MEQCIHWQ5ZqkgK4hVszA0/NA/LlyQjko65TCQej/mdkini1AAiBDOmiGdjMiTS4m6M7EohetWJHSHQfO5UzSJPDAwYLFnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEIzXCRA9TVsSAnZWagAAE/4QAIV28T/KBOJ8FZ/YZ/aA\nr1Zb5yesREBweu0bp9aUzhoFSgG1UOWNQHJVgqn97Ds0vFDdfxmb7AFZCsKt\nrMLrbIrTkQLjY+uG6mW/vXHEuHDdFvOVbFUZp9KxGeQ1PoViE1MV1hjq3Ede\nW77S3D/L+NSbhPKcETmaa2DULHsUESRdYE0r4IXplQQvOrb7o4Z7cBeeFn1L\nuVRKUWXHnd+41cHPRpHPW7cUqfnRgYG3RATKn+IngCpedlGv2TUzLo5I22BW\ne+AoC6aNL6cBTfRKGmJNqorZ8U59uMXzQtZtH8JtXrO6zG/rrrAwoyzZdnuH\n8X1IZURJ3p0jdxtu7RwNcR5LfsHSxAxxnOT7oNzjmGKeBv6xOBvOjT/p8Ui7\nkZdDwCs38TlP+3CxCORy889mmP2daNB6LaRk86KZNCbk4GOkRJjsI7K3npOq\nTTLQTIZD7JXXtcyyHBlQD8nQbuJjy3p6HlAeNKLQ0j+BakccrGyMUUFqqd83\nSEADeCz5/33Nynx6TJdOTRVVyI9Tm4JJVNOU37wbLZGWaf9SfgJjq1u6Rh/u\nVQzYVxoQTmdH9mQKuCHvFMnSkROWKaY9mTAI6hrIlh1l/nMH7uQmDl+oG7Xz\njw6xJYWP1+Sf3YPghRD7eWCZQ8+HTCQ75hKYQMLN/K763Lu4RPPiOvMK3nvq\ndt2t\r\n=SE/o\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628474537235_1628474583563_0.20418834356771498","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628474541305":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628474541305","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628474541305","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2219ad15233c9b9a9b164c613b80748423bb653c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628474541305.tgz","fileCount":7,"integrity":"sha512-3DAB4sqQFI/6ZQHpIlYZVDx7217uIxkBKqVATSu07yavR4bZ+y519+W0pUfYmDNyZn72zVDGSKuYcYqbV9J3DQ==","signatures":[{"sig":"MEQCIDRpeaEq9UT8zQU1giP0xmS5mR1gdOSamn1Syt3ZUlhFAiBsAZ08DRulZPow1gLxiKomCfQXW+I4G2HJLuUzuyP6nw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEIzdCRA9TVsSAnZWagAAiTAP/0yJlVpeLVNPBC5MNGbV\nCZZFKM/CXED8EhaQ4ENgbC/r1hOzq5prerOgWySOFwcmv4BtbPYyt7ovioPa\nQ4edZ/k4ldcRO3brRcS8HubVrjdP5kztu2txL51/TBhYa8jBur9LBCVmltXc\nPYLLJG6He36K1OqgF/a0kncloYJJgZYgRf29u8PF1dH/WpqXCCLvaCa4B7yy\nS0E5DAnMl83SCeZDsI+O0LFUT2n0KVHdk7BctIs+JdL+MsLGzVkvAxTpsZ//\n0L8iUzTib16bTBxgVSVmmsX1bLrQIYaOzH2R7Z8c6BX4u/W6ne5AcKDZ8pHG\ne23rvepX9GttwF8IhdrAQ/zAleBm46oE9wz9cTMxzXXk/9J93ixGTDMxDaXL\nWCKzdVnA1iCkOQAXNSH+swMjLGjqUhKi8ihL4vZgoYm3DnJuPBqFf9Ung5WT\nvXzBHa30D3b0Z5GUgY7mkQjFTEkG6jKRtHu9mGOIVaG7Kgc1xb3IlxWgexD5\nKyahmPac4wVZG8kWz1dAz1RCOd5sRFfYiJ89Q66H2zFquMygYIofY08JYAkt\n12xpMJwIRltweff7r/nA1Od8yjrCplvIBZC3o0ITiraZfKKoyFCL/YUmZNmx\nWKZ6P8tXUYHHs+dljcFHMgHLLBEUMMPlsEjEyEBPBnzgWeeHJt5Ej9FbU4Td\nsuwS\r\n=kiO6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628474541305_1628474589302_0.08224573197545881","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628647374373":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628647374373","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628647374373","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e19df03fc5d5823d34bea095e6fefe900a7d8735","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628647374373.tgz","fileCount":7,"integrity":"sha512-MMzXqTi9xEHBLtqPHhaDNDHysQY9Aj4++TQceEKTNTQF9NvUEA1dhVf9AYe0aHgANpf/dOL29/O7MynteFNd3g==","signatures":[{"sig":"MEUCIC0qcJMjSI+56ZvncisGla1Us+v8Z8NY4P+dVmIzx//dAiEA+W2SZPTeJiIJ623OWMveW/GIDdzfgRyPhnjzTtfF+OU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEzAACRA9TVsSAnZWagAAEB8P/2siTR5+PMEKLBuhlB09\nCTx8ZqRXofE8ddnk+TMeHpvm6vfFlsnBAwcCFHNn5rmyV9iljbA+JRPVgGF/\nMBIT9Cyy6niV6PtCYZZCHDwRkKoXv4k0x+T6+hhLxDFBxFD4TkQr/JltivCo\npiahtdCeufwAq3OTYpquBAshnFqq1pPxhvcpfGK0OWlGcD5bkbBcI0Y8lYVp\nCLJD74x7qN/CAovnX1YhiPIt2Fhpt/Rx8ff4y4VPpXxY4T8vBlWW0eCU5DWE\n3DnAxhBwQpMV3P49gWk2Cwk231Xise4iQ37wkpUUR+iE6U7rgDAc1asGb7ic\nw1XpqCCyeAvXKGRFJ+NsimZGniaFo9CuGK3HVaZukwrGJrtUfie4EBDo/tzl\nApWlkK+gO8vtUUFhPII0nKhNkxqb73vkF2cvT3J81BBFivEKlH3EuXYvlid3\nhR9kNbbhkgR6gUUi4RnCE0f+Xpe1GLMcTjbH7kqckD/0kega5LBslKFKmErb\nLHPXbhUv7BJ9e1sQIof/tIvfpyc4pIy51JQfu50vsRZp0zEpFfXk0kFfAy+W\nwEM52wMic5Olt6+dsV4dW0KcUmSzC8UzVF7pqCGGu8Vc5ssaoBmrOYpoaUsN\nnuBzXNT+YBVFh/R9i72OQNwYyVl/QryqruR5361ni19yGiHkUj/Kjen2SYBy\nMKdJ\r\n=wQdN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628647374373_1628647424458_0.8429002132532875","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628647413068":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628647413068","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628647413068","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"61a884b06c6eefbdfe7eb8482715258d7a9b4bf7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628647413068.tgz","fileCount":7,"integrity":"sha512-pYWNUmtrb4p5NgnabcCG83sGui5tnd+6uWQjY3AhcHxz720mI50D61NSkY92sGWfkf9VVz3U5P0iTgcM48vIqQ==","signatures":[{"sig":"MEYCIQC1Bxqzz0uKsnZi6ah61VanGDWfADM0TPajYDUrnkWGOgIhAIh/thLbBH3B8uGCh3Md7iwLCadRstJ4ce11ryAkaYCQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEzAdCRA9TVsSAnZWagAAaswP/RsFYq7iejBNSMnUeso1\nlyxD1j1kaXwb1+5TVuucazUYTKsm9qTl8zaZVp88QKX2oWpubNteYcUbQwY8\nUO8XWHxyIl435Z9S9xyjq3PJlcKPYau79GvwOwmHfnuQ2P1cx5NwOb04oYnV\nRJ4i/ET8eUdG5SqVmJ2zKL6UvmeLFkxo1+VXld09iswUpQGU7F/XdGUE5OLK\nHG5Ee7LcGIG1RKK2kbVasdCQNl8c86tnTvssMmXpgKZHahnRjH2MEwLKYn/X\nuXDZ3cHmCdnv36gh/bWOps/kLvcjQ+I0CV2BbHiw/5ikPOZx1NzHncWTN14x\n0oSkvIuJmojFvmzI1jlyKzLE0sxTLeQU0UIqeq0cqByWVFPqBAUyL1uz0VTR\nOWyTZsBKkCCdfdTq6tb12ZXO6FY4Aax48qXh9HwwTButiPOigzU6cnva3qEr\nOiMbLUh4YI/MKXkIMLpq0nYyklvBMrpmMUxScWTR100VKESSmnVllGyPFDNK\n5aohRbg8E/QeMxKtC3RKkq2rbva44x+8SVKsguBfJ/mF5YFA3Xx1jM4AhaWk\nANBAb4S2oF40fsg+cEfKx9g8KVNsS9RtxnuDTD2avrkjZNB3qgUA+2aSbW8E\ng6XvPKqiOR2RjjJZO62lMqMZafPhHII7CwCyufh6dDmu0lSWT/rl2wsJT/17\nnoSw\r\n=UwrM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628647413068_1628647453586_0.9019884858924401","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628647416742":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628647416742","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628647416742","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ed1e5120a546607ca4abeddcbdfcf784c677e9b4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628647416742.tgz","fileCount":7,"integrity":"sha512-bl5PkftgZF55mFrZREltNLNGfDO1rUKYu2PaSZz3b1IOc2p33+TtGagwH4voO/Q1L6d0Ao6Hcq1/6r3FG1+z6w==","signatures":[{"sig":"MEUCIEGP5WBvAOJcIGjXZWqbV1RLYtvcJCkhztw1BJ9epNGcAiEAqxAzvozoLlxPr5mPmMJjFuXhcFMiRj/rbBDgXHAjEnk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEzAwCRA9TVsSAnZWagAATjYP/iZ38jU8UntcYbf8+Elp\n/DUvx7+lmYgdfBCYsjzK1sCX5sEAXB9/S4o5b7hWjsAHESJ6AScS1eLJDSNc\nPKnmwfMCnvYmtV77cl2RXys59KEnmqA1bE8AVdERji/7LxkCWVw5NYRnOmHq\n6Xd8Qaisaz8GUNQ1bFAgL6Mvj13YFgG9sZSj6InRb92fl4eeEu7DunoQUrb9\nRKktEsW/HOmwnr/fkP61XA7V26nS6I1QqKEH0wf/XxSgd57JLy0c1YjMtbms\nsilLafUwmZKELUNHjUmXAErKkVcwGkrSMtjcK2aidUJo+YxRBw6GViTB6xJK\nzeTnJONeoDGHe8TrDeNbfMVhgOv58e13Jmsz4CRGNULvBgvx00Ul6TO3WKkz\n3ave69AdKnNwUMEsepRyXRzrfoi1OZ8RWlTk1vXnes6yoM5AN97omcHkOTP8\nd9wFSthzt/C7oF6toBuWdzP8QF+unQZeB9rDUcl42irIBdNLJo3p6Q94L1aM\ncZObRRynke8UgqqqC3jLbFnD9W/ztWQaOPKA3ppLqd9hXQzbU4kJ8VLxMVvt\nzZS3GcIOISyyXjUUSNHmMo24hIDKJ3r8tnCXD7rRC4/X/C8+TLZ2N8sjirHZ\nWRKahcq/jQKTju1V14CRH0HSgunj5sVPoDn0hAm1s+P/wJlBHyY57fjIFWuU\ntDT7\r\n=JSoy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628647416742_1628647472221_0.6406928654557391","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628820146193":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628820146193","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628820146193","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cf2098a718ec5fbfd558e11dae3f391577a0d95f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628820146193.tgz","fileCount":7,"integrity":"sha512-3LKLExYDcWZPgPN6YQmR3w+Ag2SqJGDfiXMkOUlFrw15iOybOdq+sZ6n+OfLNjgWpgzOxdn94oB2q93tPp5tow==","signatures":[{"sig":"MEYCIQCAwB1zRh+edDcO/6nLKrYpctTTvjaQ0dDByZZUR/Qx9wIhAObRwh1X4iCeX8sFyyp3TDdb/zFvPAlnzeliIWzl3Yv+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFdLaCRA9TVsSAnZWagAAXRQP/RKcEhmvngT9xkTdXgQc\nZT+Z8iMfMMM50W86rKG5CiQTtzEgddwdbtZ9R4xtG/ZFJPgTuOQ6kpTi62dG\nocng+2pASdc6vdtJQA18Re3UovlBduI2a9LgYTnOl8BvOoPUWBx4ufO7riAJ\nNmKS4yhvSegKz0HdF521+mrEfXLn2cmNF5D0NLHQf1oyaeEkPqdBYw0RldET\nUU1UNMhPZ42+wu18MAu0+95gkSv5BEjWdRyFcfkFMWrgwuE0SDcq4tcHP5Ih\nnChVL+gLxkq04Pb/KpRZdCc55Ndr18EOBpzzttAhsQ+SARG4Y2GvxzIJaP1P\nhYsG/S85F5EhZVG0+b7MVPz5Ogop6omOLOB/ODjunpXGHoMbMUoiSg2DeMRb\nDmeoc8/2q/TCOUV7T0kMoobziFs/WqyTn7+dQPOLqSBxO9QsUrKlcz6JIHXj\nCUTjUcnSGPwZ5TTIZWwvGPuj1+/WGmD2ZIKMqf7B6KEj00m0LkFHLGDWc05L\nTowlqTJahE3ukiVJCzMEdLG4gfB6ZkAGudoLSEPcTnBIdEv/cwq1oF+HbExs\n8AK31evC9HfMgxudrZ0hfHeY65ovNVWSsHmafMTgv1yyk8mdCt1iZ9A4JMIE\nglZ0JOj4EMIWId+sjCxXt7cacFKOVJAF81yoVeRuqII0Oy7L5lazOaEFmUAj\nsy5P\r\n=qfSc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.1","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628820146193_1628820186685_0.6166444417270709","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1628820146865":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1628820146865","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1628820146865","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"71f7824cd59234ee7d1b54708f4e8f559241959b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1628820146865.tgz","fileCount":7,"integrity":"sha512-kSWMRAtPhnml5C8Ucc9fl9/BgrjlD387SfrjX8wquxPlbZlckR9KCwapJAflDRatGeSNl0XAJ/cpXdU/KoQyrA==","signatures":[{"sig":"MEUCIHseoUDznblZ90CGdGE0P4N0ITkdnZGdeCKAkNUBdalpAiEA1LcLX2nudwl2YgQfzIlYBBuF3PS9M5LPrLzWMAPWfOk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFdLjCRA9TVsSAnZWagAAKOMP/iHGJAZbyEYo/mRUn+Xk\nzMZpzRzGQ9MP88VbetwMUc6a15L5XAhahm500IW1AQhjQ56FO9aAkc5ja4rH\nSU9qbBRZJK20Gg+RbH0yqAvXnnXzpWb+UZM3SxddFZN/Jn3UmeIobBv4CbTj\nKZDyCw53L3uSa+F6sLB46DjU0zreA9bmU+jONxkUPXzt+QjXqagkoJ+AA5fY\nngCgT1Lc82F+OFDTfxyvd95P3S1/aBSoKGLsDjgOrOTOwy5frDEEa/18CoZD\nd3r1/L+5xXyApWEl5gLKC7Zg/w8VbzRwJorRT8MD2D8E0FSRolWAd16lUWBy\nrMdNDVyPr94q7nk5/tnwY2+aq6gYd4Glmr1xyVdpzHrzpZJGqhgYZ+k894C+\nMZEqe0sZsWd6lT7RC8TTFMqGllEd3Wbr+sxVWZbUyWzXT1KCr0uNg3I3hCLw\neUtP7bZu+wUDX5tWBemdaYhvKjrmNb1/8elcsxwY9+naTMBa5OgeECnlX9RV\nM+l0fjxDxQzGJO7CGeucyFibVvrcPzeH3WHiSXoL8L9O1ilsGepC9KOF5ArI\nY5K1mYBMc5wA1viE0gnKY0CAdfgKAlHRmat3RtIBNf39C8SzLP2M+cOS1CZj\nmrGaPvquePqzLTEc36NwxNfvh1vFSXJ4p+Vc3kS6ggSIraOezvE+2fDBrGwC\nokti\r\n=mrrf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.4","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.1","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1628820146865_1628820195058_0.7760323252231793","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1629424923507":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1629424923507","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1629424923507","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d5b6e8b8c1cbee5ac7bcc8dab77bdbc52d0be284","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1629424923507.tgz","fileCount":7,"integrity":"sha512-5nsuOeAYqxFgRgU6Lf+amFPSe2eJpCiAKtNOVvZeCAvf5S4aocJ3X+X6NQFWfHAAalTc8sABgYnA7XstklD0Bg==","signatures":[{"sig":"MEYCIQDxubif3VXrdjXUvQV5mlOoVpQaSKbA+gFBpm7GJq/VQAIhALq8wPEMpBiFgHrrOslRQv97qOqEd9Ta7854c3svcqwk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHw1GCRA9TVsSAnZWagAArrEQAIzaqKrWTqmQ8IDFb8i4\n1ERkRJWL5F0y7Jf9HCIWG8BB0q20v0G6SJfeP/5KahTk3oJ54kqU06jp8L3d\n6+eB8BFT0uxLSQJ5UBPCwGEwJPdKnZjRHsI7iBXhNUpez2bciB28O/Q2Blxn\nEoTOyWbaOolB2vRWPS8MdMUMm+1D8jOe/D9AayQBXkPD2fmU4iBilHgfrkbM\nWr0tR5OQ6KGYB94CckNzEGgYwNf4GtBE+/AMnoeSm0guw9acjurSmPLF3cQl\nJ7ke5JsJ8FtNUNKpZDlwIDwggdojuNyTf5+aY0brFFwk2+3F92XOWLk8K6qT\n8Yq8v3saaXRaLsKWPazfEiQ7kQdJDDEh9Xs7YHgd9kSlRP6lZdIpbwNgDQGv\nduDYxrcYYD9ZOr9q0rrYMqkWfCQODDrU1uf5Vulle4xoHfpUqY3OfILSnY3k\nGiPjI0kx9mpH0w/T4AocjcDr4rU4IzeKW3Iu5f/yzmtCiWAD/m+DbL2IkwI+\nnmlRKr3BCyLIZk3twQCK9spdSnRSrjU2BBJ+fkssaveLM1Y4LYr8LaGZ6LDh\nKOEvcLn1Z1dJED0UwIg+TPotg3KoOCi7FZTl3yWfVqJCBIBKEP2GlGw75mzW\nnqWC4zpSESvgv81eXGnoIR0QPNlGRRHRKGrHyh1NARu4y3g//SytCwREP277\nEjyK\r\n=iJMF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1629424923507_1629424966126_0.2835983668847637","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1629424924912":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1629424924912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1629424924912","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"91727698a72e514bf5cd021bd467d9fb4dba3d85","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1629424924912.tgz","fileCount":7,"integrity":"sha512-wUzeseJNN4RTymnsAYMrIYM+znd998M+ArzjEQvcHNltoIfKxgHS6JB/7emjr833jwYJ3RgVhmSSZzt1Bpj46A==","signatures":[{"sig":"MEUCIQC18Xsrpb3jFd/ZaxYWhbKkneN9qvAn4Bgjg7VLdAKHfgIgAWcOBl5lR+RCMbXgy5Ok8SbVjA2vnGBe0qW7WyLF/wk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHw1OCRA9TVsSAnZWagAA/V8QAIXMsPFDRj0gzHve7Yjj\nNbh6Dmlh4QAcq0PD9PA6b276b2OY47EflGOiHWZkcW/ZdXbcR+Pdvt2e7oNu\nZBjFVpv238q4n3MKrOLp0BtAxH+rveovJMdS9BpxlpZWAGx+NizxxJPl3V7S\nwvFBoheKmV4mY2/DwFcgCB6hAfYoKGCwd5YBn8GrznhWkEHy2r33smnaV8NM\nlU8tTAIU9vQvutqVOzQ8l6ID2X8AJ/4UoHOcQeRaxB2X9KcIDXZb1g+ZM+Ea\nka3rdvKvhlphqMRwwNOPQ06lf+YNKzwKp1g3TTI3Q/WaMBud9QNp+Gbglpit\ntnrKyOPTonwfRzyElJjso7COJIof/jWBAmDm35q3lIXKRISOwZsEPQbsnNZv\nJOBSK+7bsxvmNcqRdgKM89EGwNyZft4B08q26kc98rK/TgIZHDCcPSTFkU9g\nrXly8A3iIb1BsICG8bmQtAPK207Aej8PyIbsdo9KeSienUPVn+TV3Qd481av\nbUV2nGBILE5uhfSFu33IEm6pjzCOinPmWCxF/l3200/oGhBrEpI2W2lTK6l0\ntO8sRN9eWZWl8u5XdXWL5xyBlUJ2M39d+Me/oY1f6u9avUNhYo8qKOu1F+rG\nABpeU0hpwhHzBpWKigQcckmeBPpY/Wn8u84AoTkegxn2DuQqVMmMUVVkMleh\na3Bd\r\n=drUs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1629424924912_1629424974706_0.1953669891553882","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1629770527825":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1629770527825","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1629770527825","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1887c3de741c8064bddc1246e0f8b9f1a55a6d92","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1629770527825.tgz","fileCount":7,"integrity":"sha512-jKzsyK/HTqaiAxYkqlanCUC+tANSXn1YyWcnbLjdYHKWbzAQIImX/YEGdtdzns7lwxhJhWc6trisRcoMCrJ7Gw==","signatures":[{"sig":"MEQCIHwW3rqQ3F5x0Aot6s7H17ta8lIU4CSiUGpyULBmdz5xAiB7PSTQDfnfXQrC33Ge2fE7/Lpwr5xrBD8HGBrKqDRUeg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhJFNUCRA9TVsSAnZWagAAo7gP/i8FHE5590nVpfzJjOIH\n13jnkC6pvRmg2/M+N/6Jmw8pCEfOSHNqxxSAqTvJelvqiqgunVL9gL4F6Gkn\nw1Q6eH7zbhPaW7Gfa32KSZzzfQcZxJjRBRs1Nkcd68AvO6AGKso24so4rQR7\nSckcfD5houJX3RcGYt7Bft5bSC6h0B4Hm03H0rP9XzMCp2B/KOomR7qMArhR\nSlZ6o/h7dy+fw8S40W8S3vTEIoz8FqobiZyUZMCceANVGYpb8L1sSeA0aECY\nnrQD1AN0cyTVKFU68BHNAM6sXf/LTMnrzBWzhlCGTOSHD8k625AKagKnXICR\noapQeDrYufIZdBNQ0Z4R6xJnDLbmF25JYVbOhY9GgXK/dkx3Zwys93/MzSvf\nptMPWMPvdR2Exb/HR8AXwaAYgu35/HiGH0dq0nnlpvxHRyiPtVOZtDMkzbic\nuGpILoxHgrFNQ6jWwLnC4krwh5O4ZEdJS4fvv4nErKX+QY2QzZ+ZXK3gUwNF\neUvaPZhGCH01JbbuBJpzm88Or7gTCZTEIu/kzh9C5FYdqpHpi6MNWJiTJ7Gh\npDXeJqP+5C3bJC9N9P4Ml5kfRoHLmPe93Jh6FPhxKROR3Mft86iOSqS1IDQg\nNTU7edA73Op2KNvXF54KBTBAcMJq/QMx0trlDgnUQL4dyjhsxCW/IZ1z+vDf\nS7GL\r\n=iidi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1629770527825_1629770580050_0.4701069189196456","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1630288989697":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1630288989697","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1630288989697","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cb3bbd4ef5025f13be14ac415b33fd3656a79296","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1630288989697.tgz","fileCount":7,"integrity":"sha512-NSdAhCP43ux/tJR3fhtPSuk+o4iC8Do4QncnZDyvtEsEh3Zl9+RARCFANpCGOXwP/i49blhof9IO/HUi6DdJRg==","signatures":[{"sig":"MEYCIQCNMHT0HT04exM972YcMJTGK+p/qIy1SjGgIXnq4+EenAIhAN5JnqCcp+LGEZ34i/k7sY8QvJ8LxYTOQRULhRbjlDxd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLDyPCRA9TVsSAnZWagAAha8P/RK/fVTb5XaJzcSGW4Kg\nMX80BQCIKVkbyyWUH7iS+WUtfvOa8i+PNSxgyWK6aQP6FdbEoV7NSS5Oe5C2\nWF+jIMWbrNPXB3dNg8XvwihTTvDi6jzh6yhIHFk5UxvedoOd2vsKuPDeW7UK\nUN9i0woYBbWyYHIgKqkIXkrFG82LzO0dfhFm/+cS33mAar9dnoEj+ms/drgR\nyRE2/kg51VADW5dEvFKjlgF/0/Na8MXalEbwjvPB2Dqzbo3xo7A9PF4IVN3L\n1H7YQizTqMTJJiD9tOjEIzRMaif+GV77DuWaJb3rJKUGbt2szkR+DDO2beK9\ndKfEOD3R2Uoliz3fWf8BswkzNRD/sHE+ZVedwLKItUnyNmuWRNpMA2ox77n9\n36AnR0ECFB+JpRYhrUYYQlx3mHcNzVZz4OWREQ4E1EhNNCdZDlmey75OFtxV\nfGmNKGpoGNbhc715NYOiCHEyWyFbXK0SXATxLsYyg1k24++nLRyMbw8ZmRbU\nXOYZBn0TkWHeNiJngjUEvuOA2aRHHjMXM9kXhY8HxsJU1Tfu9k3ZRSMNYer+\nmqS+Pw/MMLMq/SVbM+wteYL5U08fzQXaVcmgCbDdGxeDBLJ1v8iQZt3KjrlE\nIlOVivDL1fIddSRDUEvqO8HX9+Qu301qyXc1uB0f9g6aTIHDtH3CX/ZHjChg\ng+OZ\r\n=FPJJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1630288989697_1630289038868_0.9670317449189525","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1630288992072":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1630288992072","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1630288992072","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"17081bdbc0e5c45633b27ec297b31f75d02a8642","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1630288992072.tgz","fileCount":7,"integrity":"sha512-ntq7/Kh95QnvnY8fVreUCLCMVp/TQuzQFhL6tf9DWuyekloMKh7ANOVrSocqurgCs+QChsJRZT/JjvA6J+HgRg==","signatures":[{"sig":"MEUCIA+iFVlmy/Nm9Q2dkKnjstNGs5KZp+cu79yTlOva22wzAiEAkdqHKOKOK9dFPddHblenb+P0mKKEmnL62cC2kMbSEE8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLDydCRA9TVsSAnZWagAAVb8P/3INlo0pcIlEDSdnNtxL\nnrQUvHUysg+QGHnAV9ZKP3wAe+l9pqyHeXz5gOowMSQvMeYS8OXbTcpNYLuT\ne+McFvWbvs3wqkgFfEsJ3IPZNbo9CyhOLavf+WYq+CQqQt+15kTh4xCeFq02\ntLmRGLGbexeLOudl7u8vgEikLGvsTIPQ8WtcEd9qUvxcbcawoelgAmoIUWc8\nXSKNA3kFR4mtaLAK+bjooqM0HLOuiueL+XmF5nuTK8dhOIc4qPhnLNON/VYP\nnMZO+TPz+q5/CUVyn522M0GeKjgDZNugo8BFJ8GkOcs0VfADNQYUe9QhY0+u\nWV9kjjv8yhxPmZ470iTtkJRTTz6N4Xd9VFTQXx/KmoeFhHOkGhtv6/y17wlq\naVM/hOEOs9Uxi8mA6fNKoZWZFDVUCXxE6AC/BoYHA9hY7OboJrBVhtCVjL8c\nrRgtblot0Ldm70cMmBcSpfRVHsz5KYvtuk0iKQdZksMyNQFsER6DA9ikMD48\nOCqoT19fhDsc4SZiANPvp+/Gv8nR/nLRCmzQzlHp0vo5sp9UpqfSlB/PRpE6\nXWs0lzmQw6rEk+S7SaQr4X30HOZNroTcC0uFVbQwnD/IpdyHfcnyw42Up7n5\nAvxRs9QMOxQEPyFsFSOWijbtUI+K23GOlL7seYbJrE+Hn+vq0Taf4XZYXjtT\n2qjl\r\n=7zqp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.14","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.5","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1630288992072_1630289052948_0.3174892676856045","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1631498536717":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1631498536717","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1631498536717","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"59a86dbc989e77b37803b314cf66039f1048baaa","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1631498536717.tgz","fileCount":7,"integrity":"sha512-kw8j3yfk/dVvLDuk2Xb21I3wVT6ZuYqY/fi6ZBbGxePGSLyHBFP4yZiF8V7lMiGr2vZBs9tmu+A2cwTLmk1ASg==","signatures":[{"sig":"MEYCIQCbXXo5KDFnGGnp1fb4PdnpzeHRk//CzuG8ssEOVMZzAwIhAJKf9pABqTRK2nHV6dzNfudvQGGFXbx/863QTvl4XNaY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhPrFnCRA9TVsSAnZWagAAj4QP/1uoaqMylNaBFdSiB2CZ\nOItxTbCc5rfbco9q2B2Hp02VhGR2bkryHXlxE1LdpVoyJoPYrc0BRJJL0n6+\nqtHFnfaAozvojsZQHah/wLCqsUGq70mDpD83U3vJWJ9eQZaAWv2cIbhzHSFD\nBFg8WfGG/pTHhU3kEABsRGkraaKRn+eriIa2K792enJKANiajLBneb/m8QBa\nLGX3YXiX/EvooaG9w2MnoPGIuqvS6ZmurNp1YvyQGnHUSXEtvgQV76Z58uUM\nWhzmeFFK1ForHTM8Db2LKhygYDpAJdvPD2RL3dmIR9XBuFv/h10Kpx5hGNAi\nZlft9NME+f1uHbuRF9XroCq4/f8JpAUp5n1XThpToJ38RhlmECqeaCgICwoc\nSDU+NnP7UUlzTKOdKnSpOrO5ccuxL0dydcCxS7LZfsLHbba1hdRalliDLhsn\n9qG/1Cr8hxlF7Iv60/IKC0m7Na/Ogov7oI9eFYnaRwrn46foijVip8eE5R2g\nm+nZOBK2WnSIT4yphok9ZijYeLniZu4Ju2cDTKQUI7F6L3q4MKcD0HFdTnVS\nPYxDFn6/Ytm1Xd8KJdZ2IS4/8OKhLBAPNZ7L+CiLEu66naMEA7JBblhc+mEf\nAVzpPn0vx4/8k85LwtQSM5JJnoIN/0fOKxGpNNezn5PCE/WQJuuWv6a61RtK\n3D04\r\n=lykT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.3","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1631498536717_1631498599072_0.2137015940394913","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1632103335995":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1632103335995","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1632103335995","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2aa41190f65011e8e690c8f616cb86801bd42d4f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1632103335995.tgz","fileCount":7,"integrity":"sha512-LcELYaHL/wvUm6Hit5hPQDC1RGAF7Z9co3Xfk40DBjsErfUgOIYxjZZoZ8jJnkuUTeg4BKKpsYUqZfmOAcc2Dw==","signatures":[{"sig":"MEQCIH1OpuYvKdprIa0hGarbdHa40Bqge9s1pfHUoqDaAxaNAiAi1p4yQ2uMXkIfGKoZVm35HiJwSNeI+/ZgnKSd3B/rVA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.4","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1632103335995_1632103391925_0.9595360873073482","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1632103335135":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1632103335135","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1632103335135","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bfa803b00379cdbfe2d4debbce18e606661616f0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1632103335135.tgz","fileCount":7,"integrity":"sha512-jJ3EGnhB/ToNJ/e3CqC5TZXxGHtGKTzfICmTZE+DlGzTUpFm27EpPN6fqPv+6W40+mvrT2sg39qlA/XJUTYSTQ==","signatures":[{"sig":"MEYCIQCQeF5WHeSjK9pYn5sQQQp1c1y9zkHt0osuZLQXi8vB6QIhANQfTx2iybQE5//Po1YHGszsTB0wff0SlgaPLRf9rnOF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.4","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1632103335135_1632103432888_0.23750357771521236","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1632276138702":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1632276138702","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1632276138702","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8abe0190acf511c8c35e45bf391a2e322a5f8401","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1632276138702.tgz","fileCount":7,"integrity":"sha512-M01K+37JU1r4fbm7cqxFms6lt2IfrsijFKzlb3tvNWRwKHLsRbhDreEqY1X8h1JcjcadS5+mqu3NQe4NhigN8A==","signatures":[{"sig":"MEQCIHxy6mLGJlQqh6lDPPY+O4aFM8x+B3vVDxNq45+0l9emAiBMk9dgGBmrY/PMcrbfStAG0enBEivcIrvtgFscguldUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.2","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1632276138702_1632276197052_0.35496428851623274","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1632276172025":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1632276172025","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1632276172025","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c2efa9dffd3adb248ba1414a23c82476e48ee0bb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1632276172025.tgz","fileCount":7,"integrity":"sha512-sBE7rqnKvU/8+heQUrjsTylMFQDnQRu/5JSIPabN2TkZmjy9nDbuQf169dL6ijhqCrg/36sBDeMMrj3k38HXKg==","signatures":[{"sig":"MEUCIH44A1uKdoIU1cBHI/iHcZSuvj1OdciJGogdzsiWHLVQAiEAxcGV40d+tPGZio/2RBdivvpSk8O1ejs2TYeLV36Iaq8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.2","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1632276172025_1632276221618_0.09447587006994818","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1632362590782":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1632362590782","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1632362590782","maintainers":[{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b3080ac2ed7dbd0844e0f8b820375644c84eccc5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1632362590782.tgz","fileCount":7,"integrity":"sha512-OZpX8ef98b+51um4bsyWylZrLYBVdfTXVnKsGxqmAVSa1jKin4/mt1fXezoR05ew3Wqe3xkjL2FTW7VqPI3qag==","signatures":[{"sig":"MEQCIHhFiexfCww1ufiq9ec6GQONR5L4N1B016U5/312KTXLAiAyyjPJ5+1RVRrNEHn1JNwhns0dQX3bE3+Nq/7bgipQyA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.17.6","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1632362590782_1632362647324_0.46497266597968023","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313096064":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313096064","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313096064","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"69f5e314cecc45c3bdeb5d954bf0a246c09fb1b0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313096064.tgz","fileCount":7,"integrity":"sha512-oBP5iuCU2jOF5yCuD79XP2xhXsJOEPSWaGOU43H+pPbRZFH5mgQc503obAH7LkfwCvRezj8l2zBjmwBumr/2mg==","signatures":[{"sig":"MEQCICoenVWLY/xW0mDQObDc13VMFltYyaj9+qHDd+xZZVUfAiBCifaaCuEm92M18ow0/yUcxpSJvLuHh+Zz2UhSghoFgQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.5","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313096064_1633313145786_0.5472322531300748","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313104910":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313104910","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313104910","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ec6a0d34e5233df6f1e646fa11e3091090caf056","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313104910.tgz","fileCount":7,"integrity":"sha512-PuMatUY9j5Jy8dkk+VphR+LzOQZD0fobYzyoJjr1dQ0qkyAYeqc152z9h+lNYWvBOqOFVnVu7nkM8gLailQhqg==","signatures":[{"sig":"MEUCIQD/SVL+KClMqrVN4gNYjWIkDALJG0zs1bf1R0gJ2EJ7tgIgQq9ThkDfVqEHvys+ANsLT6LzSTxyVw13PA3oMn448+U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.5","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313104910_1633313163011_0.8286455873484537","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313167122":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313167122","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313167122","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9f40eb7572107f22c72ddf90f63b9c7fa23c70e0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313167122.tgz","fileCount":7,"integrity":"sha512-52I6sspC7jaBDVKYwXosrl4Hb8qHF3S3Oc4GVTOYP8PAILAe4uiPKAUXIoJ8Yqwpw0hzGTuMn6wumg/FwlSqPA==","signatures":[{"sig":"MEYCIQChcFnjaFw/cq1J56Xc0N3TQO2/etaZV8OJ/B3IQFBcUwIhAPX/gesMD7pxRE/MvVj11N54Yr93tkAXfgT4Z3K0xaJk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313167122_1633313219721_0.786905279144374","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313170273":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313170273","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313170273","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"40b85d046e44655a838201035ebbb4780a56a73f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313170273.tgz","fileCount":7,"integrity":"sha512-P70L6BrYl7X4joB+2abCRZwbwqUEJehap68svzzuhTzCxsZaZfNqnj68CDshpmS8t/zsIUFoTkmDwl+pYrXUNg==","signatures":[{"sig":"MEYCIQCSB2hfMNe8t1UPvCS1VTgoL+ZpJxKIA8/mQE6u2KkjWQIhAO+2me30xLCpOi9Gs+H1zENPqmAZTV/YaWH/rMjkMZti","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313170273_1633313241211_0.052107286071745085","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313237681":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313237681","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313237681","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7399cbab4d0da9cabed3dac4ecbbe993ed568e8d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313237681.tgz","fileCount":7,"integrity":"sha512-hp3EupBZyQj1nuJ9QgP57UMWDtzYObbm1Q1R1uULxmhvNPDhf2ySuRJ4HY8h7rYxNu4cGSKpGzqdEWru13OATg==","signatures":[{"sig":"MEUCIE1l0noJT3TrHZtawKIyg5r678R8HxZFa3wr2UpfWQO5AiEA0RZTvmQmOdRZ7Ig60+w3HyoPJYTFg6WP3esgFYKW3P0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313237681_1633313297405_0.14951837708990356","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633313238263":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633313238263","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633313238263","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fd3ac42559a5812a7f6597151a89930dcdc2862b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633313238263.tgz","fileCount":7,"integrity":"sha512-g3Pot0acD8r6vBlb/yJrOBx5QhcO5WCqHYwzQJ2jVO8mKUg20gNqL0C8tR5UyctmflXM3plzKIEuMxcmYFWjug==","signatures":[{"sig":"MEQCIFAcgeSGTvE6NqDRYT/C5iW3dcAgTBT4xA7OhEg8A4naAiA+CnTNlcrvHYGrRIclAI2HiMCaKFmbZGgrKbtUDsnKSw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633313238263_1633313310975_0.00023645226654678275","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1633917874410":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1633917874410","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1633917874410","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"82d7d42152e62c682e46dae6a42846ac6a73a0e6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1633917874410.tgz","fileCount":7,"integrity":"sha512-Amor7XKdAYQv/S/+luydmTt87/EaE2qNtX6Z6gu9IWpFiKddudzJjjr8fg+0clkfwkub+NlLDBGpR5PqGAYCPQ==","signatures":[{"sig":"MEUCIQClYmx9cX1HI8+2XCoYQH3Qi1zPDJ9lqRqFXTDoJ+5QkwIgDBZA6ghqoLYiAVbPDNFxKYOAWSBMpPCwSOQRMwMh0XY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.0.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1633917874410_1633917928374_0.6224578679792128","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634263414706":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634263414706","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634263414706","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fc7f2578770efe9768f442c1c740c07f80213f08","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634263414706.tgz","fileCount":7,"integrity":"sha512-8mc/l4uqZn2C/0KdTWuLIkjlclGsbBK0IENQj2nlQSz8FcCnaNBe5ZlXvMjd9isWah/QUjV508kjjnozpMa8zw==","signatures":[{"sig":"MEQCIDQ6DYZTG/Qa3KkO4xJd6Gz8oiaUCYQWA9C7TJYCTCcZAiAlnFOn3yNaQQO9dL0SbjqFeQKwr+dY8KpEBo00qFkgZg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.0.1","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634263414706_1634263462451_0.18758601647486217","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634263416385":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634263416385","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634263416385","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5069182e3894cdbf0f56960fc7fe8074624c3400","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634263416385.tgz","fileCount":7,"integrity":"sha512-aliD5V/z9xyrhvnfrfN1mQT1g5CUVdDnwtQ1gI1vCD5MgwHbmYANAkdU9L5Ta7+coJHFGdYSD0cv+cKRdJCkTA==","signatures":[{"sig":"MEUCIQD8JY+4tzltdvpFO1g4Q3AjPdywfWnNveUGBYp0/ik44wIgBSvthw0D7Y5IrwgMhmPv+K2Xr1XV/1vr55oG5bBzNEE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.0.1","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634263416385_1634263526208_0.20861950689239706","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634522576598":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634522576598","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634522576598","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"94a4bd3caed6afba74bea86c2b38508c9c23847d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634522576598.tgz","fileCount":7,"integrity":"sha512-YmNPOiMfX4vVkLshQNNtcNxAlifVCM5F4HLBTlDqlrzBoTqXWwXi3uz7FN7JeGYYtRT3QF6ZiXOKudOZBicAjA==","signatures":[{"sig":"MEQCIENrCVTYviI/Adwm+ucCyjmI38a483w/WfdUNHx1aVyPAiAapI+2HmqOelHAiVVOvROmVqGQrpoqcXHBwDX+G/tNTw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.6","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634522576598_1634522618656_0.8640732023133773","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634522578034":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634522578034","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634522578034","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bfb4bfd9270dc49828fc61a18f68dc02e6589dee","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634522578034.tgz","fileCount":7,"integrity":"sha512-mB4+vvG+pPa3rJEJ6rw8Ce7/ih1amT3/tLYyxbNN0E/ZAOhp+UaJzs+V4iRicgHMZ1GB/Nj9ZsNWWCLEZO0/2A==","signatures":[{"sig":"MEYCIQC3gH7l6YI6Bvoh0raLvt+Yzpb73Ppp6isrpf9VI3+IoQIhALUFZz+QoDOTWBcLMjN/nhn5WuvMfXe/YgrXMAsuf9Xc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.6","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634522578034_1634522632284_0.8270139458988779","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634695385552":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634695385552","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634695385552","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"41da2d9378f78e641a771a91c1109e310f9dab4d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634695385552.tgz","fileCount":7,"integrity":"sha512-ufGZBOeSJlsjwQwI8AlLK0L7k5qudjGebxRzxr4zY13JfvCbMm8R9vS0eFvpuAXWFJXDwkVoShSl37dEOmLPBQ==","signatures":[{"sig":"MEUCIDdLjga1prHhldtFIfJaEB5OKYrg2noBSpic/8tQVc+yAiEA8rTsTF3ZyEyG+68uMKXcEia0rYGwymnlcg/PHHDFh8E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634695385552_1634695432103_0.7543887430553602","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1634695384739":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1634695384739","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1634695384739","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"58fbc66a4426c50af1e95dec4f68d934737b1699","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1634695384739.tgz","fileCount":7,"integrity":"sha512-JWowvCo7oCtaQbYBFjmCgvq0AQq3mcT3e17+8eujL1fVat8iG5bWk07wLCF+1VDxqptxNCFM7fp3M8H5Who/wA==","signatures":[{"sig":"MEUCIQCcgeRQA5UBzTTRVPEi+1vXInW02ukjOLg/0aR843npwwIgSQcTygXCtEjVzM9j0tUPF7wk5yVHEmWazG6qErhIa7s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1634695384739_1634695437984_0.5457369495442779","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635127387563":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635127387563","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635127387563","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fd5c5cc612d0b46e3994171d7a1251a4046d1b86","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635127387563.tgz","fileCount":7,"integrity":"sha512-HIEOD0LyPmHWHgvt1SYQxIULTndbwPvDt+2wisDlpWf5YFzVGHXS7/tkmyXDNgHY/Z1a2x/yEbGn38in/MHYKQ==","signatures":[{"sig":"MEYCIQDgrDS48idfEwvThQhzfWl7d+z2BlhI5CrSrgOfjARrxQIhALR5u3rBM1BG2uy0PQrwXJO6k3whn7/dK7QhERfpYPhK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.1.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635127387563_1635127501821_0.2130205540396004","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635127385784":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635127385784","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635127385784","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7bffd1bde657fd92f42d50b276a66e60734fb8ff","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635127385784.tgz","fileCount":7,"integrity":"sha512-3D1Vi39CiqTQCVth+YlJiKenYVgzzbHqtOfROTImC1qU+7Ip5wd5n/atS0ZDsEQGXiytJ0lrOnclUqhLS3Sy7w==","signatures":[{"sig":"MEYCIQCWv/oPtMezdhzYSk16dMSlv6vLTZ+tJZoQkIBpi4pnGAIhANjgLMF3uEhz9WI3hpui11BTQ/VJwTGWrR44lnU/+X8H","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.1.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635127385784_1635127506111_0.6196941264143669","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635127483466":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635127483466","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635127483466","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7aa3988d8aa1da54df4cfc4bf63c7d9eb9b10d05","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635127483466.tgz","fileCount":7,"integrity":"sha512-IU6fm0nohjPJlRlVAk2mS/igXKgv7vDw4rG307tSUHC5w+Vf/vCIliDlZfdnIFE9bNonUWVubK0LZ8t4H+8CmQ==","signatures":[{"sig":"MEUCIQDB1hKG4uKQ/FdsCqosNH8zu9AkzL+lzyALzstDU3MwQAIgU76rUOjZamgxP2tV1KMF+bBJfo3kFABlacm9eLRUHh0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.7","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635127483466_1635127539068_0.5514881770457778","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635213793221":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635213793221","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635213793221","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"708700fceb0ad3db9ddf02fb5257822f72206f00","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635213793221.tgz","fileCount":7,"integrity":"sha512-BHYcGwZWFw9vCEsiZqP0ZXo4kJnLgFCUYANG/Iz1ZF0CEI4xlT+49dAbS1HLS0+2UpDps9ZTWEHLiGx9+IrgjQ==","signatures":[{"sig":"MEQCIE6SpfEaIJKcdEHiXapHBymdtYXVBH6WHcI0O23lEnTAAiB5GrfYvc2e+kSzGstAGOYJOdNnMg30Nxk9GBgBzPk7pg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635213793221_1635213841339_0.9260122368346178","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635213795404":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635213795404","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635213795404","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2069fe3b47453507dba97dc8365151111716180a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635213795404.tgz","fileCount":7,"integrity":"sha512-kAgMJbOyOmQQaeemOLIXGS6PbbD5RLWvqsNO7CDKp/nJPCvaluanZxQNHooCsGzu6gARCQo31FLiCoGeigjP6g==","signatures":[{"sig":"MEYCIQCrZvc4rwAR6xPa9qqDVrFA6xXJkSMMJks23ctWOfM9ugIhAJyoeqvx23JM14hDXwR8qu5OuAoeZaS7uThhy1eiIVNr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635213795404_1635213851086_0.8944225246890178","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635818555400":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635818555400","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635818555400","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7e6725b29ae5465d0d4a855964c638fe4b856603","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635818555400.tgz","fileCount":7,"integrity":"sha512-LJ3qGxapKRdtwx78+61wWFTGyU0g/RJdWjYuhT+oVwtDah4WFQI+d9Y5ErhwxUaePRwdwV30z0D4OGdKngrdNQ==","signatures":[{"sig":"MEYCIQCNAmOj2rMrhQiYYKIAEZlKsLCMlnxCdvYaXRl4cY7m5gIhAOurbd9jCDKv38FhoafO8kVP75BDvhIDa3O7fcSXNAPS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635818555400_1635818603455_0.5770101920210076","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1635818556855":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1635818556855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1635818556855","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d265f4d75e350839fd691e4a64fbe31ecc5a95c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1635818556855.tgz","fileCount":7,"integrity":"sha512-5jnofIfOD5NJDXQpzhDlC4u9X6T5PwRpErfccWt+mBsT0/RnRxyT8DxmHpGqm/qJWk+dxk9Q0qgTKHOx/9zhDw==","signatures":[{"sig":"MEUCIDL1AbK+lDLvrn2kY3TKCZjPOVt4dVlYDj92Ahtxm7+JAiEA6A9kfGOVXePKQG1S9vcZelzdj+ERWl2T4OZFoUrwMwA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1635818556855_1635818610778_0.14815551584677533","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636337047359":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636337047359","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636337047359","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"744b42953960bf731439e1b6c55168cb6a832d8d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636337047359.tgz","fileCount":7,"integrity":"sha512-xf891ZpiLhu9MLmqIwhZstgnV9K397rnteZqX6L1qyMVTlXWimughs20sgeeTx30VazCb/Nl9FMdDt7hKixiIw==","signatures":[{"sig":"MEYCIQD8SWXGmiji72xq3wCf5ygRLEG5o0yecoLJXkQdzpsUKwIhAJu8hZs43lKUFj2SZzyYFy9EbtxF5lTlPLtInGbMuePC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.2.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636337047359_1636337094104_0.4294197217132272","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636337051787":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636337051787","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636337051787","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4e68794d5b52f2a04a474bddcee7a5037bf4be09","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636337051787.tgz","fileCount":7,"integrity":"sha512-pxRTJtRjD5FMI3+m8Flnc2J+A4PReeEhJFKCIW2YUqeXVc3ljlJntqVxAEVuxEQMVjsnEkWoFbR0P+qb+zOLYA==","signatures":[{"sig":"MEUCID0DwiB8MgFVWS+l/4OhdmNtXFWjN+oNw1QeDE1HoKQuAiEA7mF9x1UkgekSE6VD/cKdm4FVUURLjfXNwVYS1A3/LQE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.2.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636337051787_1636337105388_0.1287419353967354","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636337035586":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636337035586","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636337035586","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"af754cdb4fdaf08248bc628978abace54626ee4a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636337035586.tgz","fileCount":7,"integrity":"sha512-TVZTabkD3AKBni/Vt8H+zmf55T2fvt5p/eVYTIa3ENtsFu6xTYHXfbZjxEa3Cx3nvK6EbK7HNDx9hPYMixCcVw==","signatures":[{"sig":"MEUCIBGx7vgNbbFWadYcWtNCHHnk41dN4BZa5KloocgzbqyJAiEAnq5F0D/zr9ubwvPwOuh7tR7/Chkw1l8TfG1LIxWoVBg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.8","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636337035586_1636337116726_0.9174535547915557","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636337035855":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636337035855","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636337035855","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"5a08a84486c51eb6e4cb7e35df790326b2029623","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636337035855.tgz","fileCount":7,"integrity":"sha512-VdP4R/eA1Zxt8hkYTwBe2mEibf53mZVql6MJ0F4x2yUh4OWzxiHMc8jXQuJtvlkcSFIZtyTc2Pqzpg0UG3535w==","signatures":[{"sig":"MEUCIQDQOHIDzUuKMOUI9OJvVq6hx+qYGgKV9DSNG3dMYYyeSQIgQ/8GOUFHZu8tKoW1rCliqxV1tOYJhQozV/IzBy8E8eU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.8","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636337035855_1636337127984_0.06353178897783285","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636941742097":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636941742097","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636941742097","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dd3aa4c207693588f03cb3b513a71277a81c2a31","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636941742097.tgz","fileCount":7,"integrity":"sha512-DmWT10F53BKHW+oC9U7d5j33bj/iRg1tgEdIjWwgDKz0zlJq7NVwqO+ah4sIJQydZlzf7zz+9YNm0hE4Rd1HXA==","signatures":[{"sig":"MEQCIHHiGdP88D3ld9218sJ+UDz2WwRp6zr1pLvJGxREEWo4AiBnwGbsjtLyxXRGhJ2pcw9ld3qDdZ9zbk87J6f5mAqFKA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636941742097_1636941793710_0.3645920269435863","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636941741885":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636941741885","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636941741885","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8dec88098cd5c9e1f1994538793481ed6277c23c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636941741885.tgz","fileCount":7,"integrity":"sha512-qmnRCP2XIvtU0us05EwNBHt7lNvT0zymikkB2ocFi4Crpi0R10wrWlJWcF7qRrbHulHmZjiD4g2LD3imU4chDw==","signatures":[{"sig":"MEYCIQCv2AmYmzvMovdnL7vWbjmpGu3mAtrYcwS6+/mqdHwtYgIhAJELBFT1PrxK2M+tDQhccry4ROh4xwougHrxtKObNdQl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636941741885_1636941852350_0.40333788455741537","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1636941809282":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1636941809282","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1636941809282","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"75fa997bed6ebcaa0d9beb49e568e5ba05faf1cd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1636941809282.tgz","fileCount":7,"integrity":"sha512-oSc4Drny2xULgiJZH7IMggnjTPybXOm8ILvswVDx5B1+bVygtNoEubFodwaY7aSpCrD7llJLIRxz5TipjEe01g==","signatures":[{"sig":"MEUCIDebmpfhE0tSC+/TSFoPPxhAcrX+IsOVpA/SoUynSl93AiEAqZMOZtW5SQ49R0Wr/GcajkMrTSwbhZJcXLqhz7GvywI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.9","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1636941809282_1636941857383_0.4681995071424563","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637287414464":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637287414464","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637287414464","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39340b9ddf5120c17c5af7b38766b96ab7606650","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637287414464.tgz","fileCount":7,"integrity":"sha512-W4n4jDXJFGYhem1qca8Nx2ppLAMS/siQk5ab00PhvKpQwvFl/zKNp1nZSmduZaAM7gcp2PwOesKZ4e/p8IFQOg==","signatures":[{"sig":"MEUCIQCvhPegjoszHZhN/MN8YX8ZDR753eGUW5FcogtlmrjUtQIgJSEc5OLMEfs287dyAO06Y1ukkXBaRiVbz5Nbs4YmDXs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlwYlCRA9TVsSAnZWagAAG5EP/3ibMdg+4/rwAfkj/U57\nvixVLhTnBWrvCO6vuzMpemWzuEnENPVw608sT17RZXfvTYsR8+GpxzU9Ev+i\nesYolwfWY433NIbMKup+ek3WFU3b70T4KIWsnkuuvR4WhYCSTnxL8jzbwbG8\nN0VRaXepzM3m2VxKoK3JtS4tWSdoW7Basnw56BIl692ruq1HxkYKrQ+mMLW9\nqQ0LP7hfUdZ27MQSIiaKXuFUpb7SoITm/vaPMwKv7lDKFjjm+UtG1zhufJU8\nSHG6JyOJfKICfmJzwDhdsTToOrHUlK6jaVAQjjJsdgI0czTuf0gKPridMwjK\nxCdVidRxkqpRrvjCzbxxiM7gYOhqzkNAaTQ+GjxUzNUMTZA4SxvWvL87drbH\nnPYxTicDeQA1576yFi1Nj8DXFoZdshT/p3J8AMmMhasGYusdRVizP689udhF\nQNS16Xs8V3ae9GYZ4CHDPS8lmm+fUjAdpxOK1vcaoHZa+vS6OS4w9ncCHzlV\nHhDjY/c9h4jKyhwLRyNnJKJhOtBy5/NLE6g4hDuUd6jny3CSvB3V4sT1nR7r\nn1yd3Fz8YY3EBuqa3gKMILhS+8EZNqWaarsOBIGl4P5enF/fXgNCBmcdlNsj\n0DGzhTtTGbp6nrF4S+zqY9A1J6rXIk1QKwxcH7HbWYyTMXJToUe6iZ7tx10H\ngu6Y\r\n=nKys\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.0.3","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637287414464_1637287461614_0.3282344492914424","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637546665205":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637546665205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637546665205","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0f32b138bf46995aa1e9fa0f2d941c92f6482966","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637546665205.tgz","fileCount":7,"integrity":"sha512-PeZHTrEhegL1no8UHzIhJ/mjzKOSIEmsx1AQzg/sns8mVp+4+CiaidkboMdd6EXyZ/cH7816LsKDApVdGUAjOA==","signatures":[{"sig":"MEUCIHS3UjnX4aKse8dOkurLPI4UYFq6Z6Kl0Kl7d0hfnbZgAiEA34vxABUVUuAZZKqjBf2NfgPG96BLm/cEwhzCtX/0vdw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmvrWCRA9TVsSAnZWagAAwvgQAJ8hV81jVr4nHdWAmNr6\nk9MlBpgas2LqmroC+0jK+c2GE5s2kaxKgylmPBxLZtaEr9uAxosI/t+aZW8I\nMybnyz2LIy+NrJhdFplMZq0vSvNYIOIk+VdItdmajkPtNgO/gWxF2epZLk/z\n/JfejeeoYtzLtrR/qPCXsUXgnF3AzYCEv+65hgFPB1G/Ay4BLFWaQWYoHhK7\n8JI/t0B42riOwK7y38vc2Jfaf0S7kOPvkw0NuQZ6NKJUOFgi30i7/nL5XVDV\nqrpB26iBl+n2q8+zGg3viEyIFVrOhLn2yUyxtNmWC5Y0iFlSRX3uhjtQ+2ny\n/cAeN+Dt/7krger0N8C8CTphMnDYxsAODQb44n3zrsplPFbXppydIrlVbDOi\nPuOE/swSZ+BBZIckbaNtVDI3PPMq1cdj0i4WKlr+Md5gggFfBojnktp5INIa\n1nBoEnpEchCnxLPBrzCtS2Saxzh19CBr2MizA/uPzkm64p+kWo3BjiIffkyv\n2mdKX4I9Wmg8cw2JmjNZ2NiSQeICGx46VvnKpjRCKBP9IeGepksADQj9Nmhg\nRzl6OsmRuC4Kb8IvJx4o2deUsmNbuBvYCmZ+jGwlfTW6arDFiAWunXNUUR/2\nxyXNpx6lwmVom5m4mEPIaT4CWQZOP/kBkezX2NU76wzacsjmq1bo7MMZaPR0\npfRa\r\n=6z7p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.3.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637546665205_1637546710540_0.7500646753049118","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637546673364":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637546673364","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637546673364","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9e13fb8a2871e04e8d372af6bfe6ef791eccf327","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637546673364.tgz","fileCount":7,"integrity":"sha512-TkV8HBLXDFrOSuy99uMERoEsozaIL9RlKbKxey9ifcfxNiY15EuSXNsvfbxIR6xAezKTVFTODfL6/8q6tvGBZg==","signatures":[{"sig":"MEQCIDipVkEX/dRj1LuKS18EpGcyfpJ3rvrDcbXuaLGdFHJAAiAEgAFBWvXD2Vvs8+Y3AmQtpE/Q+AwMjnbjRP+cangdzw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmvrfCRA9TVsSAnZWagAACKwP/iE+hCT7o8xjkrA9PFOK\nu6pmCHZOo7n8WBw8rtWBtzwPzEkHqtzjKnk1redVM7mOTiK2Aa+nhNyWffK1\nHqOOjc/za4xht7W9oHKXpTDFQDQ8FvlLNoH85MdjTS4YrB5iuaYVCHR1MCii\nvAy0H8Z9sBDB4sNp/qEw7zJFjfh48afg2QJ4qppnME6LGs/EXXZX4jnrcWOp\noY629lL/s2wLw8eBguMxavFqP/bs9M2ZyHMMh4QGWCGPChjkdlnp+jm81js+\nhd6xjFRfqgiBSAKYPqg5lxXxsnICDsN3R5B+xKV0xGV5c4FlD1RFr11RaVJc\nDL43TzsHRG+Ua6peyEvYvD/cqmKMiR14SmDFl0HN44JHVdyr9nHQOBgTES0E\n91UdtyMWz8HZf1xNXBLYWcW1r5hzSMoG96t1sB4yeHyhk1Vuc8EHls4vFAjU\nbtw5iA3U3ZeDnVSv/63kTtEFSoZ2tFoh7caXSRrtJd5qgSBdAkPKs6umWaje\nhXDo11yW9BDRfN0eTqyh79AQAylGuJG/VKrCi5GX5sN96BuvDatx3YTpOYHT\nAEh6Q5A4LSEPChKP45V6EWljN4ZqxnGvgty9ZIzneAdf+X+ujwjWFPQrtmyt\nVDGTTIaJSSPwH5ibCcddyA5z3NLPAYLtNdt83JxIaz53er2DT03vGialyLlY\no5qW\r\n=5zHr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.3.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637546673364_1637546719319_0.9985549802364582","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637633030112":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637633030112","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637633030112","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3871035c0ed440ab7aa414de617190f02174cb76","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637633030112.tgz","fileCount":7,"integrity":"sha512-Q5MjRK3ndRmOOEVlbuccPWc3yGP51kAy90LyfwA+pP6orT0jg9/jpenz4JXb1IyIsxFno1i7L3JZA4dSAV1mrg==","signatures":[{"sig":"MEYCIQD9OCS9WfZNWguPu/syvLv+CzVwqxyosnJjRh55hK+UBQIhALp4xibPIbrTTKIwnDUipWr+J0Cdkmvuc6OCoburLoJ/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnEwxCRA9TVsSAnZWagAAircP/0lvkva+4P7ebhk5Rm18\n+ALigPnbWnqaGjOzxOk3dSTOLdu3sCvIobq54C0b2pYNF6gpxnBrJw9rLkXT\nVUjeC5HM+WXyBoXfrxDD1O6v+48kmdF7usCO6wxd+y/AxPjixPiAnohNg556\nqGFW8PHHxyuwWX/ErL1t1M7z6TE8p3kOcpHUD+Nea38WYjXmlAUx/u4BXHGg\nZ4LsZ0UFKSzqy0Hzd6ujIgR4ratnvU9WDnV64nNvmV19c9koyQqaABYGlktj\nLke6Rd4IimL4IAgbbDJTE6eQiv7vpg1VuQQ2nJv6z6CBISvpvWEoLS2htLy7\nVMm6gECiIlOO3YSjwFRex0SH/vfgfNT+RgVSMdEyHmQx95+tF72ix9rR+ko/\n52HTpotIuvCIBML9XvZOLK8k0X6I+aRPiqjc+Px1sQQFPH/FJWwdgbRjdgdE\nO315TVES9am/nUk/N/SEBP3NXHcYEuTE8AerxBoCJCYtBHCbhCOYZu5WtCmI\nmIhg43iRXY4YKlSYVS0UuF9K1U2Iao/ygBkb9s8/yiEAlUHGR3pGvRyQs5ko\njyYiweKGXR09XdNoRXn886IM5Chu/K4Acd1HzZta73aFK5VhxksKWu7Tzral\nbh0ezGsQ/Tq6Yz5UE/b1jjepdi8rgdBtYG3JECXGVeOsP/V5SA0tRvDNHqAA\nULTB\r\n=26pX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637633030112_1637633072886_0.4045831511857618","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637633032745":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637633032745","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637633032745","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4121714a038032f8732bbb9199ab15cc9124490d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637633032745.tgz","fileCount":7,"integrity":"sha512-17oDpFuFz74uqt3PTQrhHrRmThrXztjj8ZVkL0UzD01SxuLjJRG+LzKyUOZgWRmVmnvSHYujsX9c/0jRPAqvlg==","signatures":[{"sig":"MEYCIQC6khZTPWJT4f1A7ClaMHO2eACRBcpFBbpde6RGK1azNAIhAJL5vBXLj4QkwNOfzc+n7vzVqjx3XL4utrB/qRMh0+a0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnEw4CRA9TVsSAnZWagAASAQP/02nUg9YUQP0WhotY5FX\nkE532HqRNx2uaQhrq+Xsc6RgxsqPSDBtN877Wa1HMlSVOt0SLdY2olFOk2YT\nZTk9358/2gBYdF6NDphmJ1n1aHDqXzcL2j3TtwXRx0nmU1qOC1V4wj/gl+hn\nxb72WMlTlRF3jCegDOphnQRtYE8Ai7yXGnRd/M/dk9KCcNIo10vvfLq/qguF\n+BMMJyHHA+/QA2/DxR1maAO3TchzAN0p5aJhvKoTkV2kz7aFro/hSt1uhkGM\n+peKyeL5biL2SQ2ZCUf3IRD1+mcOA8OBsIMSIMcdH4g1+LSUHgOm6Oa6aG+d\nrMTelaNqamnHqh1nYvxrYnPBW9i9TfilAvUCs18X/3aivYSusS06i2R3csnB\nHeJyEX0y0YjJREQGPJO9E1rVpHBe4kHczmGEQBq9tYf0s7jepKPCkoBBGuY/\nGfM0IIL2Azt5W03MPpR7lwtozaEd7QgJRCj2tTzuWutya7lHGeMriAmmTZxJ\nFiq0KYmQWFHLczdvGubcsdE+btMbUmXkqDpT/0+JHACq+JaU9dbNdhcmiRrh\nPS0i3cSvskklOKoKnetjepTf/ZoYGs7AweNdRRlZfXoO6UhBsq86EHDTxN2v\nVIwSLwE81FLWJgY9jgZ8mOxEDhciepx7adLrxKGd+rNxaJz8kbsYIGIdVLMV\nnOmj\r\n=O2It\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637633032745_1637633080062_0.7271572840234759","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1637805758499":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1637805758499","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1637805758499","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"890e174b231e9b6f96ca7e93f40de2f0839275e5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1637805758499.tgz","fileCount":7,"integrity":"sha512-8Rd69fDBsT4I3cuCCjC31BPue1XvXsxuzsHZWKTgjIg/GN1+J2FDZAz2570wo+FggQ3Mi1EHmQZisnrjatGgfQ==","signatures":[{"sig":"MEUCIFRDvegSIXXoc82I3YFrjZgBaf5SnPg6qBENnDMpEeLbAiEAwjMIhyfZXQO5QXmlGwTkuK+wkRR337Hk8V/pSOXBcgY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnu7uCRA9TVsSAnZWagAAc5MP/jCFbWSE/V0uQfn1ZPYv\np8HGFC2M2ebPuTvwnW3rkUa9I8z26K4VE7oVYnhg0TpdiMswhZ+82ximbd4U\nrOSQi6clP18oRWs25OZZZ0KcuihxnRzMZmB7GngI/4u2bY1rSdJ4N+hGM3mz\n7kydilOWLAOEeqkbvvbohWsRFaMP3PdIQdlB+JQ7Li247Nmv7pnwLQV0G6pe\nZ90zwmMTUeYXKyrT0gpCrUr9JCn7VQb1Glm03b8xF2Tl2sQh3KM+7lpGonZF\n5CyIlrEAZUm1H8AAQ2ohgEAkzvCTX94Viedi1f+VAgS3C/JNY0VSplXCWrg1\n1vvcCPrUGK6Ty+edTbzokBM7PQz7acBFNFNT/AndiOvkwX0QSqefrkYO5tNU\nZWcHSKLWVZQHNM6nCeyUnZYzpJ5WiNDhvo0dVdSdrn57T4XJJBFeHMa9J4WB\nHJfAYidTaHVV4VJ7MYlQZjdqSMXcaWsad30QIrGU0WBctAffsBi9i89fGOOM\nzY3OsV76KOJHUY1ol1ofl91ZPQOmydtzdymTeqvOtktHLF6+/A0jvQuHJbLk\n5B1ftZKUMmmF5XcD2hFOifw3UCwCoeGbqFSNkAt67Gv+G/+BpBWeS8AgX2Th\nhsUvC1blwx/1wEwBWz6zIcELVkX7gBI6WHIGY7mzCxI1B4mwPTB5T2qnGW3X\nW1F9\r\n=mzpk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.10","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1637805758499_1637805806100_0.07676081314399386","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1638324177439":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1638324177439","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1638324177439","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"aa7fb47fba690b992e9f38107782062d01e3db1b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1638324177439.tgz","fileCount":7,"integrity":"sha512-MfUVfN6OJrT9sEFLxq3zI2eLfpsQbg6J+rWIxszdeV9zjQlvmm0Q2xBEEXwkgHpESLFXVxrx+/IlshfEteW0Ig==","signatures":[{"sig":"MEUCIQCGydwlb5xG8Uf6rlqr6l4RiUooUSYcmfdr+pfFa2fVCAIgWh0mBXi3tBXo5oEnCW6OS6cW0VQeOXWM0QL/oe/ZBwU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhptgBCRA9TVsSAnZWagAAh3AP+gMfY8IJBFtpCBx42G5R\nQktAKGTJ5VI2C4Z300ev6fTp65nh6DLxCvO6drAdUMNy0xhqgSP/D/2Rm/8r\nfRzs7A/nrjfATDkoNyONpOSgw0sNBn8e+MpT0zaCf0sgVjhmnSA8iEq7R0yz\nrjdc5Bj7yOBU5UYpAClE9Vvx4+fzpW+OyjZDieaGYpIw9mVsP/eweHFLybwz\nJJUHkw5FZUiO0JVeeEC2y/Rp/KGXfeOTg3RVFDDwP/PIiW7QV+Dg9piJtdi3\naMWm8krtTPQ0hub2iMy2+uSuSLm0kEDjOmVQbUxguegOrPbEdOLVhl/lMCB0\nvMcanyH6oyZS4nVEb/3bS2gQLTT2e74/TTkVDWhLjV1boUJnnkX0ONaAtBF6\nbU8TKq+sE44NsAOhotW8GG6J49HjhsFC5dVd4AwOaS88zrcHdToTTlZhlCVz\nSZUL0nye4Fh2F7VHsGa60V64L6Cj4ttwSJzSWyWA93f65y6p2oZnpc+92P/i\n2m7GwI13qCBBqgt5QPlMdk/1/FH58IY45KXMlMlGuuo43++KSi29V7QEeMAy\nN8F6I1iSEKIbhv6+6JR8tVDvSm5r7M4cM1x23kv9CPtXT+bykvExzF28Kk/m\nMtG63UZsiHV+eMZqMDl529wCSgakACIhTfpDuaEXrnaKY4cid3sbFLDKVF51\nXcIu\r\n=gvwC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1638324177439_1638324225440_0.09750676996395646","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1638324179129":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1638324179129","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1638324179129","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"49568c6afc6ab49e06b480c56a430fccb5ed1a78","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1638324179129.tgz","fileCount":7,"integrity":"sha512-I4P581hDT9SPPfdyEy2iWSr0gP4FEQUZix2FxsPr9QSdsq9ctq5Dkn1SPqAqQO8e1cT0cJ2utrlxq+iS2veicQ==","signatures":[{"sig":"MEYCIQDZ6LFYOacR0/1h1iQkxgrOUnKOp/eYWyykN5L5Q446+AIhAL0dpbFGWhjRiWbxydXGYVsil5l0n5SwG+h6llEv9boN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhptgSCRA9TVsSAnZWagAAlNcP/3H46UhXuINaH9UsjqKD\nHhtE3ypn2w/ZrqEPqSGQ7IaScjOFpm2KPAdaPV3mocUcDzGqalPjhQm7inII\nM+BOP6VAs2vdyyLx2UnvghUh2NLLGw3NWIwkHKZuNuUnfMfhCULwpeJinzyk\nZriVHvsfVJsTGbarXv0XOHgIj6XJyqpFFh5SrFqgEFkgwEJ6SAJtutFx6YD+\nzE2jWEeqA3MnV7MPs9c3t5PdsADHHylszWlfUTg7ICFnA7/nTBbB1v8H1Bcj\nsXw6AkialFGo42jZCHbUwOlSJxRdBdObkFqNB03MCOR00QufY3sir/pC5LC2\nfInTuAFjafmG5WjHJknxoQhBr2/lZQeKjCAiCvF54vUhKw8172N/nCiPKhNu\nbZwn7ZX0PWLgy5/BautRp0ByOzbTjlsOOgr7WqyTXnOT9DFbZiik4a9ukafv\n0OEl1xHNiFCAXQK1Py1z+XquipncXzIOFgxSP62FXg8ERGFdQE/H6cdBiZmG\nc2wJn6vZWu4CqITaFxnlLGlSCL2Y7ldQRsLuJToFhcQY8I5C1a/zztdOvvmj\nzrzf5xDG/OOCFO1ki1ry0/xiX9JDFFdkKUa/S3iGBWB3R/mSon6lTqt/NAVS\nUmXF/Vtb77OPDJgYTnWx13MkWkgWfox2N9bEGkh52Hr2Rp29MrsepTk9HLYp\npM3P\r\n=FqB4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1638324179129_1638324242203_0.3001044757514091","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1638756272033":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1638756272033","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1638756272033","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"77e1b93f054b2f4341a8dd09d1f79c947596b510","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1638756272033.tgz","fileCount":7,"integrity":"sha512-Rnf4QDgQ6p7SEOdaGyfsStI8uWu+u9HGNwOdxcu8xkDpC7i1Ks8HMr1pB058W0ZB7NHYS42y2VA1H+uQUUnyQQ==","signatures":[{"sig":"MEQCIC2VP7E8UAdKeIXFjwZTQSLhYPJtUBn2TtkfVuNvbACFAiB7JijU1DTz9AliQUGav5dO3W1zdgmML4gcUtIYvCbr1g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhrW/ZCRA9TVsSAnZWagAAZCwQAKBiFSQ/c2wjZNCzFecv\n3XviX+0qhqyWIl5GDePe/VPI3dng6+PAQO+xnPjLs00CyBbMmZ6KO4HkhxS4\nqiHNikd2z9rK9SumuS+KEHj8guO8C7oqRrFv4bzR5vg9XB+Z8VOSQvWffCqM\njN/a067AaDoWuxB7Uax6Bnj5kM7ss5OvR3iQG5aOC+9g3GX2aPN4QrF2FRWn\n3S51OqOtII3IUTikwJAhmu8HS6lSTpdYIyhw3kCWXVBL0LB5PRarRJ1KoSIf\nASa91Z7i7kufon4IXrCUXOGbO47iqcV31oJUfzUmyppf6mns6WA72WXxtaof\nnfKg+OwAcbXZ//FR6o28hIWcErfZSaDLjApd3VDnZdBxkaL/6AAxgP1Oze2k\nV4P6YfFN8Hk0RSex/XPirOyemHW8k3e5Ki5xc5wQjUHmRe2bhZ9T62E9V7ce\nA32oDR+e8BvZPkX4pbQJ3pGEWnOKNyspylV/3NhL5E3kMr43lGJyJrgk9Z3H\n7Ygcutn+ZJADuPeXpVt+74mONookWU804kFNeO6pIcWBDABVZkQiWg8NodAo\nMcQUMCOKym9Mz15uB0IEG/oq7yRFhR2xsH72Y9nDzMaqFv9LF4hnDFl1len8\nsZrjc8fwyoUkbI+CNCPvNg9aI666XI5d5oWn0N+TMXGj4cgY9YcFwxHhSkNn\nLffL\r\n=5wxp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.4.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1638756272033_1638756313655_0.1431996974673888","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1638756271849":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1638756271849","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1638756271849","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"74d1bba058832a8d033abf4eb7f18bc48c2dae9e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1638756271849.tgz","fileCount":7,"integrity":"sha512-XbaIvhq3ENtxu+quQ3ac70om736pyyi1caBDvsL+SrWbTIk+aG4D9IvzXinp5gzjEVqt05w45cIscO+U5xs9SQ==","signatures":[{"sig":"MEQCIEduYmKHY3UZ68AJDZlqYDyZBHW4qevXJMdAuBsvtpBvAiBfhPvssu7whvJCxJ5th3+ZxdMJcnASq0OyEoMudsSXXg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhrW/hCRA9TVsSAnZWagAAL1AP/3kBz0JcfGyFJA46LsqB\nmq/51HCeKPaCuHPyp625Bpi8QkEpCzD5FjbtKbRyZnWhADN8dSIgivjglW58\nIzevdibMSULFRCSzG710yGeVf/f5yNX0T1/FcrT2EUOSPj/qsB834YkuBKaB\n6G+vy9h5BiikK+n8XYqGUX527Dxw0yTbdVz67q33K0VhItiw3j8+QYWeExX3\nSlxC+H1Vrm1XliA9dZfoyRx19vtjdizkYSwxZpqIEpPawrSu+8UJQqNA1PO0\nyitGagprclq2aIXAa475YGoRBlosbVUpl1Ogu+G8SEU706Oqek0lHSv6t/bX\njvKxEs5BVQ+lmn3ZEQe+7aCI9FZEQ9xqmjIwNZP01GKM5cCA6c2mI+qcZR0E\n4aF2m9kxIpT2MBCsEPy+OSQ+w4aXg92FWs1uFl41Z1EoAEh/LhdN6eAXYyk2\n3bnoWGU6QfIw5ZRKfdOKFVyrEQZWVel1VUiyKYiZiJyJvzEs041r7pXJXEZo\nrtaawWbLo64ZXXklomYs1DI58qIc1s59f1a5szYMsLPXaLDPmvzZsSUwUg1+\nGQ33418YB7cjwiv/2hFxBJ152awQ/OFnwqjj0o20U/4Vzs+8wyxtrnIrN5eg\ndt2KpN8jKcclIFgtZztkRQBVGm5/NBzUdBwnyEEwi7GGVVX56r0phJYHFEnN\n9Lqx\r\n=Zzkx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.4.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1638756271849_1638756321239_0.3501671560254995","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1638842660136":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1638842660136","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1638842660136","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4ce8eebc011d3d0febeb05aaa0b701f5871bf519","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1638842660136.tgz","fileCount":7,"integrity":"sha512-eQbaIKULDjoE1hs2mEaFHVOlVcZb0POeEMj+FetFFOed5x3k67gTcVO18MmKNdlKh7WWAbrdKuf+i48AunsT+Q==","signatures":[{"sig":"MEQCIAT1tmR7W0xfxrszL2HOBLhkaKacECrelM2Ci9bYpcJnAiBpYP58CoPIcrBnlK55d+SGEd15knExOHf1tY8m5UOZGA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhrsFVCRA9TVsSAnZWagAAHvMP/RICTk9LgRTY4BKj0Ctc\nmqz/x8Y00oSJpCc1aSsrbNiPmq/qG/pHBTGbaIb7JxXDq7S6jntxPa/R4fcE\nOeGlpOvcSMR9NetBwVzbhjagwG2BP6jA9qqbgsF203ooIF0WECf5Q1Yju1S5\nYuG2J/n/Vwpa0mpfXKK8ivZLJ66XuXv/QDlHYuh9Pa0ssGch7a3ZZ7vmPvW6\nYISmZ1xGYX3vmn2YdXJU1JVD20JhDSVU+yeMSQguPmv5KTkc3FOa0k1eaF2x\n0vyua0kIqMM4WmHbwwumMPzpGYDUlcYPUOLag/3/Wm/M9WtZOKK+S7PZgxX3\n9hGnwDZhZSrFNQVxnkTeFXdRCiBIBRBgint1DHdsYqYb5m6jCK3RpVD/rMSW\neTUqcaZwu55buir7twHZ9FMHx48GCZyUM4wdXUbRp1LyCUyEU7OaizG/jB1m\nTZoTEqpnRQUv5PdO2Uowh/XEnIJIg5tCpPD40FzX9VMhDKHmgr43xXzrh8Ty\nFSw/qEh+sK1XCzZocsEMgsDIgg5Ewn96zA0T+wjAZ57EcHUYf1z+vhqoJjWB\nTRM7PZmhzri/FFHEKkuV7xjc4hNzrb6Abp1p5wf3vdkzIcnMUDL3Nxd97Guw\nGEsmQNolLpHfvD3v5tcymCvaU6/GCt9KwoCsYn0nOXKYYKc/JoFUcVYA1Czx\nii6i\r\n=xSaq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.4.1","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1638842660136_1638842709345_0.9042089065592256","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1639101819806":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1639101819806","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1639101819806","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"16113b47043d424468bdb3fa52e49fb734b9f686","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1639101819806.tgz","fileCount":7,"integrity":"sha512-FyvXiPhwYwmC2BhhcMzdgVZfhn35MKrLsG2qjK6qd9gwHqLqbjPcZjUVRGabArrSHChKR5YWntxPkUwVri7O0w==","signatures":[{"sig":"MEUCIQDUV0LFedDw61gcPxC/NCs7rU2Ea7VseC/fOJt8qm4oRAIgF1HRgnLG9odEUo43bj2IHQza4ON3F+ADcn1laBT7/0s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhsrWyCRA9TVsSAnZWagAALscP/1zqCxZmEQFlY1cIS7L1\nJhjzY9jpZY1iKI4xYdHzEUwjDSmxyruNXTNakq193jlft9RT6z58CM1V9Lfh\ni8QNMi0xfFP6InljRYGlZo1zT+7+n/cDdzjS67szoryrGgvZWJbx+zejJomf\nG3/F0BP45s+xEMTfrYmE96YG2CTxrqbkodfuM65yvg0EuBHAWoTdFCAIvIqD\nrQTGCF6q0mTZ5l3qqc5BYI7ewtlRsvfbogezF/iY73FNGqO4YcXKqLuwaPj9\nscHDDi47BFuhZ0XJ+OPz+MIkGmEE6WrzhA/QFDnud6/lZg5K04iGkSYMscM8\nTxTovP7bMsEiE+rQi30sdMUlr8BWrMs9wvV0HDTagfS+Ijd0fSn0wy9RKXbA\nilMYySGyBMGCHo4gFH+CFIiznPtPTCY9hVp5LCDXRta4I5Vxp0Jo83xW7dyf\n1U+xJbtq8UBZG0eyBIo/Z8Xx5phuoUz4k4QKPkdvQD/7ysifONqltbt4Mvrq\n30j64OCPRJfZw31hf+kdtOhfNCva01RISCB3thWGcjeOzQKtR/zCjaQoixOn\n3HyvzK8n0fhX4L+sdEO/rp5Jn/D40TJsUHhSKPCT95YQdclnlMywOiwvAbfi\nL218QSSFPDKSdXwVt5Sww2DrWCm7v51rnOqtkbzITxGNHtjgnVCQQWOLa/sU\nmYC7\r\n=45Gn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1639101819806_1639101874246_0.9467291443543682","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1639360978527":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1639360978527","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1639360978527","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"96148fec343c728dbcccd07b6df0fe6520564ad7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1639360978527.tgz","fileCount":7,"integrity":"sha512-jfwhCnffFPbxMI63TEl3AEAS3Ed/CcMbRV+gG6lFYsWYFqCc2zg28QEhcLCp8Ofnlb448Y3wbZd9t+ABB919+g==","signatures":[{"sig":"MEYCIQDHta5cT152i4onYrFsNbK4wvkRktd2NjmqqotCHSo4zAIhAJMou+qXUjKXg7S1Sr/7VkZPLU5IhS8eVmH4pnzwLAaS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhtqoHCRA9TVsSAnZWagAAKtEP/3G17yovYU4pUTxRf0Vh\nt2cPfLik/KdSEmOWZOfSOzy1qgoulplYY5qgYrjT6CJxu6i7d25MLrwv2GHl\nYM4bM5Aq1ytmbyCorZ1UDxrcdMB/kJbyixMCll59JWW3t6Dpz7bQgo6lkEse\nM2hfqS1K9glqttwIY/ZmWw5hYcienz7Wc9NmX4XNZUa2MHimJe7mms1QQqQt\n+zRqxRGMIWwyyYGQeZ1fMhvt5ffDuLtKxMSg9XyoA3DUlWQIPQ7zvV5t1q2X\nKIC8XQbJbkB00ADShg1/UKDWFy8wCjdnrKTRHprfnu+kTjPNf2oxBSG0GXFD\nJjxBTTpfZLX6/73uxtT9Nb93wU41RhNrOTUsSqN+crVa2IxtNo0Bgf0+uV83\npLawHxzhDShDRJR1xsF59uTemfVGN3c/iuSJPMY0gWxTCTLCw8vsIbpO2WAC\ndAU6s09zXyMYQYI310r4pEldYwlx9+ppuzJqlzKb4XhGyC7adEwa0F3E6ey8\n2mlN6/BtpSIhk63eGHT164aFwM3a23zMx6uy9kNUj3mXXsQghtDLZoBwDg1d\nzweQ7rxyB26jeconvRsYwlZCUvxDlCq2AYAQDZI8rhDFEAbFRn58Nts8gV9G\n8eKvuzXxHswNbJMcNAQ1wEIdHbbvRJSc5pKWMsiwIR8cL1tWFQqi5gmrQse1\nXiZH\r\n=5/qY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1639360978527_1639361031716_0.22153600339323365","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1639965825466":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1639965825466","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1639965825466","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ac86fb1853d40fb2e803abfbe9d6f40fc22f92d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1639965825466.tgz","fileCount":7,"integrity":"sha512-ZX5+yLc4Vq33PdggrNMqr6/ALQ3wrksHnZwqcwTSORkSsI4VptZQ9d2l+YsfLzwP8q1Arl76PKfhgpx+YasaUA==","signatures":[{"sig":"MEUCIQDjyESSqC4hwl0hMq8srFVWqQyPegzG7wcUxU3Q1fPeOAIgPLztGMZl/G5Zje14/gC2okqmw80CHYykUECGpRJYC5s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhv+TpCRA9TVsSAnZWagAA+xMP/jHjq3tm3yMijA3/9FGk\nWqZkZlHqrXzq3uKJ9e7v8F0D5RCt1Te/nxPNl7ec5JcV1uWgd8aksjBvh3w3\nCdzqHPwEdd3ogmu8Tr0tkc4y4S2yt2X3+48Fl2A17mOiqNSYEPbE2+R3D8fR\nrJL04i5SS8BT3XCSq+dtF/e2RWOnkvKBGTrC0hvC/TxVlvDxLgINyfyScrfy\nIL7vtobGNaCGKUJ/BP8SDHEfevGTtQAoqZ9P7V4sQzf751oPxydHbdxZyCNI\nek5KBcaf0TKQEhhiBCP6uoDBx2DpIDEKN+uX/KcHlFrv/lzuvIZogVdI36QS\nBvtf7jYHHThQLIrK5LOZXtsGXqBGV55R/vyEE1r845xwln4EWYDbCsjYeQEp\njVPsbPvqdVqSw3z7JZ+p6MQgIbqiD4Zt7BlwYc9VjxQNRZYlDgS3ZgWdrvMz\naVob7lIzoFeldZLunw+ooDxLfBrh5OXipLSzc9p6YuV7j680K75eEWQAFsi8\nvrjd4DI2QZcdKN/JQeQUudLtqRuouuBdMgrZDG3xn1LkEVRmo0EQxsXYJEGr\nnBsrAjQ6iDq4oQKLSPWskYVli4+Fv7pk7yLybxV2ACFM2FTM1EgzmCU7pKHY\nx/Hza6344be97E9k9NQQ/h8b2eS2ei3/U/YQDUirG7HH8mXx5h/u9gyGx/jt\npTFQ\r\n=op0B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.5.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1639965825466_1639965929120_0.15020983309799218","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1640570609151":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1640570609151","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1640570609151","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d5d588a7c91bcaa57c78528decf60f317cc4dbb5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1640570609151.tgz","fileCount":7,"integrity":"sha512-58qL//m8+2px0+47D3xR0CxKMuzoNnoIjdTng/yal1cnGoZVsgI/fTRwsXfFUhHGyEK2j9A0bzj4508H9czHlQ==","signatures":[{"sig":"MEQCIHT8+mnTPUv67jlW/oZx2DxHopfu878+73nHIcIaBzpiAiBnt9vBJMT9exfNnocMwU1E5CSH+q1j5D94E95bNIpTIw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhyR8mCRA9TVsSAnZWagAA7g8P/iUvtZ33wQhOWW3nRmqP\ni1dvSSlGFjpry/QXxo713Clbn0x4BZDs6XcsgGGlnHlDZq0pTgR6NzFnusGW\nu+UV/0MGquJ0pZJ4uVGxetOyFiDeokNtQ29SFeQBxJ9XUNIGsXAosUXdQJYx\nbUBjU4XItznd8iLAj4O+cqIUcF9OqDyZ/CFvewxWYCJ4BRGsMTu2wolbLVUU\nSBG3Yx3hB8iZci6YA9TYp5z90kCSx+HMn204nRU0oG/wOA4aRrlHRFvYwwBm\nd4rRDpktf/OG5jHWI/JTkNO0kxFox3aSDuxwJZ3KYgxjQT5GOKfe1odq/54z\nJb6NwxbGl2zoNu8jdkyWwtRxsw/QUGT6yu7avGj20uESqZJiq8J7DCbOjR/j\n3uzPooptXiKgJWj93bCHFX8XZfpW/P1LNgNG6qshWzoOIuwXkdgW57qAVOHt\n9BZrtFifqU7jOhQqTiwCEK2zZ+qYyF4wwGWLSBMUjVByjI04Hm1RXenIl+UV\nilqAX7u43wiT1AH2dRj3gulJWQ1yJfukX0wK4TdyYBaTIVXZBRIg9Xn6buSx\nsXEvCUrdejoM+LpPcj0QgTV5SoAXLJczFWV8wBJ9dRdcmDsUOI/bh/2Kbj07\nLJTQZ58ViYwj3+td5wougVZYQVaG/SzWjiVbkfZslddB8tTDIWprU7DdB+EE\n+mYV\r\n=b6sa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1640570609151_1640570662317_0.8950748719082899","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1640570950160":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1640570950160","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1640570950160","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"523f88f3068e45af484c24235064169ab8f9047c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1640570950160.tgz","fileCount":7,"integrity":"sha512-xB5ySDoP5yfjxkKWz2E7zGLMY2NUeknwHAJl49nmOY3Tn+n+DvagXWKhtEqtcsNGIOFA+1jqSWhqSLgwAQQvzg==","signatures":[{"sig":"MEUCIQDLrG3zGxf6FcKO05ZK68D2FgzIVqiRPPcJkFSo5AgdWQIgAwMFc+d0F9/z/xkGA8LNZcZ+cLRrdxWQ8tyOg4k37sA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhySB+CRA9TVsSAnZWagAAslwP/2S7bDdA/tVDiEh9R4Ii\nRVR6pERHWk06N2vzKUfTMb2a273teGQUel2falG1CNIHYGAgtZPw0rWSY1FV\n/U68NVtquVWVz3e0ps8JSqlu7zp4VbkgXHJIARMRLVLCPJa/rd4kCxOYkQ0w\nwhkjqOBBefmfNDNbYc4Bt1Vi0D3S99tRaGth6nBiMQIychr09aqBIFgC6XG5\n7Gb3wvS14AAfaCO06uJHfLi9xiEwXzac+Wu5mbHqqHMHNyfz5/0dJwk/VLP3\nOyxQWdLzm2Js+7Rq9kxJlmFdRo++sm+Bee7lzcActNY1GNygAi7ZxbGdIma3\nIh69BKe2n2JxHK7nkOOy9DzfU4pZK6zdRKE/HZ2Uq8jOF1OekiCK7thx6rWb\nL5MlyqEV8AWBq42QrMje19km6fUgB7doHduttqWHk2ddmaTQqYj8QRcQP9LY\nz0A2bHY4MkincLe0bryDaYhiA42Re7oJpiDD+/2uz3f3RLULbOs6cczNX1T3\n6qMBaTvlQqmhfVnYvkYSy3h/svBLPCACscQxpDlHDhZaUyu45yJSPqTZpOuZ\nRbCodzs9o+USTCpMAWRY3u1M1a1P96K+Hpp7eDP+UclylGDHgyipgix+wzcL\nRdn9pHEllVLokMeP6RAii5Gm7twGTaxJ1TqoXqcbdvWQXGfhcIXu9P8H+o+r\nUhvo\r\n=Ngjy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1640570950160_1640571006240_0.4418893912998849","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1640916126359":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1640916126359","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1640916126359","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dec23bc6d7490ac250e6942e5cf4c8e1b1403346","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1640916126359.tgz","fileCount":7,"integrity":"sha512-g1gVLG5BaiMhbcrnqnysXasQ83NgO9/7v9z1RUQOKm2xBHNRp57sr2t1pYSaUdbAFjX2kLn6T0WTQBNlvzaonw==","signatures":[{"sig":"MEQCIAhjtSFCO9diF9oJCsuA9qLlE/AQZ9VYbGEb/wRex0JfAiBrMVufO0KWWJQv8OqIzKZRG16KKfrEltSIrARwXospyA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzmTMCRA9TVsSAnZWagAADcUP/1RW9qAZw7hr9hVYj777\nVrcZJ2SyhrdUT85axBUzXwLFtaUFne8YVYPufrGLrRF0/DP0Nc3IFbY60G+y\nM2gLQ6nyTHDqiB2a8OqrmeNfqW6sLfzHL4y1f50anCYjQZb6EjuH/mC3YEvJ\nqhRI+fGn5CvRo9IKIp0urMok7Usn+Reny+l9Cufsm4AmzeRUveHXpJbAHdd8\n9hJczeeoV8/IzlbV51YlZt3+XwCyJ8zhcCM1PEQET6uaeDtU7FA1YWiYSYr6\nz6eJMwrLeqkvLeHedOgmq/B18GRLjMMrBnJwvTsSMIqdon5hjYS0v/+FZdEy\nf6U9xox6XZiFzfS+KviJviZt3h2PceuAqlOhSuQnCJ1HTmqK37MpgqVWSNpb\n3roizR7wJ38cMXQnZESm5h7BcWUQZrKGn4oOYLqR9DgtHk5YlC93cMQei+oX\n5m5iSwmZ1bnzQw4TfPyYxhx/tJzNqe/XbLownrb3ftRR6hb2vJkZ5aCDDgvf\nupUwKREnSoxkuh50d7kNjvk6sACQKRyrweyXy+qAqqkpNTQ2JmBhxgSz33KV\nmVDc5nE4D59K433ROb28phEiU7FjdL6G82CemaDxKq1/CRTpsCsgQlj1t1mM\nQoy7a8J7z467/BN7QNqI3X/oPObXaFUL8v62sj0tCcCe51eC/LMawBswY8iY\njVlc\r\n=VMg8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1640916126359_1640916172542_0.6349406529224451","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1640916124934":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1640916124934","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1640916124934","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"533f5a44efa2b6b436f273d6c8594584912af2d4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1640916124934.tgz","fileCount":7,"integrity":"sha512-C215cw9/Rvk+K543DB7g3wpkpXf2CKmDNYx3CfBwMm+g3Azknt/DblpS2H0rUywp/ISUPMftLcDY73wXNuY9SQ==","signatures":[{"sig":"MEQCIATI3GS4dkJrOKqEA0ka1JCSyNe1gHfoEIdXLGCScmpJAiB15cdWeVDYq1SJddzG0jfLnHEMuKACRA8i7Wn63hOpGA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzmTTCRA9TVsSAnZWagAAyIsP/AhrS0u4yyqVocBjc4OB\nJeYzwiPrvFEz7SG1UGHW9hBViTiBPYIUhWpG4NQtyyoYrhmgOvl+kHgCuXo5\nQWvdvZN6ACgNvClCLQJMJPfu0eMRJ0zMshVBt2uVjOSj4klgncQOpot+zPHh\n3iWSKehJLsTbKwux9VD7Pu3RnKiwa1ds9izzF/9bIum+KajxZ9rWPQKd10CR\no/ajKepU4Dj2/cRV33VErsmAvZ8DmuAYOFQG5O7cicDOiZ/SH695hVDWTNYg\nVBW8MR3Iz6r4vsSlIbFIiZMFQUloenOM4W++ZBRJ+XFkj3qDYhUvlk+H4YB9\nA2B6OAcun5Ub36mW7uInKsUZW1OAYkzfZBx/yxiiPlQNM9FMqPCiPOl9Nags\n4x97ZUnbRcRnk69rPVOz4p64xnPE/0IDoXoq8Xhk3tz9aiq8OyQHfexn7Vp0\nxRLxGYunYOTUECnYRfIqMFAe/XPIRPJphzDsOstLfoQ4Ap+/vv5n03ivJdG9\nwhtJq+lM+mFOzADxl3NaVXPBovHZ+dTtqIBjCaq1CHT6K56gKRQ57Q7I1pDt\ndRn36j4CQubqT9oCskl/Ldha62B+8Ko8y3dkMv3h8Dskbcpja/rUZAnduzMj\nNqqKpKPz5YbPNj7ycDIN6MF3O2uvhVsRhJz7Hlz7smdzpCBLGIceUpBPWWCH\nRYio\r\n=PNYP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1640916124934_1640916179177_0.011007120964373396","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1641175399440":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1641175399440","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1641175399440","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d4e36791be83d3b860cd80760f76125ee7187616","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1641175399440.tgz","fileCount":7,"integrity":"sha512-xOiuQaU6pPQEgCBn5JzCaTYc0BPeD1qDTk7DpKBDmcKqi1TT89TC8pPdfcTUqb98JVYELCDa4BO3X1u7ysOnxg==","signatures":[{"sig":"MEUCIEU0vVICla6PkDxryn1MULuEUzHdBcE0xdKiBmQce7UfAiEAv3Sj4BOXwKQtLrlxxXoxd2zkMxvJUzplYDS7c1RJcR4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh0lmeCRA9TVsSAnZWagAAc9kP/0XLWVWza68wrNV3mlkq\nXfy2PXuM3AgR0SLs1MspBioAXqU6rzOmZ+sAJZUz7+dBW/OWBdBxeQmuLJjW\nI2XXmLcijfFGd0yBPIZFMqiBjdxDbNUXLiKxAZMEELGJEqjv2hIO8LsgD6a0\nof/1Y0WF1+sbuwAQbH0LkTOc4rZZJKMiYl1fcCRwmfJGjUHBz9ZTPKHyYcV6\nSjkyTFnd8L0SGVBT06xD3pVihkZ8r+efLuayis3HgeH+/9CDRYsJj6gJpaue\n5hT8N8j6O8UpPjSuQX6kazrT6V1a155wOAiNBKTIC0ybiXEi0QcYVqVdET7l\nOQ4dKC8+IxPuNBmrT5uOqfOltWpo3iwISg2/elcAQHjwcLXwia8tLmDNn7N0\nEv+0gpkW93PLWKSarFrgEpOvb7GFNpRLAYBJWi1hFmexGdfdt1GpCKJpJ30l\nD5BVzEowiFaF09lKaTKAphWSxfQXnVJeCUF0iNIb4rJT7n5pvys7VCZbVBaF\nZFyn2hyXe+skTz4JGosYzcalgaTrzyM4XeC+DgKkPC0YTm5PEjm8pX3dLHht\naw5OylNKrzVKwVQ74oqBd5hzC+VLu3Vl7V35hrJB8dSalH931Q9DgXhBmc0/\nShy99U//YogKpmFEACGDAhZj3BayEkhJT6z+esHyAsO7h04hudNb8q2dxaZ9\n1lUT\r\n=5mCt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.6.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1641175399440_1641175454248_0.23698062090929062","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1641348218942":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1641348218942","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1641348218942","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"732171795751eb3593dbb30f318c0900fafa55b4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1641348218942.tgz","fileCount":7,"integrity":"sha512-NokOxaxbAntbvQJ6g/tklWgvCJYZs+6mXKlKBQpU2yczbBuuQhczqajZGryqZyYKLC/pjnkY8rzjlxPYEbpqmQ==","signatures":[{"sig":"MEYCIQDppsGLwJwTZwuJPgdOuO1RCQz7/eCq7zg5n4EBHRRXjgIhAKFB46LaISzqeXYMHu+f7yn0yHRX/adL5bdQGedn1ezt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1PznCRA9TVsSAnZWagAAzJ4P/35Ok6vQVib0luwTj/PW\nBKiRD47RyxKfRyQZ5U12xPjF5G5AstacOvozkgsvbXudeP10hynAxjut/keU\nJkC9PmY5ZDkdLafSI1ztu0KOG8BkayZB3JGQlIp6tebhhuHEfHfe+7DgoJl2\n7x0VKeZEWJaMxCKV52qio1vfVTVLQ7SdzB5PiboII1PUrXA7vsq5fcvp+e19\nNo4AvW5HgN9QUc0Okc+cEMJqaTa5XMqv5Q6rDKpi1VO/JMAzMhYrqGnZ7OlQ\nU+7oGPrUtIaSdT5cGC1IHH3uzxyBO1FF0nt+nEaJ1k+p0ZvOJ6oO8a8t1A+P\nlIGlnAjaaETY2uuX8uzsYLt/Vwcp219gnFRmda+Uj4EnEOL6zm+vyYt7dW1+\nY1Pi9IKjXMNh1WAyEk3QHrgMiHW1YeH8ZWV0yQDso6zpU+2N08SaGrjfJgMP\nmL5+rnKeL50HEiiJ7X2Yo0emM3Ka58C8blrWdiAAgnToD0pDCXRQSD+gdIf7\ny7JhcN4DJ2pH5QvS4V3dvof9dlAQA7IsVdTPJ6CMtn+G7eJJCtMTiTv3CEFq\npnia4Ch/t6+A9CkLi/hbTga66hg1KHlABhzzbPzctdTGbb1jRM/bWZURqMx+\n7E7p2lXJ0msfgtQwb8Q9OAFK7iFKSjtl+8T/xJNdsA/CasYk3ef25yrLrbvY\nZe+1\r\n=74NH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1641348218942_1641348327466_0.8813652232714944","host":"s3://npm-registry-packages"}},"1.1.1-canary-d67a93d-1641348219165":{"name":"@iadvize-oss/store","version":"1.1.1-canary-d67a93d-1641348219165","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-d67a93d-1641348219165","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4ab7862eb65158fdf76a318a1d5385fef6b5effb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-d67a93d-1641348219165.tgz","fileCount":7,"integrity":"sha512-nCcSs3zatU8XwVLB7NR6jmYm6Cf0u9n2KhBYCoSzxnudgg8QPsOVLYFa7KVN75PbKgINjpWt1uWwoVk2ZwLEig==","signatures":[{"sig":"MEQCIFxJ9Ss3kellXwlwtQbUj8314cIgKtKhO0D52cvULMh+AiB0Z2/hZX8wrasmqAeeHsc69MLxcnZn6mU5yd6qXlQ9iQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1PzuCRA9TVsSAnZWagAAEeMP/Ag2hm6uXX0TFcB+OzRg\nW2Q9nCyA+1iehSJe3WK3xW3/E+Mjq90OYi+4l4Ex8WCnKJrk+Jgs1BupFVw0\nB9drnWVA58AbwTP/OvWdljUBwRx3xqX3w38tc/mIddHYgE+7X894YAGvo0OH\nsWS8pNzT51UPuOlZd0+tQ99F4wz8ZClf1Hj3f7pP+NQamlOZdf7vUutp/yhn\npiHohPtuY/PKCZ9zNMrE28SgL6hf1m2MdKglA5Ej4JSvyBu3in6N9M1Pk1FU\n2Kul2+0So4HBbeoUYUnNBWhXBlLE0NRy3DcxcGlLU7Pmgj+IiZZbUUTQ0poh\nQ0esq1sQ2k593PrsFvcxHWp50u+NERgq3DJUKSjhel2SzCcjUqF/3+qJjWNb\nZVA/ZrLq/GVNQD9vjU8Zb681JPzVyhAxXMKZGE6yHRGbLPUqWK2AOKnRauho\nSRMQ9jUTwpR+Lbf502RRHtDmOA9M60FlDavjKPs0V4tmfl73aOK/cdPerYI+\n08cVCtcrcb4iFSiD3+nQOFrklg8oiPdl+uyxsc198svCti8Cj2VK8LoO3wmt\nlm4nbn1ZBZgcNi0SYOinj5c37VGina0bQcrItqKpJshIJdQIlOlR4ZCd9IhO\n7apUu9oT2f6UHlzjDYMFd/samtghA1YfFDxwK9aXzc6eL0a38Gvtf0X6Nr19\n6LhA\r\n=NbIX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-d67a93d-1641348219165_1641348334035_0.03350596512113624","host":"s3://npm-registry-packages"}},"1.1.1-canary-f39ec38-1641482194561":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f39ec38-1641482194561","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f39ec38-1641482194561","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"493fdefcb6df7f9e8575a1dec725f67ad861a9ca","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f39ec38-1641482194561.tgz","fileCount":7,"integrity":"sha512-f3rrHsIQFIa67vezBU5Ltudi2D1e9CHCv3cLF4j57NbGwJF057qeVP0xurDaOEJF4wA72dUbBgJ4MA8khiCzwQ==","signatures":[{"sig":"MEYCIQDW4TpvOPjxVxowcv8GpIUq4Kv1fRn0W1qXzbWyfLYRLgIhAMWLFbVhKJxmY5mKIoU/BrtrJ17RuTU/ICpoJSVA4cAF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1wgnCRA9TVsSAnZWagAA4dIP/2cFj51MAk0wZNQetKv1\nUn4o0EzqUQD2YWyaFX6kh96PXCc9cFkNPW8E+/Y1BlGNv2MUQ2OPXd0JiD1f\nee3TMtjj0TuvzyMFTiTOGUIzlSc7vXbIayYY85MaRI6afm7J9wMwEnDhiAgy\n8lBSdxvv/jw0tuCssBZE9cPEDUnmyfXAOv3xCtLkzLd3JyRt8C26FJe+h3vR\nqfRy5xqwp8havVUVkJnNiCcggGrUAgyWq0xXBRfL51i5KmrOwER1I3zXU3//\njCt/4NYY36OZTfXmbgM7m5GHmD5ywSfiXUk8jsSfDJfMN/RiQbQSEX30Afy3\n2VCDGA+rjfssPsWVQF7WRtuI7yNrNXUTvp0J87bnice6SX3dh21qXB/oJGJ3\nCUzCE5X4Cgv1MuwmeMNggctzwYdCBgIlYBzKDV79fkHVT2D+ehK+8JblQQHN\n3dsjCB1xyMrDc0oj0VoXyZRVkVahroUGoMjCFE+D3HvjkLpr1JnwFPivcfAY\nAdxElNVagrxr4oATf2LL9WNHRZfwD5MZ47Ywb8y21WH+39CgEeWDAbpmAWxv\n+voYRWTnsQZel7dwh+OebHWf0fSUgVoEnlo6VgZlk3eECxpnY4bum/1eItSg\n2MoeQdwCpvQ7wuPwpX32kle1TowJmG1y5GGDyaFQLNSpBJeb9ROyTQZOsOmw\nw+QH\r\n=HubH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f39ec38-1641482194561_1641482279834_0.2677142023710921","host":"s3://npm-registry-packages"}},"1.1.1-canary-f39ec38-1641482193379":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f39ec38-1641482193379","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f39ec38-1641482193379","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2c5b777bc3a6b1c2f950d32b732e7979fb9a3008","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f39ec38-1641482193379.tgz","fileCount":7,"integrity":"sha512-SGlde5Q952pwvT1skg9WVxjbnMY+PdPMjQKS69px4LM8BtF2oof8D5V10CQirtVlEEBkyq6UU0w0R55sQYEB4A==","signatures":[{"sig":"MEYCIQCkUzmqzIeCsS+AB1sKGihsUKJKsmNTCvNjjPeyQXO6BgIhAL3NJQh48xIhCuFce/wI/z6L59kud2piuM7hInbu5oYV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1wgxCRA9TVsSAnZWagAAr7wP+gOlSzYy2lUdwAYn3jBb\ndXJ6QYFkXSn4Igg2OAqVcmFvL4/sqRS7ZDP8IKFAYwZ9rqZH4rM9qBSSzS10\nwMThMy0Ej1K+v8wQuhUbsjyPDR0rr4oJ3VECJ2rynYtW9ju0KzcblnFi0ml2\n8JAtw7C0CLl+YvItMQbRgkPp76i8EPustO2JI0veu+WhH8v2yvf1oH/A5e2C\niWPaOAHyrxIoxAnNzHeJ4sE3DfWf034Ee3EvKlp2p6GHxaBCraX1gTjJDtN1\nOar23hUyKti0gAJKjGkffghBLocd12Q/Ry3Muk3wT1IQcqTZvGGY1p9mz1GU\nev3ohnsmuvWO5cGe+CcJx417sKX7BWp7UXY/qHzUjR+wM2WlIRw7p05ICFQI\nC72cHhPa2xWqjO5MhtMb8xev8e2ega9TTziuKiBAWJELpli/gv/zW4A8jKEP\nqSgKGgVnjl3kUkmEE4U4CoygOh2b5CLUTJYnQnesiTPGJOLE3k0iNV9sxZhL\n8s4Uz0HingO9T8cbFGKtgk5OSGNRlR+4wiCr2Nv4neoIG3SdzhyPP+hQGr3i\nuHcVklhKQWSXuCADrcbSl+tfudrMGCPov49Aa0DSZILZgfL2zvttjRej2ASo\nULdQi1aGqYVGNE/oaQKWCok6aht2m2VZKTXS+lnr6wf2lMhWT+2OQweJdYbU\nprfF\r\n=rxZt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.6.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f39ec38-1641482193379_1641482289329_0.41697887145278645","host":"s3://npm-registry-packages"}},"1.1.1-canary-f39ec38-1641482256591":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f39ec38-1641482256591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f39ec38-1641482256591","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bd7e5fc8cef06a9f0a332d5a3711d3f64005dce7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f39ec38-1641482256591.tgz","fileCount":7,"integrity":"sha512-ecVuwISRfd5+yvXnxICHSSBrvDBhRvymkPXT2UqsbgHg/aSC2e5CPLoErq4SOxE2649R0p8UlwMu2pTfbvqVcA==","signatures":[{"sig":"MEQCICXbfJAvN8fCCqy52bu/n5SNxwbUmbaTG/Yhc6iFK63xAiBkvGncIKdwXEA1rVL3BzoXfc8XQJVH/3PQfcWQGiLtdg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1wg9CRA9TVsSAnZWagAA0Z0P+QCkIdO37mwRZcfwduW1\n+ezb35Ox2cwPLGIfNGypF9CgWVAZ9TB/PhYyQJdhdNhG9KAmq58/FZIm6CVT\nMfAEcfxAtiZL7pRGHmXnqBsCwhLDolAUyFFyKT+i7LHLsbMGjgBntPWUbtqC\nyr9oZiYYQ5l2xH69yHBVOiApCYyxNhRRGl6sSSZ5PZJNyHo+Hu4Pu4b2Kkif\naiBcwthBiMgK3vcet7vJouDEy6MptoHPDF3gXAmfgGaZZNkVFq/SBBZXZZhl\nqf6GQXP3LubT/TxXId/Yj8tC4Ki2uplsk/2112vPyrqbOvFid/itGen6EIw2\nJiIoBOu05dY302tY+JS9kZXNB3TEWIcOYIieNHak8OsNiEJSEXTcHgdh0jso\nNGwPYx15GF3FAtY3o7e75RkFMqf5JRe9Zbua5ClHWdYYavITj8/p803eURJd\nd6EBGsh2sQ9xP1AtzWyVdvnpqzZHYsj89Ir1eZByX5hM5RwqMVaNZJkYsLP/\nryD9ZT4BJA7b8cRc2P6ft7+V/lqIzwNyAbtDJSmWQkzHZq/5Os1CtenF+LKc\nxqszsilV3XM/rAJkUagkDRRRh42tj4dWzi0ZLNb8ASzsvoYLJaTJfY+bXhXB\nkAtcMD45JVdM39SlApNlxZJucVZesaZC0IfvZdjwWVm970C1hZsCH1nSDOsq\n2lA4\r\n=b8YW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f39ec38-1641482256591_1641482301814_0.6607452028880818","host":"s3://npm-registry-packages"}},"1.1.1-canary-f39ec38-1641482256234":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f39ec38-1641482256234","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f39ec38-1641482256234","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"61259ff77187811dbf80beac8fc2d2ee9824302c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f39ec38-1641482256234.tgz","fileCount":7,"integrity":"sha512-OP/wd68kyHZsiMXhI9eYruh1+5ajOXZqxVFRGRDpFu31BtH3cjrVPTh6Zw5gDlrhTDJBL36wlQkfOGopPrwJIA==","signatures":[{"sig":"MEUCID7gFOe+mupjst5qK2s9R6lpqR91WEYx/bSpiQFsZz9gAiEA414HZYDkDEoJShRmUe3oBG+3mK7R7e7JqXG4tbOrK/w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1whoCRA9TVsSAnZWagAAv5QP/1/B+mQc2J6oNOElUQly\nd/VuqSibl7ueGsSclhEDfZOBbHDX0w+d6rSA9/T6Gj9br8sNqHFTbCFh+xV9\nF1bMyTd6Z6cbY9nzJhcubcmz9JbXzhshhsPk51+mc9wjofznVk33cOUOGn4o\nimWEYDUpft9LdKQd/OiOQL4VDS1YTyGzhyDoruBD6bGI5eZNVkXoVScbY23u\nSUuNzuTr7fRn8Bjym7DfoX3jUaiZ8NKkRqKoCs76n756JR3j+2Pv92h9fvbs\nPPGk1C5AHNKdVBKS8wxLBd5FTLb6CBBmP7zuVdohqZBNWFSkqlYYcO92o2S3\nz4SU7Yvx/PaNKaz27U+7Odz8NNP+bgvSZQDiZGaE7CGRRT8obIZtpXL7J2FF\nweHDoHOo4pPcyUh0LTAlwbbA5LdxbE4cKupHCtgYgCcCdIuS0tgqZtZmtnlv\nz0jfQVBeAMi0Pk+XOqdSU52GiIBntE8oFz1fstsvXAcdGmaohgd/F2mbQb5H\nfTKV1iZZ1fB/1+PG9nAUnZmHlU/EKMLRf3VppDErkxXq67r1WckUs1g3LkUP\nkwCmh8LXJ1Cw4cxekATBCbU9gmHsfGXJ0bXarkWzSAZvBeGZZJtCOkgvsxQy\nAss+ODqc+tQlMhzvuZrhmcCBYiRQQJYP4/W5ZkM5OB5o3fHXbu4zWitOoOHG\nCgDE\r\n=MpWs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.10","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f39ec38-1641482256234_1641482344116_0.26300963362105345","host":"s3://npm-registry-packages"}},"1.1.1-canary-f39ec38-1641482261217":{"name":"@iadvize-oss/store","version":"1.1.1-canary-f39ec38-1641482261217","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-f39ec38-1641482261217","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f6c00740e20913edc2279844d0b5ea1929247a13","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-f39ec38-1641482261217.tgz","fileCount":7,"integrity":"sha512-m1l+w0y9g934+6t32Jk7x52DJXucH7MTcrzcXHb4W7lQOyGdlfvOm1BKCSD4NdB6spPPfGWrVftnsl0updKqew==","signatures":[{"sig":"MEUCIQCg8KiuuXwU7mxuq4O9HiIGW9LucGPnrQeem535RNbiQQIgYjq164gyk+EEiCjy5czhJFSdxDLhJQLUt4w1CWmY+4E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh1wiACRA9TVsSAnZWagAALokP/A0z4rb0fYNhHnTX74f0\nxtppqDYjfpFy9QQr16deLGfFkaqq6v2UjtMOLnR8sfOqFzUekGNKgejV0GRu\nU5ws6i8ZVdUPRO0SooWsit2angNP2M48MXTDTy/yff8VtHYU9Hao+we3yCWn\nSNK8TM2f5SM/y+5EIfJeyFEpnXNmT9FAtz5raSPcfuvx3NSZtRdev5/dul7D\nbJyVogRAg9+UY/tSTueLz6/c6ZJGCB5Rr29bO2+5vMhIKWv/sNzKWUcZkiSC\nxlAXECsGZ34Mi7ztIpbYguh6uJbgX4wSXPEZzq/hmcIbzm3JeM6UVAEwVoRA\n+z5rHgSkuLZrpYqfAgsM2/2InTqNRLQEFqsBQQJ6nfyTuvvcAlOJfrrBXQy8\nqabXvIBXDMwYfP3lshXcKuYgihfZTsE6PDzFVSpEmpvK0YgUCL1dFRsTOnLa\nKbDmQK4+/EGLX4HvszkDn67PQczL/4Cq7Qd+aXwHFEZKvEGs4Foe/H34UIvk\n0Niq3m8FW4SAcLRweHb85zEVNbVHQoka/YmdtXI6RGkm7vgJk5SInRN1p94K\nKZFGFOO8WKHEbL8buPQsVIl7Y/FIu9HwuNryS37Znj5lu1NJl0g/ByBnJ9Ab\n4V68dYZvIDw7zBK6zNMLvTpJTSpoHyxbCcBeap2ko5wzPZlIYoHLbLkJarV+\nBJrR\r\n=2j5h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-f39ec38-1641482261217_1641482368803_0.6422022616974121","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709774650":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709774650","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709774650","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"be077d5c3ff9979da2a1fc2df4cacf7495bba18c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709774650.tgz","fileCount":7,"integrity":"sha512-LnF+6Z1CVrLXMqAEQPZ2x3vAZCLQVc0bMO2I/NxXiYiNU2+cd5DqOXjV/nsKpZnUnDzwdxYeiXtE5CCKaV70hg==","signatures":[{"sig":"MEUCIQCv7+gItdtdUPkjfiz08dv4z3AQJWbLglOGcVlNfnwUygIgG+ns6f7qLyyAOFPGF26cE0DOdOHSUqUykzMjaQd7vfc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QV+CRA9TVsSAnZWagAAN68QAIrsD7ODuLujIR9DAEMY\njURXMo7jp+e2iyTYe7PCXF/eNQ1GheQ7wb/zGCXQenWps0/3Y6HZxHl6KJVW\n6TvOuCnJS7xdbOsV+kN2Fz9OBR3IW5xHoEVMwhZO1G6EfrWxvLvswrjdSSbi\nXEweGH+Hc5MvHjRdCxZhktOGcVJOw6tIypiIKb/E8oq2llfJbyKYXC4VuYId\ngvCZghhvunwdYDt5WHHCQb9xYJjPfV6JQOP6k6Jj/Fc7K6VZXwdvYwVJ3GSR\nOaJa/trUAU7SPn/SoCLsawpT5g5DnG8bq6l0/lBkEo1mbb96RbMmggrNZQSJ\nd1KiJ0q1T6FDVqBCgU2fA1yj448vf3k45DHSM07D5wE7AxTI6LXukgXMLKeK\nngfjUnK9V5dxeAda20XSZVFxIsWyinaTEVGQl7GWRMpzxoTSrIqf+1dpHlH8\nZfdOwJvI4A+YhPK3pEzkktyFVhFWoFxRV5gAAaYAROEC6qthFNd9mslo3GSU\nUmOePdwFz2Ip68j53k1O4qOIb8YJYEeB99RSuS+joA/RVKU5Ew1FpSlUsy/X\nV6fi9Q9LRL1MhYMxAu43RZfzGRF5Equ7R3NAy4VvyPa3rCQJqVdeFo04AjTK\nHKrLbs8v35jisoZdaZy0VuuSsva1CrYDbyHaaKpRO7HBU4ToCnkFnsBdLRG4\nfZ+P\r\n=G3X0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.11","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709774650_1643709822199_0.3300465508706385","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709779366":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709779366","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709779366","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7973c473984b710d414c77fccb4f353e6048fd65","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709779366.tgz","fileCount":7,"integrity":"sha512-lVVYtb7wTok9scrPsB6kgKhhTtVVfBwpvLWO2sGDODHKfs6VVJ+DlGJl6M4D9xYJt/6wtAS9JMaOl5oSKTuI8w==","signatures":[{"sig":"MEUCIHVBiZDFWRR94liCWf+dR9Une6WadqOzsm+kbs1dQsfkAiEAtu0Qo880xCLvE+fFBrAmRisMSRrZC8Pazob7ssoXO+U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QWECRA9TVsSAnZWagAAGQEP/1u6D+aG+96o9Hg+uvN5\nqchYk7/w/md2h//AdUR1X7Aa2BO/NckbITEmcQfTi/g2XTT0XaTxEVhdPtlQ\nnNccRMPynaX/94Ad8jFhLLNcv5sKrDVxsfyiH41Jy/6QOKDClcgfOjcURRww\nWUhkfekUDqraCN/jaQzLM50viST2lEHS+ihCWXJfVVWmziP9o4BDSTDUaUYQ\nunATZ0F7nCehKj71fiuCI1Skcth8531yPI3vHwR0VlaNnCPrnW3TMsYoTrDy\nGNIGAhb85OXkoRUljSvI7MMFECL3xDqFX0rFzLhBLa97/4e1xB1gVAWzJNZ1\n04hf5Xy+IiRkYSHmucgD7NxlBSF1kjyu7xLH9fP3ERxcovfEQ0Oa8Aj0gF9W\nZVZ5/DJYCn3QmlOqN07ALHD2pw2wKDn4eM6rE7ZM+4lvwpHvhxFF74C8OnIZ\noFJKiLOfbjyCSBvmog4EHmBae8iGFB905t9qSNB6DvbqRdfAwZ2fSK1meWVA\nPalECFPT3HtJ6o8gwyHHltPAI1IGuVo4UE73YllgFW6NV3dPdtAhXdw+Mq/E\nItzh8ozuA6CcKYLRQuWPh1N+zAABegk08ZX1+C7x+XAzy+XwQvtceRHLwRdi\nUaNcB78ygYlbnYTjp+oUDzIKFBK3Xs/aK614aXrEvL2TgJ+V2wTciLlppuGf\n+EQ4\r\n=npyv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.11","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709779366_1643709828300_0.27109879894243094","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709792622":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709792622","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709792622","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3fdd815597aa5e9e58798724896fa43642341f67","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709792622.tgz","fileCount":7,"integrity":"sha512-ajoUYnDjrhGCVHBuZX5dNSXOJFvGaIFadIJOu8PHMfsJvg+Jw9iuOqXd8bcQyWC9ojzlKAaNuMYnPOTPvvbP2g==","signatures":[{"sig":"MEQCIBd2QDeQ5JpS02ykrUJYt75eu1K4w0+gFQqTZju5l1GNAiAMIjSStfpcX+kIwLZHvkNvrhCrn9nolaq2G/jHyzvIZg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QWZCRA9TVsSAnZWagAAH/AQAJcK6md82NmFV68i7CTl\n0Q6tB4GTEMrX4ujnqOGoBRZCwnOAjcPGBLvIVNbclZ2EFrGKDDp5lPI7SWjV\nI43WItmXdizYEIqjOpALgNxAQSB0jcM1YhxiOyZKkgTkkeQXl1HW3KGUdGM4\n3tooT28oKDuinE0xQ/sfhDCiEez5nLYGyM4Eam2GpNPxPZtmYKrn5B4/m0MU\nWWmfKFrBzDW8+8XKj5N1MbTFVwWdrC0FHvZgdSTxtraUTYuvAfGMjDg3W69M\nNsB+syu560gsz0yhVhurAomAjv9DkqM2NGAUiafd6P2FoSxSbO+FgGs4Z+Wc\ntKnyVYRtqABON2mvMpLgmE0fdML6Kr/YIsmssLjBmVWuUWIKYYq/GJkgC0d9\nPIa8t7BfJ+VD+jiVcMyO42NalCy9hsMmrAhlescSQSeT5vdYjOZQOirtgYFC\nxNnQRxg+2ua/NrvghxqB2csfaBeI/AcwmZIvFNB/7FA2ix/0+IeavpzAAcuM\ndcPHy2gGpR35M354Y1zq17cMknd1hHu1bq7R5MrPJ6KdCWzgZTn2iV1B7Bo4\nFpEPem74LfHhYro8sS3uzbWYmE5Vt4dXzCJz32/qT8W8EOhenCKSi44j7QSX\nfiP2FzEGohruMihzU4ihK4v7rgCuIfw8yQ3y/wIdHpqFJltSrxcVenZ0klrJ\nhAbN\r\n=e3nd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.8.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709792622_1643709849771_0.5663051592840758","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709821001":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709821001","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709821001","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"801991b562477b4d5f17c49b537293bf7442787e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709821001.tgz","fileCount":7,"integrity":"sha512-A5Nr+Xkpe+Y4U7dUu0TUkWcYrKkZuY2fNBJwmwB24n/Pa4RAMWBhKr7Xx+0i/8AhXTuLpPgiA0BENYoqt///ug==","signatures":[{"sig":"MEUCIQDJmUGININJz5ecQXCMkbuG6JU95ZzgjXgP/dg+C9dkbQIgDMTZF3vwWSOkRlLauh5U/+DMxv6CYJo3G00DeTlBKmE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QWrCRA9TVsSAnZWagAAyMIP/1uKGW3+SdYA0MsjdN21\n1+2K/Xn4tNGt171leKC715NPLru5648Ns2EIoYrMpIa/Vmc4V2bRrugLS5xt\nRq1tQ3v9R291ObAMMmV+x696kdudjqrKyDMy+9bf0/O+2bDHvnW/NZaQZAqd\n7hrL4PwvOedechfAvBLVM93QGuG/asWt2qu/C8TpETaaY3oruLpcCSUeqhAH\nDwmq4PcRWc+EznzD6MyW07SfKJnF/05qGHJDtZ/4z/JHqxu2gsyx/9+btoii\ntwq50mJ+RkYyA1pw22+V1SFvzOtHWUMnrv3ARkUUlwX8Y2U7oInc7ePFYnd6\nm4b2OXrfnqq4aOuMelLGcL2OXCuaLzn1PUikvisYQF1bH8aHJdTibeoJc10T\nxVcnN8IG1kJHa2fGthE122lGt4/pqp9o4mKoxV79q+Us3Qyhl9m/hAI7lsHo\nxpUKBLV9mRwzHPShQpL3en3D9ewIm79ujwzlFiWNG6HaFSEPBcsDIapcour8\nHffoApDSAD0ZuNHGC5rd8hyB4sbAFmF/RJh+k5SaCq/oXdYZdlG7jE3Srh3j\n1qqwPe9SQYiTFqIJ4/9prxn7V3soudcp4IiMoRORkp7ByzpMnRMcuSuOEBpg\njyyW5TWBILv1vFtus6xvMsDC/DQrl7iqJgSU6g26vuFK9ZTrroVgIKjPXpAE\nft+a\r\n=hjBn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709821001_1643709866893_0.6917238027262493","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709824511":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709824511","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709824511","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bb430b1e55c37d4224d56b05a76d36e70d3f3cba","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709824511.tgz","fileCount":7,"integrity":"sha512-2+tSGShNKlDZBI+Blb+lbDuN6KNyVtXg1DTQyCCDmacp0dGQ40nVnJ5hvqVfFXVGYVXJ3WkmXQcPip6r6itr9Q==","signatures":[{"sig":"MEUCIQCPXl45/ekB2gLqv3UAplXAILXnUolClLD2Kgh+VQNzPQIgRAkVXO0euqcswjECikoGpTlLGtOGOXPza/W0b5lMxVk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QW2CRA9TVsSAnZWagAADEkP/1+3h5ogD7MEYEiX7pu8\n+ePz9tADB/2aH3pbvT1v1k8s/sZJhRIQM93Vm6wbfBHibd/5zrzc0OCuFqaX\neZdoBTc2E0xiCKekOyI5wy5XBd7gk1Dm5ESTlfzdxMtms82xcYo/Y090b80x\nYFs+XWeWgrc3rqag9lV76xVwm7gB3/t3bLpnhYyMvUeUGuNPmUjA6tLv3QQD\nv8n3RxyNmZNSwBJHQMrDQ948af9pa7EEYtR83Da9a0TU28NjK/UccWP5Nl7V\n4RXGialDOMODbxqyO39sKDvxIqGZj6tB1vPyiOf9IDnKT6mSDl/H3SeRl+TR\nF5Bn/FmTTyicyoooCAJ1cnydt55QMX/yVPj5E7ynhKxjSA7vLj3fH2/f9K7j\nuIuMT8V0sOKrnktr1/sodg6voM55xt/maQDkx5yaP8pwgl6hBY45oaUytNzv\nrNKE0QIJ85B20m3hK/1rzleezzuyIx3FZ1RwgyGW3IrCTa8V/rNkzjipVPTB\n4JIEwyoax63SvgVmw8DfkPGeGRAWN5zvu7uotF1ccnInf0DAkRpBrL10grkT\nVAjOQVQa9wE8w4s8oL6kQJI2rvN6GfHR0Exll3XYT8x/YRNt5Xf3pFPJWkay\nahZWdL84uywdcaphqC/hMnT8nvQ2sKMCPY9zAOoDCXB9gdFTlrytVvxGeiAh\nk564\r\n=+AfR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709824511_1643709878215_0.051940365294880886","host":"s3://npm-registry-packages"}},"1.1.1-canary-10271fc-1643709797463":{"name":"@iadvize-oss/store","version":"1.1.1-canary-10271fc-1643709797463","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-10271fc-1643709797463","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b9d41d7cdfde13b31d99ff98eb86126ecda5603c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-10271fc-1643709797463.tgz","fileCount":7,"integrity":"sha512-HMByY0YO7YQiwEvBGYAkOV+eaHGMUZqh2ARX6prC5kSq90BRMmLfLZNmPVpd7hGB6O+jVfn+psqpr7rKgAw2mA==","signatures":[{"sig":"MEUCIGfyqpFTfaTYqb0tUe3fPjZr4FEtZ1p1HsD/WulDGBvrAiEAgCrnlq6ptAzXUv9wEuHzIDonh5h17u7kr7+/iBZLM8Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+QXRCRA9TVsSAnZWagAAJTwQAJyvjmFUVw8a4Vqm32wB\nrfZcoKVN64ZZBkOsnO5BkxyJo7ea4pQUzRiouy0P+eGxAgy/6vT66d2zpjIl\nn0cVQpmYj7/D5LIiLIVrSo4lBx7C8bZHMoGHjE/A8Znz5Z0sTeqexBd7B4jx\nJA0NI63SAI+Sq3NlV+pVH4VUljNT97igqGGRPyj2JWGdK2byBnKr5wikQTa2\nO3RRxrKgfqV66xRQX5dmaIZ8a7M4asvf9QWCCc4kPTl/v4KpyNIOz9gcNidr\nHr1b3U1gQWglDpu05lBdMC1BQTe3kc5UkX7JBKJ39/xMoZk6LfrV6q3IgSli\nLSD2WviLAI6Fala2HAVtfO4i8KRV8nz3xlqcaTREkiW70aqIyzV33kmQVBgD\nW8gbTgIEJgnJmaMB5hwiAPRSG/r2vQfZqiSu5jZmvluLe0yvaqGj7yxOYA2H\nu8B++98qUPKecbenfO6KbfApQptKqshbmsEoeO48sY7nX3/8p72B0KDiNvi6\n8Bt2itsRIT+K4WDj7PBFCc1UzGcu385Qqzma3b2aA1HSOO219Ox1nzXmN+Wc\n+5aXU2GSEAGQ0W21yyvfgtBCehe+BVQeOZ53Snneami1vffHRDPbAtUi8oiA\nwyE2dVgbQhZtAZj0YRUPSZwpTsuFpnMAH2w9h3p6qkUm5GAe8n6uXi9HXeJj\nbeCg\r\n=kL8T\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.15","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.18.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.8.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-10271fc-1643709797463_1643709905184_0.26881425696643335","host":"s3://npm-registry-packages"}},"1.1.1-canary-76b1459-1644906996486":{"name":"@iadvize-oss/store","version":"1.1.1-canary-76b1459-1644906996486","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-76b1459-1644906996486","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dcf23fd33a0bba233269c5a7382346c3cee7f28e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-76b1459-1644906996486.tgz","fileCount":7,"integrity":"sha512-XctCeDytqJx+JLRJl4Ekh9gJZ39bbTQgYgO4qisYvLJNVQWvzGhp8q18tvuEYM0NhS3bWfMOuHBNm2Tk6LmX7g==","signatures":[{"sig":"MEUCIQDPT4zctgld32//GPmX3c88nsFaG6zCSfU2AweqXLE5egIgebjOkH4MnM83KI1fkv620HUYoQWn2hKKQVTlnknej2M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0rECRA9TVsSAnZWagAAibQP/3Fy+/McBwarqmvgu2nU\nPmZZjMHSl6U6fJ8Cu2+sk83Q7Xn3aItucbTpk6woVpHtVj+DlB1pxBkruHNq\n9OF0IXLo6U3pnilyeGqQay8beaAS+zlNNvL6dSiRKmT4Fw4GUpgOwPQrWGSG\nNUaNg4Fo3LQ6kM3X4IyyZGux259ceLhw67WTGK/JZtxjUqrYkrToDZAePil/\nmDnTDEnzDGlfmvIEtLQB6iu+cp7Scwahl2HVer+Qjg7s5OVOpJY5BWcONovy\nVMLM3xy5Q0n2Uvn+dftqaoxYRS2QJ2SuczpBd3tM85ABRfAArxL5PSJLFt/+\n1cVWNPqaLLbjd5g82/nknPVvVZH/Cp7XvTZWeKrpDPD4+HJOUpa7FDO+AQrU\nF7VPmdPEMljVC5mUBAC39cMW9MzQIdx9zPKsxgF1FHWWQ8sStJ99e8xlYw9G\nLjLl0beJwoiRJivsAaa+5LLEOvN7RQUIAOsfGeayIr2jJJspk8oOfFSGNe6W\nNo3WDnntRdRphz/eVJnCQ6Z3JvM/RojKHdVRYozW3eABXvZu1PQM3g1B69lj\nR8QudVf3VTWSgE0A/T2VgaiApGWa1Bwey7VXjY4QIiua0wNYyMlxRQ3u1asS\nbX2B7mTG1BFrj+HRXFwy5dg8tgJZKQRSbpIEayfKO9DP9S7d/WpnZw9eIvNc\nmRKQ\r\n=C7KT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-76b1459-1644906996486_1644907204236_0.3477701364268233","host":"s3://npm-registry-packages"}},"1.1.1-canary-76b1459-1644906992232":{"name":"@iadvize-oss/store","version":"1.1.1-canary-76b1459-1644906992232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-76b1459-1644906992232","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fd8bfd4949b58856a6332e6e0e4c7c5bbabbeded","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-76b1459-1644906992232.tgz","fileCount":7,"integrity":"sha512-Cne9jBORV854RICXK1F5lELaROSL4bA6h9MB3HAgG1y+Q2QKsKPmgeLrMGeDsKRtVOrkV5AsOWx6yT25JlAGRQ==","signatures":[{"sig":"MEYCIQD6faJJRinRlmsyl/kBcNvD1YyhLXey6f8N26py79gfjQIhAKbLYPG8iUqq3IGXL6PWk05h5ZBHtgZe7Y4ducbkfCk/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0rNCRA9TVsSAnZWagAAjFsP/2p6ot6Oe/MILU9x670Y\nXOCFgFotG/XLlBrq7pb0yMPKT0weMqKZOQ05B1n4Hm9HDgH4/PN7gMttteBf\nA/icVe3CsmqcbzD2AxnnL99TtaBFBrRVSJfu5VnHCIxtquFGF40J4veEUuW5\ngLF0ODPMmmLkJQN+Ge5GrWLjrATQMYxQR/nWifzKBMr8yHTbWWs0+ZiYPH4O\neUe2T5va/qiOXQIOUf2cSZCBj2CISat9foPfqA78x5LAIXvsCwIbiZnu3fjc\nSbNU+1HCOF21aWvdyBfxAZQvuDZqo3n6iWY+mBWrItJ/ZqvWEzGc1gQp+Omh\n8EGJCptn8twums9FlbQIO1sf1Urzj+0oJd4DiwPKs/D+RNRNtGRIdE3j6fh6\nqMkQ9ju3s/Yr2nHOxPSxwot7hP9ppROJtS9BWNSEqkvt4yDOuvzchqaodo0w\n+/dSDo4I+d7EMZQCS181fb2esXb4c4Prgo873Ks4JXti7Pzi6tCxC5c1km/R\nzLj2vrfMVRsxfOq9Hj4wSlF2hJs/s0j9KzaOmj5GnBquzLEq86MqLtAQMtg0\n7nq2wekaLxG7+7Dhznlmu/1d8d9/cgWgd+MUTsY9nDrJFO1OSmk3Dy96F0C4\naZEBk6M/HuoiWFcmJdYUuB2hlrZHnqr6WxxhQbXC66rH9lLmoqEjc4ymxqxx\nW/KD\r\n=sK1N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-76b1459-1644906992232_1644907212898_0.09559769903699378","host":"s3://npm-registry-packages"}},"1.1.1-canary-76b1459-1644907185928":{"name":"@iadvize-oss/store","version":"1.1.1-canary-76b1459-1644907185928","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-76b1459-1644907185928","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4f16e9ca7fc24cab02c87657faaad67c368043d1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-76b1459-1644907185928.tgz","fileCount":7,"integrity":"sha512-SUqc7cGp1kj2iqcMi5VXKtHtgIvPaD0cwaIfvCEI6NiJ+7UFzmsdqk9I/WYN4lJJCqHa+PjoUkp+FCgwYhBv9w==","signatures":[{"sig":"MEYCIQCG4XuQktSpghyuWLTzMwn2PZC/tqP9sO8MdmZq15iQ5wIhAMkdL2YanOKTNa/CDdkay+2QeYUFMAr2wogAHJ5bhdJ7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0rgCRA9TVsSAnZWagAAl6sP/1TtvT9PArFAIeUl6CcV\nJEgn43nsRLflqzbfbO2dRyilVz0dOZ9wF1JaicGhyPhVLUfl3OFuNGQMhb4l\nnTaMokszGZNWtNUGCJh/BwmeEGuCwVwfmnwmJODmE/gEELzlKYbV2YbG23ju\nFABGu6oowg4RdvMTQhCjsB8EONzMhK5gbRFwW4yHo2l2wRQfUcpBsoSY/ezT\nfWBIYyWkXUcdepGQbc+uaZfm4rE3cWnljualPy3H3BaX+S8xXgMcnyPmC6v+\nR//PvZApYMg0do35I5W9Kl/bG42qD1NzYR4IR9cB43NLnPjKeyIAQMRtD4OO\n2i1EFdDl686GfGJnUZE5ZBQnSKium9eaCgakDH/hS7AtRiYUW2P+oVaWwCGl\n//cVhWlzjyvjLLg6xD+JdRy9NqXATnMWWwqR1XpeG6G6oh8J6LuOZ+qquqtH\nYsMqZ1m6UR7CLtV7cSJVwkH18ptxCwR4YtAKK9B7ruhBmkcYZOWyawiA6UoR\nc2qObLiWh3lluXtvhN9SQkK2QDfSxLtAzh01FFvSC6B0icQybEkjetBbo8Cu\nQ3wRjC6btE0kPIQg4dO3o1Uc/jUFeUhQ0c42mo+OSSbeHV+hEDievjqpq4Uj\nZseekhBXLyYiH+dsK/DvFZbeeJXezLkahoBvETuA9fSuucSyXFL9a0gi1x2Q\nhAIf\r\n=l230\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.11","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-76b1459-1644907185928_1644907232033_0.6508798232495039","host":"s3://npm-registry-packages"}},"1.1.1-canary-76b1459-1644907063756":{"name":"@iadvize-oss/store","version":"1.1.1-canary-76b1459-1644907063756","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-76b1459-1644907063756","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fcc8f67da7654f22b5cf8527a4ffef1d9993a5e2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-76b1459-1644907063756.tgz","fileCount":7,"integrity":"sha512-l9Va4q1bE6myVXjBbMGRw6R+d6tGsKSdco0zmsPlLUF1Jc5fDKMPu5UeFc+CmjhRjAU9NJKsDJ2inrpybiiVbg==","signatures":[{"sig":"MEUCIQCwPkU9Ds0P7tpb0FPOglOV5Sop5uKN9y7xMa9DycRbxwIgOe03qhSmYeGcmY3KC0TL6hVnxX+7THEoGWA6fOWhpPw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0tCCRA9TVsSAnZWagAAqNAQAIaNVaSedvMMNXiktwHW\nnqIH1JMqeKIXgEM4mPJy/+iA4t2IDvFfUujg5sxHpO+UcB7cuC9GmLOKlccQ\nXHiIyf+/QyXaHLEfDsa3qSL06Hv5qibRjEGAHUzPvxstY4LyYxxXGS3zZ+pN\nUDKRUJlKIWciZCNA1PiK2/6wg1kPFdiVQiegJhz+mBQv+2h3eavNxZoUkSxK\ncLK5/c8BM851aRGYCtsz7e6teIuXtVY6gOdZBO25oR5+YSWDyEDCZYQ2zHvO\ngPvWlnuusAw+kAPx+eYzeRMc0QOVK/lmxo1DhaEmIoPD9eMpHO4/ghSvI4QF\nW5flZiJhPkpQLhbfGZCRoGvslJf8HpYRrlhz7+eAn2GVMZTrORSReEfBBfix\nm4/PHdJRgYSADFY2wpze+icgXKBApw/z+FWm6BNcggxc2jOL951I4BfHKndB\no3EWqPc6bml8jviwolefGlIrrzWqG26y8psCJudSi6C9od6Ym4ydtehRaM6r\nMKTP6muvEpM2QsiLI9wA3nGLuqYQh9J8BER3MINjauGBaq7NaE5gfRqKSBVs\nsNsZpL8HtOH6Va5AXmYDmGAmpot/wKoPuMmXbL1I+NLPK/YICiBW9YAqifcY\nDxsDs6TMQC6BE6yxcNqlG7ES6XdUhW2n+hcd6pwMxH7Lqs+N/SFg78uum6Nd\nCWK/\r\n=Imnx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-76b1459-1644907063756_1644907330560_0.9841378942756973","host":"s3://npm-registry-packages"}},"1.1.1-canary-76b1459-1644907132861":{"name":"@iadvize-oss/store","version":"1.1.1-canary-76b1459-1644907132861","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-76b1459-1644907132861","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"69295d6e3b9b8d4b68a7c1301a34adde457469e9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-76b1459-1644907132861.tgz","fileCount":7,"integrity":"sha512-hSdleXB2FV8BtsyXVFXLx5O7xotqsTSPLGYRLdhJXH9hjrH6dHw3j6S4ewEqXhi2wx+L59rLQqpowIdOpMkpOQ==","signatures":[{"sig":"MEQCIFVy3n1rpU0iRSvJ9EV4LP6GjXQQNDP+kjbY8Wt0kO/nAiApVDpS03WEgg0YOmfkY2TdyCak9fAgfsJ9Ws6yXhGBUw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0t2CRA9TVsSAnZWagAAVWYP/3uN8M3FCGEtX2wlS6kn\ncrzc0i69sB3dgflrDpkTrHFOCatbww2xrjpwPDU3FWLxG29o3O6a1zeUfcq8\nHNKaGtMAoIZlEQrR2erFv92207sT7bcply/ijTFhr9IgAFJ7bKvzzBrD2hwI\nZiz782UeRvOpW3rk9IbVfIL9VzKwVsufh7+4UyW7KhbtAKkMciIXu/Sy9DOn\nYbw/aENAJV5yHHux1VLMY9302Ffljzxr6CSwNa4yPAOT0FJBx3ypRneKTrfa\nJ2u+bYsEEwHE24UwQcyqVmIEYYd3jaSzrhKHPqQNi2wlUjPTZtb+kdP6JirE\nGxuKTW3g9C+RxSvJEE1K7v7ywjLLwkJER1BfgKzk0w/yUo1grrU2KA/NgG13\nLqbyRLcJQjFw05DiteRs3mp8Ok4KOVBNEoblsP2vpFWKIP6zrJ2JsPRHeMHg\nnPePX1Vdn6Yk6Zk8Mm/reFkZukHUA8zvbw5emNe56IXIjmSIL1PlwqOGnnnZ\nv6FG38aVSPrOL0BW2PySUxxDk6Lozva+rVlIkUXQbstyH3icVPr6biUXGujU\nqHJXq9zLjnH+yGQBnhRD4obksOTq17wnl4PvKMt9xCmCiYpddCICE0EvG0Ul\n5lb2EVL36nOdbOk5FnQS3JgJ7XuRC6PdrOoTzJtRzaKpNRG5McEbcuiZCnUJ\niwWs\r\n=s5ln\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-76b1459-1644907132861_1644907382513_0.3963097353212057","host":"s3://npm-registry-packages"}},"1.1.1-canary-0adfe8d-1644907190688":{"name":"@iadvize-oss/store","version":"1.1.1-canary-0adfe8d-1644907190688","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-0adfe8d-1644907190688","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a8a47eb4a89473f4c565313aaf725b67268c4a34","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-0adfe8d-1644907190688.tgz","fileCount":7,"integrity":"sha512-IpU2eR5O1yprrbLUTk87GTwlLsGglBq/pkLG11Ne+XeIPVFLoGZ5aYzbD829/BT8J/O4WH4ct4iSd4zRf4BoVg==","signatures":[{"sig":"MEUCIQDHK7aT2D5g6Ik/f3ywm5b6tXCuMvGleaepwv613Ez7mAIgT/x1frEe6sp7KQ8MGa9dsjQ5n466k7GUa9rsRBGLYOI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC0t9CRA9TVsSAnZWagAAUhMP/RXshvZ6Fh/1MS2xiL6Y\nWz6pGZZCjslLbG01bMZ7yI4dSskevyVVRqq/eKzAULlR3QcQwsYOJcg9Rka+\n2vujJEmWUlz2I1pMYOAMX92ze7JPwSS9Pto1xEytA6qyxBJd+8rv7kKmXn4l\ntcwzEZz5Y2nObykkalhoQVs6F7701fFm88xod9B19XaR14GH1akrJBuLUOaQ\nECjFLj0qKH1k85jVAXgS38djfskSd73PWAxWxpv+H7nAI69HuIoN0Dgjilfb\nD0e4rEuTqeYJB4wiAFEnkAWpA0qITCiguaM111H4x7shSGgROh9dqpW+fGMK\nnRHNI+AI9pcpkl5tTzveHJuuuYyj6TlmD3JuW2OlMMCklGud9cmH7FPgES1N\nV23OPsk+OjKg5ts0JMmdLDnpfh5PXvlii6sQswghqbyqtaQNZz7CCo9+ELJl\ndWio/9dpobwKVZ8Krkg7IXGhkK6qSS6xIbGPXoFketCPhVRf5AGgR6wt9G5K\nx0rhq98x0z0WpR8bpfd2De7V9mC+dqy8eZG0ZMoaUMUGNxuCZZU1MGA6h8xH\nQd1h+qf2DgEy3NNXlijWkgm1ZLGIoKnbav2i4V1UrK6CE3fbdX0IEN/gxOk4\n6PpyoI03ycfifCaTd/Xts0WV6m/Vu9MbZuVPcyG2M2UtKtjHn1oPTEO4YtPk\n7exg\r\n=CfU9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-0adfe8d-1644907190688_1644907389628_0.2527669991099213","host":"s3://npm-registry-packages"}},"1.1.1-canary-0c81dee-1644909277662":{"name":"@iadvize-oss/store","version":"1.1.1-canary-0c81dee-1644909277662","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-0c81dee-1644909277662","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ae570d327572e10381ae6352c5d38cf707162e57","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-0c81dee-1644909277662.tgz","fileCount":7,"integrity":"sha512-JfrSpZboyAhnfUCbjFl370hssTzLKZ0Ol7TBa6R/vMGPOiDJSPYLy+zUCaJEEkr97zR3/A6zsLXBK+DjAkBQKg==","signatures":[{"sig":"MEYCIQDyYAvgVT8IE7RvLaWiIY2m+o7RYR+hBzKlZW3SIB9RIgIhAI/ujL6rrBuYV7xxxo8EMZ1a/2P/ngE6oa8PYpY7YXgX","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1NrCRA9TVsSAnZWagAAA+UP/0hzmSeVXdYqRYEaf8Hm\nWEch2rX6iDMz4Zkap72rljgxvYWo7IrF3pJLu7wrV9NBrypAmTLwiHgu9AKv\nlxGArXUoDR2ziXX3uFT3ZH/giZeMmZngJ+E/MF+DFkU+bmwk5Ll33wkmxzpn\nnu/1QNG8dvnKx/dhGB0eU4l7Nvf3KOzvV6O1ABxk7upoh15WrtzQvFNbYplJ\nz9p3eov6uuWrzB7f7DHZvRAnatMsrZ54lNaouJKlleR88F6ExU3EOWujRMYE\nqwg7cVfubDgJKAKaYcxflQiDzoDR982m3tabdmQ8dRfD/dn9NyatZWl5lAiE\nGqb9E29Cuals6hxLcN3YtOqmc9RcVqPuJNuEx95d+Z03aTZTYocUOwu62tgf\n08EDgkcCeqeWRkKlw4R5FbNrGVEac9dSWhWNIq8VsYUsQbotMQwJbPyg0BvR\nBnr2qD0T681Q8JhVKlOGxvHmIzKI99hoqByhByqWW6ZWQT/O5JbKLddN7Z5n\n+hDM55+ioz83/VR29dOUD8BVWC32klsNphIPX9Ku1DSxJJn6xeVfskXuFkSs\niBWrVw+RyhUqtSXFR5+3ldpEEGlXX41LKaeVFDpzJ1oi3V5FK9HuctqOFryp\npT13sB5p0F0bMjdfcm2tetMGadl/Rtj8QZmPd1skOGA7694sKAXDImfFCWD8\npIJ3\r\n=Bc47\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.0","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-0c81dee-1644909277662_1644909419253_0.8661295202886139","host":"s3://npm-registry-packages"}},"1.1.1-canary-0c81dee-1644909341275":{"name":"@iadvize-oss/store","version":"1.1.1-canary-0c81dee-1644909341275","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-0c81dee-1644909341275","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2d543c2c876b8ad883e9f80960a80ded9dba86fb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-0c81dee-1644909341275.tgz","fileCount":7,"integrity":"sha512-0oYT6kBKN0BItvMRp9YOAuoyTP6SNgQO+OzcB0BKkQ6LPwsGCm3sdV7SxfHlncc7wKkQp7yC+tF8NIM5AhLAmg==","signatures":[{"sig":"MEQCICWMOUarVLYBZoxjO6HTaZkey+xg7TFyFCc80FMaePbeAiBlfDgw70nPGbrmwM93mdf+eIypK3/Q1+FJkSvUC11lqg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1OtCRA9TVsSAnZWagAAnYwQAI0U49j7JYM4ufOx8JP6\nS9vYZZn3iTqmLqfk/ddF1ojATcM4jBcSPrT4EH7VQW72KU5zjIBXmfMfTUPe\nNTVXzUYIOCj+wYFfDLmcCbX1nXL0f7jIB+5lWMMtSh7PgOLHu1wvAuBUGq01\nT9l/KTfKpRr2trh9G7cY9ru2JV1MNYrto2cAI1uw+COD72CYR2hNBXKIAvbZ\nUeTZAK7MtxSRxIujBgDCoPpoQw6axidLggdsRRpcdKZW77Q8Mk4fCaWcpG/J\nWLxA4oyfSWaTSB/pwhVBxodPEoI6rVMUkt+JlIeZV6QOmSj6zDwUhctElknw\nMzhxKs7VLvs3FloLCb5SB1WPRPixg4/HkLe/6aRxhKim+MeUV2TJ/NosA1oK\n/mJkE4Zy5SnZZuPvmEDBFnzmy7o0vriz4sxtGU6u/RS/hWkNiMmNOVEN7W2a\nZV3FbNFPP6l9/QAcy6aEjo3p5yRic8Ypjw9gH3T626vCs/j+LHVu+YlAu5Sl\nBXPZB3R8i6KqRgiLp2SVT9khLbVhbj0WNqxkumFJ8fsU9xrjSin5RxEnwt4f\nFa7w6W/pxJWJn3mWdknuwOEswgxhCAllTxFV5bl1R/tQ+F46ipK0robQncNL\nibSW1HKm6591Cg3yNFBDTOY6PHcQgYAbIq/LAV6L8IU0ee6HLh/qzS1H6Uz2\nR8k+\r\n=bZKA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.11","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-0c81dee-1644909341275_1644909485176_0.5479322860347833","host":"s3://npm-registry-packages"}},"1.1.1-canary-0c81dee-1644909349548":{"name":"@iadvize-oss/store","version":"1.1.1-canary-0c81dee-1644909349548","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-0c81dee-1644909349548","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b271205aac030e58863bcf9137059b3a1cce1f30","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-0c81dee-1644909349548.tgz","fileCount":7,"integrity":"sha512-a1K808J+QyGUaxpB/3LY74r9cuXBOc1XC6Ldkgbnt1Yc2Aln6xdktzucNj2xOSqv43Dzj9+GGJAegkYpu5iL9Q==","signatures":[{"sig":"MEYCIQCtA+ugVeDxlQg479EUv3PQJwX2GlAUV8EXuC3WseLGDQIhANZ0rT1cmZHdwEddn6VLMbP5ToJyq2N5qf9vJ6QBjIt/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1PpCRA9TVsSAnZWagAANvcP/2Zxx7E6w7Ci9kTjAOyg\nKEwfo0WdLbNPr5X7zzz/x1MgMEb9OL8DJjfZw7oRgJuTrBSIBqTJL+DBSvk4\noiPqJQqIuW7ajtAX2ifYb3/brwB42rov6BbisILiKJaqqFR/nu/GgRjNJN8w\nZ8xAfMQE+OyjQdzjcblGg0NeDQ030Ilnjccg5KFc0DNtF7tX+tKTA2smc0la\nOAMg1G+QSc5YlyhGtJO8G24EiiBDEhWrghA1gZU8q0/vqNAHTg1vUyvxSpD+\nOBXISaVD3QQOmxxFFXMzibLHDaooLAQMiYecLZfM59XBbtFkuUEZLe9l9Fbt\n1dvBU3vM/B1LapQIr6ezoXQoNHb4119rlB5jO/3SY/hExkHBV+Fh1AAcO336\nWmu5AxXpNQwRUh8wvHqFTph1kzdeUSnsfCmBxZ1kYR6p0Bp0sihtuNjjhaHE\ncD1+Sc8Cw6CCwOqZi9zmexValCqGHs/i4Rc9Pf7mRM/qLTtF4ZAoGjnM8Nto\nDYQXwO3V+kE3OfLGdEdr/VKpXE8hk3EFi0we7r4S02PnMwuOb+xm3RUTLSPX\n0A0zTlZOS9fjmIW+A8lVyJpUYAg7a5+y/+3DVpBTuqiqG7Rd/mV1FxtZgJec\nGLsjCwUaSMH3Y+PEt5ZKG0kJVF/SLk31mj9T4dmRtGouGoie/AWvjSRoNtR6\nFjHD\r\n=QXnv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-0c81dee-1644909349548_1644909545158_0.03030855706485447","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1644909464446":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1644909464446","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1644909464446","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"fe618fc39393b94ee95522d408a6a8d593461dfd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1644909464446.tgz","fileCount":7,"integrity":"sha512-KyNc41Bun1VoEF8wkadmo8QCf1q3pfjjNTbBuknM4YU3DJ5HWOpkZYsgXnizLQ8wy6JFMkguntoBqO9kKlh2qw==","signatures":[{"sig":"MEUCIQC3x8qM3nvs7aNrR5PANdKTzYU2lXqV2T557gttxNzz4AIgCZR2FrISB3DYNSwRWfC+jy0fXe4uIPZmiIEKO6q+c+k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1PvCRA9TVsSAnZWagAAQOUP+weo0cxMW/tTcgYwVjvK\npYx6DtNmWeCKm16/D+lArPoe5kRno68XXmi/jy/WTA0M+t7/nSTAb1gjj1nz\nMZRHZMNmEOZ4XmJQ1V8iqhTCpfDe6Wr7VUSHlvT0Pc2jDa3wll4qMgKIXU4o\nKNDU3SAguD02WtP78blnPxqWKwFWxHYozHvwbyBwNMsLkQz6v2oSGIdV6pC8\nhEGD/AWd8LpEFGARIRM3CfFm0GtiPia0skmCv6G/hvROwwn1+/sB9qR4xTPm\nz97y3/SIhLeCuepieOUfYm37lce9a8x7dRHybWmPmh/SOFPAiUVBIGa/eAmQ\nXARpghxXIwlXkiy1P9etdSok8BrktUr4SoK02zAAmROJ5Ltw/6NC6x++HmJ9\ns458DLjoRQg9YnQnhKeXlgGb6gYQUNBDHuhj/ZSwb+ktk2jdwbeXDOw2ZuV0\noe4cnh6hu++ZK6FnozTyV+rFgn+7yKnSzlVJaM6z3rr6pS3VGHaZLjxF78yb\n8Gz5O2fv5VhQSxe9NfVYnDY1S5YgHS6wIP1ohwzSMoSbj2EgNv359Ysz/22v\nm6tGRoUi2iFUmohPR05AaLuFqimPPeGKEnepkdJsQJx3KhgXWDr7kLpmPgsm\nA0BjdlwajSmzcrsmym2TD1R4Asnry86flZWB48gHZjMINJpx5BFSUTpwBjbp\nORtG\r\n=QJIP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1644909464446_1644909551138_0.45517160854184224","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1644909528605":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1644909528605","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1644909528605","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3710466e1e7c87712a342e7de47119a103d244a5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1644909528605.tgz","fileCount":7,"integrity":"sha512-9MAoeDMvsMRoHJTWR1F5lBkuHW3gLlL7bIJw7Cwiw1kQIbntV7YupNzuGs1Ep78aWMZx5gQcGF6I+68vNh3z0A==","signatures":[{"sig":"MEUCIQCAvs8S5ppBJhDLShzYaQJHtD19i54XK4nAjF9EPYJ8zQIgd9t6UkgT8Zj772shgyOI5RBeXw+qQ4Nrg19uo2uNJj0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1QfCRA9TVsSAnZWagAA5+0QAJtvq2+BvqeCmMh9XQ+Z\nbW9CL7XP6LZgZC7iQkjuM3/5NLNSR/h7s3gNK4GIa3nXH8EPho+mmVYEVit/\nXBb1r/ccet+UHRZjC76++3Znb8o+ENw3N+ucIvOu6leL+RgdA1dVL9vRIUAn\nKiv3tTx02VDU5xijQOA4dqrtbyXpZ9wVSV4h0e87YSx1biHbllTraiqIfp7S\nZoTgd18BAp7B8BFqNHLBrMQv0AZ3cVT42luqw03d4bc1+/lH6BQKFkZbxQpu\njmhy+ffoXEc4yYKKV4SPnMCZEBShfrZHHb8l+iMFcc7SXsW//dU49hE177UH\n5rEE01JhOnP1ocIHO+I+aKzcnluUVri9FVibkxa6aNb5z+y7cMX/fKVwFqPP\nkv8ewhKnJqLS7HfMU667P1dTzZa0bopb9ucMAoS+PgsCVG2soLBn1qN1EOu1\nfGFJ4GqZUmm4tpiFURrnduDK+RwRjzpnKKYpT8werWiRlOpEN8N/ebr0G4FH\ngN5a40U4vcXBySRdup/AZNBf5pWKuAn+xzknjEtRrpuwM/ucmGDkS3JHWSIL\njQejURQynjpV2fFkTLXqHkLgfPwSzCc2u3604LmbogW8iMZeGFTMGtk7oODC\n6hrvLY/8kU/7nOgAc0ihJhKjcurRrc+WgvB7paMlg03iZuzl9lcPSH6CDvMt\nCyAy\r\n=vXC0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1644909528605_1644909599444_0.4557112341200136","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1644909527325":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1644909527325","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1644909527325","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ae31544dbd05a8017b93cf7ba55d23c7c5263783","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1644909527325.tgz","fileCount":7,"integrity":"sha512-9cR+UI0RKLzEO3WoCjA1v2hFEv6tOaUIMj+ru02SQAQaIJMlKUHBztGvkhTu3npChsaaZhuthGarBk0E+W3bng==","signatures":[{"sig":"MEUCIQDXhjWQw6J0P9HErpYuHYoOnFPq3yticmyF/8Eqe4jiOQIgDExDF7i4MQ/CRisguqlaSVg8eK5YXHGVq2xqq3pTdKE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiC1QmCRA9TVsSAnZWagAACiIP/3yCoGikO1DgMVnwt4gY\nzkRBJtLlLSATiEbkaVYxJz4LGRp6GFkdHa0Ka2rDjL/jj906EunTHXPrp8v0\nkVZJq1N8R1ysXSTtdc2qAcUHkwe6XppIx+LgCsik3AMv0hZrlLNCcORyolbx\nj1wcBvcnhipVuBTCMRpP8+SFDDv531fXZzrCVMXckz/zP1Bsyyg3nhK+YPXZ\nxp7w7NtV38b+REaGpxnlcPAIzuL9YEajn8j06FwkiVkMoTZ4QOps4jwMp0gv\n3FevsZ/X5eCJSc6pOmDUHxEt5thWYD+RYhEj0pTlF0wiqjLgiz3PAhqk8Upx\nr9NwORpvOn7czZJIMpQyOsDepIxhIf9sJgptqfozIO9WvxCrPdaT2+K6EkdX\nwVGekfmiqZHPDgRlJmKyg5UXP4at9eQ6MllKNFp0rFqF9DPDDFtTtU5ZDFPX\nR86jmDs2kOLig+WMem4T9kTZ76Sr7tpRpISEctrHrbL1tvzf43TV7yqKaWFP\nPpBSIb7x8PyV4xXzyVwv3b2t1Okc8ChH+p22tvuuwvsc2PIMpiFvYOVupRKS\nmitb+Y4v0hI3tOFwtmAlycrEpOLWXe7ValYpglN9E8buq90/baBDsZBK2z+E\nXB//rTIGRYEgWgKBTr4RHcXxVHtillQa9kUa4fXh+YPyd04amTeQu17+GwsH\nfK7L\r\n=7QLA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.11","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1644909527325_1644909606764_0.05205728178467761","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646128890920":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646128890920","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646128890920","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"47ad5f7f23c161c55268b6fc2000147fd6066a5c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646128890920.tgz","fileCount":7,"integrity":"sha512-jcKXt1F6Z9gVS1cxlIgO5YGo14Yh/+2i4HvgduqyUFG9Kn/WZwnVMCt2+yyCb1V21Nau4ODu4eP3iG8coK2Jkw==","signatures":[{"sig":"MEUCIFf4CffZmrXhpCm+OWKLoynH5QW7/F6wV82AHJIMsFJUAiEAyFkPG22Ph/D6Mv5j4lp2LP2zvNZMJgjc7lh0veHnYLo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe8mACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/Wg//TT7PPBXf36/vKHz4PVaSpmPWZeuhSdXQ61s9TQjTwV8q4gNP\r\nRC65D/mwk6zCIBjQraD9j7YqvVnUp52lLLFit64ZuUkuXN85NxAd+UIDu790\r\n/KsVLXbyjf78rJA9TyuIJG8PbiGGRBAaD35YAVCFIEin1lL49OHHC56iZDWF\r\ng7TV4M4nRbUNAewVcwrCe+3JJrDlF+YBZVYpKRG69sIXgUhvD5U4URS9FdOl\r\nfrSafmi526SLkjSNX5/SiJABvmn6QTwhPOEN08y8LAv3GJJjQ9/xEpvHQvKG\r\nc/iu8hN4Caq5e3KX3qRvA3wtDu9cHnoPWuGMIaoffUz0h+/UEoSQ8AxQQbI+\r\nxG+Lp1dtNtiAz/RPIRwIlnTytHKaEKQFPg58nke6YuN8vM/S+lSc83T/cgWR\r\n+N1BZxAGSZ2/Gu65kdu1dSCFXmkqb/f6a05uPf8TpLed0486aRhW9qihxAbv\r\nDeQmDy2mtryQeOaS+h6yyZeSAfIthyt9fPujF7b90cEVdxKNXRFHEjTC33dB\r\nWF3FcdXa766e/6ndcSjtDaiQWoQOGdu6mykoaRP4eE2l4SYqUH+pptBhfXoa\r\nRjSpblkNuGTuTgAvi9dx7XINQUHuzDwLYhHPmdL8uBjTtr2yRGBYLpaBy6R0\r\ns8I85pyCER2azZuvydBNR2tg5YsMpyTp1BQ=\r\n=VlXb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.10.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646128890920_1646128933908_0.7463272418835041","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646128922118":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646128922118","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646128922118","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"efefd15c4d903b23c90ef854309e3380f0510d37","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646128922118.tgz","fileCount":7,"integrity":"sha512-sLDouFvGpxri9y8bhaXU8XumTXA9R9f7pV/C4w8dxxqjDLGSOIpV70rAacC7d8d8l8MWwRw6oGvFYg98TqEfeA==","signatures":[{"sig":"MEUCIQCEfffWgqV0SuQrdWENWc8xLQ8IUFMzvXXk+JP4FTjhiAIgdpFmpmcFupbS0dEg4cEZj4c4FEurajgTaAlRYz2msME=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe9LACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1lg/+PSZCClhhzdshlwVHKfsdln+uKpsDc60tarT65xegoYP0cxox\r\nxxn7f4hqLpud8ulQ+6gkdpgmW/39lxFzY6uwUumuNRfY/RxZoNJXz8qQNPgF\r\n4y83/dkYZAFFkyyzC5F4B/2+xHVe+Qs8aNjH4kMVR9AVUPcj7te5nDA71GY7\r\nlO/xqoPHRuRxbJW79+nugF7xavNZW9xTw4qmzFcAfb/BImltDdZ3pUm8DZwX\r\ngU1GJJCC1DiMN/DmIhsVReauikJGbEA2u97eoswzBiewyp/bTXvONdDSUxMB\r\nZzKpP8wt9lDZ51KpccaFA2xzupLGS0nX5w95jnXxdlSF7GuuIM46tjI7mFAi\r\n6r0HTsoVybQgJ9Fmv7BpxSu0HM+gVpinOi2sPDCzVV9bdR7abZzalIZdWnNJ\r\nJ3SjANh+amD6x/pmcpfmgGGCl8uyxZn6k0WSIwTPK0rLT7l2jGPeAq1+k+L9\r\nyDqLovDe1oQGlllaIfuarEWhNfwWMTqXx4C0DFuyZYHrqqrBnCgooe2JuPVv\r\nKaXwn2gO9EzOEM70/mjBne8fxdCs6+mbXctzXhiq6rCeWX3luvPswEVwmRTc\r\nfIhnbayiw5nJFU9XC8T/ds8WTtgTA5F+SyUMsaEgy+ukd0rjcNoTl80ObqVc\r\n6MJYvprVAF9lbdAevrht3Fogsqe/WdMA37M=\r\n=ahxn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646128922118_1646128971496_0.08607665772520767","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646128924634":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646128924634","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646128924634","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"4096cd9e1e19c829efa27d84bb446b522fb49ed1","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646128924634.tgz","fileCount":7,"integrity":"sha512-B06JJzWqowLuc8qtJMZbVFV1aZa8QxLTYOz2NolqhhQ495UN/+be3qZcVOi7Hm4EoSX3Bl74z0XNq9jbeOFa7Q==","signatures":[{"sig":"MEQCIAVpyXA0Y+9GyRvGYTUevq9QAjbW0vxxp524esUAOqiSAiBn/3RdsMHrssLFNieo+KjAdKFtvCuMbeIyxf+KIoTcBA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe9WACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpbcQ//RpOvnrnidc7t1yrrMzoHsEj1+7bXS6HgtVF0/8rCYCrSxgcs\r\nXSABjGB9wnFKYTivMekj+rXBzFprNDpSfLUkBXl+J3us7H0UOD4xm/XuYoTn\r\n6y2zTV6uPzca4fnH6pQ3nv+LjhqSNj+XPjmU7A9mPll17vBRv66ys03bUlJD\r\nKxXgXnQdRWPiDcxlibjRRyPg5feEo+LQht1EtplutbPf19l4OU2gocYfca6I\r\nmMJd7seoqJZWze8TbGVRjQKHtlCnWVY21ReNnVeA0Xp0Ny2ChUe9SV0PQwHz\r\n80/OB3n1tAJc3lilG+NB+6hfhqJqIBd9xnHjw8EBMM5UGvUKZqadLOUwagPD\r\nQQI3QaCbxzskaqDajQjX4TsTrFA72EuV5vWKLZTJRE3XrtGBu1CSGJj0di1c\r\njg+7rQdicxjKvdVI14a+3i2IqxeNW2Onch1HyfzwcUmod2e8/k48gtG5FaVG\r\nDHfiJQ2iVL61w7Q/vseLQ+gCN90OZ5m9uZow1KaNnp4ZI/WQRees44TjGbaD\r\nY5kczS2USL3XbTsXT9l1inNsNdibse9BGy2Djg53aDVyoXsASyy9Rv9tAHpa\r\nHP/CD0tDybAPmnSWnnM3cff5eH3Nq3tyDP9/Yxrvr7RK3ioESGeY1WZHJeVi\r\n9MMvgt5wpQHS7nepfzVx7JIXcGcc0fLdm/o=\r\n=arGw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646128924634_1646128981982_0.3184108645505097","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646128993154":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646128993154","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646128993154","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d6d7f646126f7ed1fb260d55956e041e26d8dcf2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646128993154.tgz","fileCount":7,"integrity":"sha512-unAZ7Br4Sciqm/ApVINNg8+/YZ5PNb0C4XdlPfB4/fVeFPHp6DtCBcv3gbgluGC2tmPw63j5yqOacURs6VMcbA==","signatures":[{"sig":"MEQCIHr5RYGSyrhrYZpi4rkv3AEUKOnHV4jaGhuzJRPeVmmVAiBGRgWAtWopUMCb3BKUZEBr3HzMkX1NYVN94HUBTx1+Ug==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe+YACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrWfg/5AZ/te5ghlJCoxBQLJEqDX6QPW0AfU3z4hXGZ0CME0VA6zm1D\r\ngBF6gucn3mdsIiNU4PZ1OB8chFOPjmx06KE9EkZ0zEA+a5+fy+82v5+qJd1C\r\nGhESyJcVQBM6ZeF/Ael2J/FW7oi7ayPhQd6K/NhhO1mpypvga6LpzfOUCRQj\r\nNVtRZfhO8SfPiATxx719VJ069y0aNHjEmSUxa4MAsXOzlHUpM+unrsFvh0G8\r\ntysnfy4tn1ksQCniATPrWN7RuzyTxwMxeMAkx3QKpDaf93wdRqJDN/+lXAR2\r\nXqE6NLaxkA3UXq1ZKu+Wu9ZZOQtkvsNXSBuQcVzreldcNp6ztVRnMAeP93JZ\r\nK/oErabrw7skzc7lt0TrM9ig1epCq46nvFg0Hw4Jlg1T4tjI3rFjjJDBj+a+\r\nqLD7GlzuuTh9fNQgjB3C480YpFrFNI6n0WXikID+uc50RsT9d+RcmCxVAdlb\r\n5GbOfeNjNSpBHTz/iZsWaYY1WbXbNbhKZsvUGEE8vL12rxKnoJ3q69kBp032\r\nOfZefhLmZxpgwSMIDFlgsBqc/ogMfhbeysxbOryakfkEZ1DuAcA/xu+8WSAm\r\nr+BJh1JDoNAHJJ4a/udoyqoAgamccsENVuejKwdWxhdOquLWlY0A227ZHj2q\r\nQh0Q4JiCDf6yZLGVBTR4ctBtzlmEkGbHxkA=\r\n=Odg9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^21.0.2","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646128993154_1646129048268_0.618883633620211","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646129005584":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646129005584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646129005584","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d50e006e9f00681bc9b5b5064ea70fdd08a737a0","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646129005584.tgz","fileCount":7,"integrity":"sha512-0IIT6Fl0UKtvkgtQEnd6+yz57TvijAC/tES2FJg9+mEmLGejNTMAGOjgQYTsf3myNVAWnAjAdkWtVEm5T60xBA==","signatures":[{"sig":"MEUCIAxfYsaacUGosvPVQeU0HiP+EjGZxYdvgRPDq3tvu569AiEAySCm/KV0Vd5is23qvOw1Dtqd8QGIcB0UoSFtNiuu2Ao=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe+lACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/7w/5AZYAfrBtNySgS0A4oJ4ndXptwyF/mKoJCf2VVsITWGsHV3j3\r\n204+I8KsYh3yBVAqz2Q7efkv/ceOZKJ29tBgCmseo1ldwr54aZVXZ5SLjWCH\r\njYiVB2jC8hOtNEAH/+10OaYOpDJ0VbDv5Flo7JfyYwhaRrtBysVDWBAhx+g+\r\nANGAXWRRPZMlhQ8nfAQ2vLTlmd9qDmDiBuMT9Y4Jv+kWX4PNGhRtUa3jdyfo\r\nf8Y1B7eHzHQ9EtJSRWf57xwEwr3oTOzvhNizdQ9HBZaEEOSCu4H7tj78c4Wv\r\nzrKeTLeSiW/Vwa0KN/O48+6o3w+yewaArSBNRkjOHi53XRB9afnKzPw3RDLu\r\n+HRuncR0Uao4jcV5kBoPFgOebejWru7wZiwzwxpSqLtSTRzIYb7dobJ1j8gZ\r\nX8GWcCfcdZ64WNLCtagaMPwUGG2P1g4YkaK5yVod0+pEhSMxkNZxyW76QA+Q\r\nh5U4bbhnLfeCq4tqAgFoimxOuPljR+sxtU48L2qnR+JMF7FLUOFVccVbJzwO\r\nN57fO1jgfx6UYDbTWYOdDtVEdstyi6eoOyLy301iiY8Jm+firu2ZTXlbc757\r\naFxP0/Lh6NbpF7WmJTSxcYAFujHO1nplPJ9KVJy5qQxNAYY9OJHimxNn/yOJ\r\nOGIDTYeiH4BzYpAUaITgNcGcM1g+BLMSsoc=\r\n=QkRl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.1","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646129005584_1646129061296_0.6055694794914384","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646129026963":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646129026963","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646129026963","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"303011cc8379ea41b98a09e0aa94ee2860dd15ee","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646129026963.tgz","fileCount":7,"integrity":"sha512-kvrLmcTQ6Nye4sT7ykGQEFbS6ee+hQJUnf0vArLbaJ4xIQ6qWuGKYXPpw9LYF+Mb4FjEQ9PQHGOLbVO7Qp5kfA==","signatures":[{"sig":"MEUCIEPbRxgyWAlxi7HRWx0UVx6YC+V5zUKT2sBIGiu+z3bhAiEA0cEDndLSHrdJUp6yJ3sklBM3UeqJ205lMhb2ryKYdvQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe+yACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo7gBAAldlpn3Ns4sJn2cvrwNGN9tLKqgCkuyNCVx2iW2AeCggaMDzf\r\nBMg3GMCXaIpQUwnbBymNSUFdub9d7yUy+OOQJx0NdKnO9k46BGG3ZqVSuxVe\r\nn14vHCZp7/YDUUNqS6Fd/IWbXxNUHhtHUzBPruEZHa2XXetF1VwtPcBjq5Kg\r\n2F6Gr599ZfkwomOP5AjYYdqfZlpUBu+jkMVTekCcrS3SW6kaidCKtp/4cySC\r\npnxu/L5P+kJinVNm/41sYdEPXholtJSQDTxqg4s3O7cU3Jo88DaeaO7yKirf\r\nPVCZ9ZM9IOYNHUa1tDvUeGkenOC1cmbUgksDbA8csFQ1TnH7gO9bJO0lhqfe\r\n1AXDMEv0dOWuwnBK2jcC2APR2OyTVOlWZ94o53saoa/UNNPz5voaGZWlqIpZ\r\n61VQBNGzJ9IzECXyxnI8yIKtkKqXknFDjI5mfTSURy+TjxRE7jokZt3MOsmF\r\n83NxSk7KkZx3lGgKc98JDGO+pP+iQUGi1ut9hZOkOFT2HkmY6Bs30ll+LFpH\r\n0bHjtjCIWtNrerIxiMc1A6sVjwiqxsA8BYt7TufzB/OXmhGmTUVqq5K7ZaF+\r\nMinj/BZTUYHjSvzpd+OpZ+YARfSKVaKrN3qda7zZCx3jeCda/SSQhDvyB7K7\r\nEc9OovA9eeahWWXIuXJZFYTiEgaKn8bUc1k=\r\n=uBnq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.12","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646129026963_1646129074014_0.14950343350239104","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1646129008721":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1646129008721","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1646129008721","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"58611236c0c3d7868ea83204ad8180bd3274e1c9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1646129008721.tgz","fileCount":7,"integrity":"sha512-OnoY/HHR7n4w18371YvBTJu29yyMLQavah313Gh1sELnQQCRGhrXa/3NDHmqYlSdb4GDtl0yqrSBiB3lBMFpRw==","signatures":[{"sig":"MEUCIGc8erWQmyxRQjk2Gu/KnUfwDSBfCBKU5CvyD3KzcYRsAiEAotc8gNWgPJ899qJrpjVpsT1x/WCQeLx/nIhqr2vqcAc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16847,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiHe/lACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo3NA/+J0oyOFV+SzRe94ZZzlvf6T6JziEMyt7OuFSn0fdnbah6245L\r\nT82gRF8m6fusQpyo5wKZ5vNg01L4EJfX+7qpxF+CJAQ63I/E7OjcDqMEcXc6\r\nIULw9/iqbBwoeNAMY6WUkAsrcYUzLl5rLDH+fxhGD+8n/Z5pVi2GAjXeqciu\r\nucCAa0KKVWIDZxPRqAzGxyRZJm85rdutYhjZlecCWjAfr2yBYbOrvkaprohz\r\n161PUEI0hybRTQTSQrSadTu9PWWlX4qEqkKvAHalyMkpEQOiWuowGAuUTrV+\r\n4Yy8RuPadF3FARPwpQ1BPUgQApJoMQxLDXm9vLw93rGAFo6Os5SHC15oLo6u\r\n+9FzS5PpPXqJWEzI00KTS5BD8PhEXOMwA1djQSbrkJAJqFohm0CtK8y4X759\r\n9gLozli1d/Fq7ZwvIlvVNiBWhzK/h/DCwX3YsTj/NAaX76x5R2wx4SIG0xME\r\nxiua5BvdYar/BEjzS52a8HNIJdx+3P0Yttl+Qw1alXOxx9Hmtnbf/v+ONWog\r\nrkEhnJEaofvcQ6nVAfhu6vfG5vmZBEqUhZogucVTXkSfucBwxOkoDEMi85Ze\r\nro9f6vDh8yoUWhDOnZsrr/SILtlR2ZF2asnDWxghIFCOWU8Mnkg0x9sA6Lvw\r\nVxtcUt5GS4qEkr1IgYN02FCr+c36lo3hQ2c=\r\n=FhxS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^27.4.1","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1646129008721_1646129125308_0.8626233279253399","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1648344645750":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1648344645750","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1648344645750","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"39b05850717594255df0d8248eb5eecf4856fa40","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1648344645750.tgz","fileCount":7,"integrity":"sha512-qpIv9rPH8Qe4FXh+zxZ0X3HPybZ8Vy08orXkOAbE0YSH1Vv3aqryUYP0zvTSKymSR4LW9YYQr4YVTR/QEYtvNg==","signatures":[{"sig":"MEYCIQDrLuC1ofG5mZ/JAg5vpBeERS5P5X5Je+ZCEfRDOfNIPgIhALNcBr0S1gnX0/cVabVAW7XvLkHxXXnUATNFPd24lvVu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiP75vACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmohrBAAlfu9coecAws/N1kQ4TcWs19pvEJirosi4HxmuDbTGvDdKnLO\r\nRoXGHuSGs30HzDsV5EZTr/UdjS+IvV2SRjWbp1iQZDd02p4ZE5IqTP0NvxcW\r\nzrLYKd3r0tSX+tKwhcBYj/tSH72nMM/hCwHCQAPjtZqqsupsRGDjpMMN3IaX\r\nGZhc4EzwVmExFTQbEb+OO0YLgjq7bWEM4rdyEdibKlcl3mj4QLjUOsDwKqRs\r\nWw457wecVf9txw2xzqt4M33ADEBBV0f5YHt8sfVldk7i4N6W5d5suGq8l5a6\r\njpLKhx4X6JrPoZaT0lXIKn5l2zmhw+ReyxV1qO80iiSNgDlR9gS+SFGj7kmM\r\n3gkeXegkQfLbAgqDjggSEs4IRsfUghx0YruC8n7C7Y6QPt3WxQsCWms4EYZA\r\n2M/phN7decnHu3ozMvETUcibczPs4YXl8pHjaSxXSs3pVhVHdtSvSpWApSwI\r\ntIOlY7eHzgbh6kA4MJzxnYFSp8Oces/V8dlT9wCUj4Sh/q8hhdZyTQq35u4G\r\nAUIEQZXsy+WnkAr86kNMnG2U3t8BB2KzoJxILVvoAROA92fXe26t0ku7guvk\r\nDwzh4IlsNwmZixnOSi+MYzu+p4Y7wBO7oli0k4X44QkQXvh0mN2SDvJi4CMW\r\n9Osk6LLd4EkudWBFBt13vhSYnSGY1MoKcKE=\r\n=h8gk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1648344645750_1648344687025_0.1974989412603938","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1648344650694":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1648344650694","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1648344650694","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7b49531f0b52957ccc64031494a68b28dc0fec0b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1648344650694.tgz","fileCount":7,"integrity":"sha512-VTUYIe8nbrzGgcHtfzfhjGhmbW4pjcRJsv+ZJnT7OgG0QQ0wE+pc5cBW5QS45pUiqK+idBzsRneIjBa4Y0wD+Q==","signatures":[{"sig":"MEUCID0ZtVC2fVoqhrusjUCS6wmsUubNyeyBzk6kCpwuAD+nAiEArmD53FnbzY4CpB2MimBEuRG4Dd5G/y8hlVOrWyPSABI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiP75+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpDDA//auqDxPJC4cvd3eflkSgGP3y7TzAikz24El89ldDWj58bGobo\r\n/Y+Oqo4KnHjaUGzaW+StVUlPvgMQ8HwDtbypIRe2CWCxJOszxDAIdH1ri8lN\r\nMoxVyFUwK+qqTfCAR0wgYCT+9fCGsPCHm1/6cKToopKrptHH8xGZx3N/O66Q\r\nZBjcteVxClxpIaTnHRo+Ra24asaWvKUYi62u0pi3Kx38KbJuH8+nNHRO2gen\r\npUs4vTlhiWjDarN+/xJuK2z44hDmGbS9LWuT3urAVoFz+QMNjidwuIIM+2wG\r\ndjTyqjkEl8O7REn9YJp2SF3VP9HF7jqQKpNe076FmgF5zGvwKxJVbQyRqBxQ\r\nLm/i9geZKbDRSc6t9oxY2QVI3T6sxCqeDTKYsC6Rm97f+n9/yge05bIZkqkC\r\n12Yjq542cEcQLETlSSgwF/ZgPwy4C3gYwZxtkcILbyjxNbLaqMPweGPXhE1W\r\nCHIuEqjhk5IXj6/QqV51pSpZiJOFcWvztvhxbWuWqC79t+gYy6wvMrhwHVLv\r\ndmumqy+wSGFWLi+w+l9zjAYoyhdSiDYkGqzKw90mHZODDwqpCI5mPRG6XQsw\r\nb2S0uHG/MuYOdv6mMbPV/x2Kx0jf1L5Gb+1WLJUioAWGmu8aMKk0mR7pkll4\r\nRujtdvzoGtC63Mbvt10p+uk+zzyOmfxhxtQ=\r\n=yO0K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1648344650694_1648344702302_0.18776330705289612","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1648807400819":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1648807400819","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1648807400819","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"839e20c0bfe8553ef4cae845e64b690ebaa16ddd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1648807400819.tgz","fileCount":7,"integrity":"sha512-T6bLL2/kx0J2fz2nSSbHuduMqzZCM5wpFe4GQnhtsj7DD4BPBp4CR2/LMFOkAUEAI/ryooxHH3lpSO7p5YSpvQ==","signatures":[{"sig":"MEUCIDpCcvG3hcJi8KpLLpt5TMzmbKUDeYNe14PXSRgs35tBAiEA1+9TQ/V88Gf1RH/h1/ZadynYODr5NBzgwyWIYDtY47I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRs4cACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmosjxAAiI5R5uWtmJfwhmGCBQMSNX+vMLuOi5IpAtiC0NSu/cUTwHug\r\nhIx7mk3R5Xid/KWa8aw42lrU9GcpEUsvqjdEi4zBCUX0DY11oQUj3/eloHmh\r\nBy7LmqH8oq+V4EEkibNLLTAoo0AXsNyVitRt+X6a6VHm6GLDNE2Yfv3Yq+J8\r\nx+3jHB+pQGe8qR0wFCOF2l3EmhpzCSopQA7J2sEpWqBQEQ/jMnff+djJt6zL\r\nHsO4Vo560uUbduRO4vvydSO9++32OfwmVlQkOVxYH1V/zfgbc1RG38PxUBgK\r\nURAne1OwdaTw/Yi2PEMKZiFQzvAMxdhqMool3JrLDiY5Uefh8O5B0iGGOAoc\r\n14mo0sneuRXYRQjPeqdzMtliAYGH86y7Gp0izJ9m8xuTMv1FXc2vfY7PFch0\r\nh5rmYUPPCS8fVvgjNVfq3OqN1g4z2UAYf7ziD+DEmzqEtVq0uYWaSaJ1dHyd\r\nE9jj/mi7Qt4wG3ssTO3ICJBLByOYMCb7nGBGMXLTZq78ERSTDtgVx8Tr2YgP\r\ngr0KB0YoKqrKSN93p/ovCJVszRkzWPXM3Lk1o4t6+v2x3WNbH8iKhxl9Oivi\r\nEfU1aevYn6niAU0zc8MefSKyeAvK70gGYq+9oSxHcYsndZ2aOeTdT99GZHr7\r\n3b2SNNXkxPeQDmz2t4V/HqdPZiP+0928SUU=\r\n=NjKZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1648807400819_1648807452018_0.6118919255020283","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1648807383097":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1648807383097","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1648807383097","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2b20334e0a91d2b9ac5b2f3505975fd91a0553f9","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1648807383097.tgz","fileCount":7,"integrity":"sha512-+44SXEvPgfvT0zdxt6n6qdPjTyQuA7CMIBVhqBTLIaWQUdXxiEeQURvDUwBc2C0erAjPWWn4zmO/l1byCvF22w==","signatures":[{"sig":"MEQCIG+yHtl25+4l2kk83f4KhbrjFjBWcNpZx4RxovAix4v1AiB9/9xpfNG+T3pnvWw5c2W8nhSYyT8cGmBcROrpYI3lsQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRs43ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+Tw//XnXwiiGCLmQ7en5d++QY7YgcJqg3RQRgr8dHGBuewtWQET4k\r\nu3gW7hmn5DzSRMNqwuA7pY+AS0CHlw84/Mg+HFTZLSmyOZoyq++WhiGO79Lm\r\nqYAY0MtGDTFdjqbUXTEgT+wVitBy9LcLQf/TP2Q0YYKPXZPGaboe7+t0bYDf\r\nUSabu/pQQS31E+XMmQ27uUz5CJwNGcDP09pNbRJHv2kwpxnQVoqjGh0rLaXk\r\nKbqrNgpzWQm5UzfAV1JlO6OQ2R0QAT4g2c6j6pNyyUIus8CV6aSBW4yCx4rx\r\n/ALQQpJESTiEb/mIJMRfwqcJ05dsuVe+1daETFeZKr3vGjdu99SXmcGHezKl\r\nzXMvnUvw/QAVJ/SafWaziI7RkcZ1B18WZZvDuFCbtRRHpLLieNgFsaZnRLzT\r\n/7xP5hGuchRHKZ++kwz5yRmUfUNoet7wMH36/wLsoIVBUxkG6y3v8C6NA5oe\r\ndQ4+Pw1k3FVSEgqxwLbqYzHq1hwDU6yaUCvddR0PdBPdJ0ovatR6zvPhs0Uu\r\n8zExh4U00I8T43gvZDYJS6RDIHS0DrwAbN0ukxo3zgCe69kdHpbJX4jx8M8w\r\nQr+PZ2Nps4vDg9PSKa8l+dQ9bTd8h+MznfqzOQEbQaIcrXbT2BDNIe7uEySt\r\nFIFYvi8o+Oa45q7OSwtiMHDJ24eqRQRLKbU=\r\n=x5ds\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.13","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1648807383097_1648807479312_0.5230316924833232","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1648807382208":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1648807382208","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1648807382208","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f6247104c6164a4a637354376c9b8731b73ad63d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1648807382208.tgz","fileCount":7,"integrity":"sha512-4m20arxrzEJumVnZGhemc54lbWi74jkCmFwmH/ANKP4Iir+666gM8M7RFGUcnvR+3Dz41biTScOLNa/jPg5XfA==","signatures":[{"sig":"MEUCIC3BSLc/ZhXprCmSe8Cp8ChVTqil9EEIRhnGdvjqO4F+AiEAwlBQ6we4pwq5GdwoKuCAGZy+Jw7WH5NwQu1y6WIyNFE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiRs5HACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp4Tw//YLiMInndQysaU9LDbiHcWu5PWfHV5Vle9bFvVpjFX7jIRYUV\r\n5gM5sRr2Uo6FL49kCDKPQGK+w/Bc3EEELX/MlELYPkfJBzDhJdFChxUYqP/s\r\ncaiaPjrgDMza2zrauFAGNrn0uyspKQILIktDFB7kMvoCsGte6z9rLUEZInEs\r\nyDpOlRr944A4i3+AkEFAGswxm1TifdGLG0zi8S4Pf/jbFheo3MuFhSm1Cj+x\r\nSeIP/eOpiSkauLxEE1hrh6HCOew8KdkhSDIHkxGuLny+aIFIqhOezHuFAvG2\r\nvWtV4/BaGnkQ7R1tKXg2zSMGuL9lGXcY9R8DlYKqFvsrLtCCJoogloU140rC\r\nZbYd4uBRlONeNinVsZ/Kn2mTkYNieAT6NNawLmqRIEIfeyEw++wKqOe6dTMO\r\n3JR/IAUixdZgf1wfXryZZbA0yZ3mN0eOZRuIqic6L7d8E6VLGNJLZXpHFA3E\r\nvERmY5TFX98dDgaMn3nmFHGUiZvttn5c4zApPi2TEmd1UPcnc9VYcJ2uYRLk\r\n6uWKKQx96NKkTIp0qwsfHQp1HTQ/BJNBJS4BO5RIx9X9XB/0HtmgtbwO5+O4\r\n8i7kSv/8I6aokp2TaB+o0g2XCV4vxtlif3ifdSypreLk3N9irw9c4IhSc8m3\r\nEca3SDKkpNmJyzGtg3akcEC6bLO4uCxTvy0=\r\n=nwDj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.13","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1648807382208_1648807495308_0.7966643952984425","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399292964":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399292964","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399292964","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a1c6cd2d9de79cf7698f893b77e55cdbd7bf9c93","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399292964.tgz","fileCount":7,"integrity":"sha512-SlSUQPBBbGOfZWtp06zbWbFjriCojVi8itSxs2jfTVrzs1obM3itLkOcFskCLnNHNKaXSt4OMuPQd+4JfhJnYA==","signatures":[{"sig":"MEYCIQDi2cQwNPHauXefXxATZUuwZILuWFqmx0KytFIMCtLcpAIhANolA2K+KA2MVkqcaMUOoZIPl9jzEEqsPKoKVLjTkMF8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiblqqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr5pg//RtqMQ1mzlAMTSm0OgBCVldPnMgEIOFDTe3swv2/iB8Rqbf3L\r\niXtzce1kMDgHTFXjt4ZAsGe2DB/x1XfsO3nQGy61WTu0ZIPcxiFUnFYglSaW\r\nsfKApsiQ0kGbKy1htGUwQcBqJnzNoWl3EomYOT8xBN99Hb2vKFbEA0v8uXOI\r\nVy4SDByRQC/0P5wWmLn70zzJQXvXwTRwW+QWRYJAWC99IeeUX2FfpdT7eQ8O\r\nCIxTZbFAtgZQrmvPG+TVQ3jFhR0Hl2h/nMmSovgOVUiROwCOS4dSmoc5oXZt\r\n+59QD3uX9g4SZeg55CPuMQxv7rM0dXRjsEHp0wTnPaAXF6oukaczvDtUnch3\r\ndscieklLNaK8TlamxOK8cxHDjfW7crZq9T1sfd7rBVwHyZBkAbWY5+hpKqrj\r\nw2ItsJXujbA97Tr55x45BoG7iS5Y/slmJHebhHSa0APLwB86UCy7qSaX5sgn\r\ntc68M4s2SNQVyvWJbsXn18hRscCssccuHZ0jhGlRGg7ZHgYLI/08FgWUVbsp\r\nSyfY3Xg2kZXZWQC8Np3u7BzyiyWtqTMulbDmnHWZeM0abhM9JBlJdJzJnDY/\r\nPLjrCfSDEJDgq/mj5saqLyLP+GnO6btp6DbfburRKkoYA2QHMPGpPA6S7yTi\r\nl07PseF2oTfTtY1nWmZ3FrqRkiUdZIfoYr4=\r\n=Piy4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399292964_1651399338792_0.5968212732983853","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399399898":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399399898","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399399898","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"716709b8681e08df2ab4f2c16203127aeca02605","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399399898.tgz","fileCount":7,"integrity":"sha512-31vOOznbN1E7gs/TTUk6W2JZE31WhEEAscxMcY85qTKYzGJDWDAcB0FINkv5Zh1mBQ3OtsQQOj6tIPMQyNf33Q==","signatures":[{"sig":"MEYCIQDVEbxGm3o+FEWEE63TohIExATIJNkYauZMnNLnHWMsZgIhAMr/vIYnjPTJ61yIWhZ79KTCbG09Odf6Xz+tufBX+2xn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiblsRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq6kQ//W85B6JL4OYVgKLyFQtJYL0TvDH/3GiSVUrMdgOpDrpiGPSdM\r\nS1rknOA+2A12Pnw1toSKY/EWhD1gANqYKAzNPdZsKH44J6OGQrEtUEnik3nM\r\nWa5ynZzw1WOGKL99p7jhPmdT6icVK6iOp3nP0SDCGjYa+u7LMXQsXfDLmfKz\r\ncBHp5I/KR2MCKsIJs3t/35x5CSuqD4rWHRTpG9eZ9ybFGvK2H5nR6y7u6y5G\r\n6D2kla0XNnv4B3TxV4jtr0x2s12cGSkwZCOUCsn2ISBIhT3HlMvoAMh1xR+0\r\nzhPeG1niNVhroqyVdXX1RL16lA1IiLkfJv4z8F142ISYzOXIxtEi4IU+Nl6m\r\nd11lCAHfLuebVD+LuaMMGLeEmx7+8ZFqcfdtB27s51FFUQAdR2v3iqroWwag\r\n5+WXhteQ0rpioG6MkCg//ZoQKxDWYwDfkcmvm0zivb+3XsfUnf86uW4kXWp0\r\nQ7HXvhVgNreTJV5rsSS7zXmlXhjsOLugmPG/aJfVjrpoLVM7e4C5gYCiUZc3\r\n2GKtxOWmS9RrkngMEkFz4sXi6uabXsCyog1y0kaEZuiLcokqlesCpzhxs3td\r\nY5mNBWbdXNEhOJtMPqE0JEGln9PTsjQTpdF4ClBvFaB/9MQwvkWyCwtFj/tf\r\nugb1J71Yux27Ro3LcJfE2HyCRetvvrk+9MY=\r\n=L/GW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.15","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399399898_1651399441246_0.38460676995022336","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399436059":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399436059","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399436059","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8438ad7fbea54059590984a41c2ff71c54bbb8b7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399436059.tgz","fileCount":7,"integrity":"sha512-pOSymhlIzDdKnfLBW3D06HAKknwirkdDi6oiRUD8/P81I9ZXr02El3nwv6XqtjP+3l+LLS63d7pgi7N6hZiVfg==","signatures":[{"sig":"MEYCIQCBYQdG8/A6RCWc15IJymK5UZ21xUHrAJJSNAJCKCPBWQIhAPmpbxLKgJGrF8xuH8MQCdQ5GX/NoNG5kciv6A72ZAD2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibls6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmphrg/9GpTPuUcSANUW9MX4cbmYZyO+1Bk4hKLtursdFbmbEQ3Nzpqr\r\nGnvqDne2bhFYQk+CdmCvn+1cyj3GSRjjexJFq1m46l0YMo4DGyPZbfwNnDhH\r\njawYW0d/ndH0yUdtNYMVzdSHOj1KSRxPOMqPnU8+ScslKeLHsMexXia+OMyk\r\nepuhdYaa02hUL2b1dH3lq2ItzwVSJmsgqaxjZ1SyrJC78N3k8Xnt52PVcqSh\r\n3VrL9d3rjPc4yuA3go5c+dDSW2+E7xhJ6M2Z1l1DE5t6YTYeaXCdYBNr9FkA\r\nsRILTbAo8+WTNHTd+1RLY3cA3+b+6H7YREoFR2I1ob7WiLBPuv2LzLLbUDeC\r\nTOSyb+OgxxLCvC81V1tA/6RSxSvo5we76iU4S7AbC0Ai6GtPlzH5GXFcAFgJ\r\nC6CMp+Yau+Y2l+nR+TzY/LhTT0YvGGsN+9Lb01hqCR3uIu328DiUmXLCOyhv\r\nIAyR3ZILeDLqFVxvvnRC9T/GOKDLGcV4b1KNvWFs8/Z6ZMgqczRZIunTLqw1\r\nAEs00mSxhzFgoOzEvp/u0tItpS2/Ofaswuxvm9EhmwuWEHWP/DVakR8G08Ux\r\nG20D46HGoeudXPlV+9pAfG3D268HxUWj45ZM2S3BucQ7SgR4Js7SxMPJ9mPi\r\nXBIaVuk4ZLGUAxpXsOEO/ZsZw7xCMzsaOIQ=\r\n=pF0B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.14.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399436059_1651399482274_0.08543831601550522","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399434032":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399434032","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399434032","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3186990038b886cfabfab594b02bd45d2668fc3d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399434032.tgz","fileCount":7,"integrity":"sha512-5Lvpf0+vMA88seKS5PNYJgd2bTJA8O7sOBhTadLhYjoM2yzsSlWpwrg7+FRKWQhsTnWu5f6l04a8mXSlVuGe1A==","signatures":[{"sig":"MEUCIAFoayvqigDf7f75o1mKujcpwUowotHAKQi7UwA+sU++AiEAsW+awD6UK+vRIL5WYkxm7LE+B650fcQidACiaX4wz5E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibltAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq0pg/8DdhZoh+zFQWJseeD595PWnVYd2GXJHsLM7Qn+7wKwQ8ddo50\r\nSiar6cBbkdFhcylghu959+ruAKpsqYLct3Z9Mw1/QHOMJoojNg4xOq7YrKFa\r\nreyFMsMkx2dLQCMbVF6/SpQjUZ8QHwT0Zn0FMcvVEH/sI9rV66TI5S1sETmS\r\nr2BIGyozA1uNItbIf/oX1Ae490p4ZJKft0dMJtLIYVkQ5ja/SbsRAblMOHyb\r\nCAySF6S5FNO9eZOQXWtbbcgIsYVIXH6hoi0uiR/92FZkQerxJaWXT6eSefY8\r\nFW+axYn9jcjTJPWX487yaBVAv2p3EouJLt04bRHQrYY0Gnp5M1kNWuzyGW+M\r\nghxuJg6HkRF+CMBMLAWreOnLCduw+GwlWVjsqr4cMD5bpm0ecvl3nnfVI+d0\r\nZL55BozFuWoWQeXQFNTkBBzgl9kAdSEa0H6tQFghiV8CpTssFIwSQoDZiTQO\r\nRoIQdo2VZuvibwrxmUTWDcFXBtMQzY1zsYloZGadp5z5DOSkjL7KkKLyGQ7n\r\ny+15HjywTixToFAKFVythKJaZNI5lgXu9ShuLIIC2WtFdmzDutLNvNLiz1Eu\r\nHIA7j4ehT0mmWzdcMbnzF6QjA6DB1TPlGV7O+gFORKbSA1nqv9kmKxP7Uwux\r\nbRmY6Kpir351GaQhqC6kIHc7kJgDiqdWpBk=\r\n=Td4c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.14.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399434032_1651399488327_0.8804937237324271","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399452687":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399452687","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399452687","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8245abcd8d429339826b64ffbc70405112d10d19","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399452687.tgz","fileCount":7,"integrity":"sha512-x1OPJgvoOOMUL/2BsH31lmj1a3ww2wwKylgVnOKlvP9RQFi5etfyugXkY2j0SzuiVTPyf8fRd1wbptCZZov+Qg==","signatures":[{"sig":"MEYCIQCfmDCnEb2T+4JbibsxFBfYPTf6vMcGLYYuSi9UlEjxyQIhAPt1JTkDD4Ybz5T8yLbw6rbirAdhdblSEoVTBCdKR3DE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibltRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/iBAAo2y9BNPOkGndbq/Y/doezjjpMwdveh2qDQBWvo2OK1J23qmp\r\nc7v+5ECVVMbNkRn93zuTCREx2WGRKsm/9uGquVYnLZrG+nFB4OiBCsSQdjFs\r\nJMkuE/oq2JlLMv3mvH6uoBhJNtJaYRg+RR8huHPlLKOjrIQsyORHRWsfduLI\r\nMZKFGFC6WfUT0RLHjDWPjYmPEWBOxNzurlHovvcgpyTBD/S1iopS/Nv0w/VG\r\nAk7EYUv8lxKabwWRVe2ThJUU4xIdbzGBOnFmmhzGMpDhPfrl8O+WybZMc0r8\r\nV4u//BU+GOPe2T0r20FtXfZpkMBxszZlIAGcUHLUlnxYmBzZnCcIOdmginmT\r\nS6hmTGlLUC4kS7+H3jyiaWBKy1po8IOQ0dBxzaYsZKcZF0kz/7Yc2Tc/asFL\r\nIkm1vc4qbdX2DnUcOroyDfTXfZY6orivaYHyiYDOMZNxvOmqe5b8K6l16bhp\r\nHrTFTgZWH9Ne/M1lZTPEJy+gJaulcebpMOjX7SYhXpybY6yEgNjqkA+ms1P1\r\ncW0YnwuvkISQEDFwNRxNQ6MTNPKb/ro1U9kxFXok7+wmXeRB5T1fibz8FvrK\r\nH2zHAGAp6Nx93Y0jc2Px24pQFhRBKOKUu3ONl/28/hySjCoxGlIt4TD5xQaS\r\nSyWAlfHSBlvbV5mmwllq6As7c3sC+oa3tWY=\r\n=M/5N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399452687_1651399505596_0.0058517730890144115","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1651399454564":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1651399454564","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1651399454564","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"42de941dcd6399c0f03137b0776c2bb34bdcb7f5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1651399454564.tgz","fileCount":7,"integrity":"sha512-DQ8VTIOlSZ+KfUA//LpKUBvexPsOAuzUwbHGgWUrm2OUMXUOkNEX12uXncEG8k0TfX6RQmLLBtuOZpBbPr5veA==","signatures":[{"sig":"MEYCIQCEOBXvtZr+74fNrF/bf/tcLbtp2pN3k3psCFsDi/xEHwIhAKO0ETWjXb4mauuSsRmbCdGiYjLfPRQCDTI9uDt1cgUJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibltYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr1bg//fwfKqYK4tjPQBhmGfz0M2vUWAM31+CY0p+0l764rTM5WffoN\r\n7K70YzkA2EusbxPn3CvouncTe0X7hkTtKNlJyMJUp+5isYR1jECuSBZODM0l\r\nnC7yWrt54IMJNfbUpqmm/+plAN2KCKvb9jJR8a4weGc5Fx8XIcJN5YFuJIaz\r\n57tGuj00SlbbeTQPK8y8ATpJYcZ0RZP8M+gXLulqZgwdXTCi2SkLNi0lRBad\r\nGWK7YQ1BBOdTit+IMj3lpPnQbL0m3s3NjwcVeWTSf8eBStzBnfaH3mBgMCR4\r\nXl0Tuq8kHioyx4kfavUT9+mmxpxwBgnnBoZs7Txl5JZXAP0G4a9mhtouyzAC\r\nuBIu4eRpYhaTdPleIXpcKI0/DLGjWYOPopF/ZEJmGJQS/sfn38BrTuBUAKfU\r\nWE4hNTCVvKs+h7a+720O7ZahWGPtvMdLMp/7kBY0nUdqu3zwMvtOTVMZZ1vP\r\nfNGkBkmtQNqx/ZVpdQipNcb8hqhY05oW6GJC6P3dFQaS2lDHKurL7MgSJGjV\r\nawxeYISD/NsusHH380NAWx7qRCYiuLIfNQmUe9GBMGctvSdcbo4JNSSDqwf/\r\nRX6XpQpRzVilxwopwHDQCOjaa1UWIX0oNskEuf6dgGuE8hwo329dXzlFimT3\r\nUsHZfH/JyiM1oqycPrs3JVt5Bx3KwOF3iAA=\r\n=R6Jd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.16","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1651399454564_1651399512396_0.951675082883155","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1654080673706":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1654080673706","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1654080673706","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d774d82295023fadf6528a6121eda42de1d26474","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1654080673706.tgz","fileCount":7,"integrity":"sha512-qQTipgYPCDuqMmKNhRFVQt0u/quUDCwn9EMR2B1AqQ2bX+H9+lp+hhEllYAPEZJ9stoaeIWq6gvkEuL2qNWlZQ==","signatures":[{"sig":"MEUCIE241SxmFIaoGZhiJmdb6G/uD+d8cYFbV7RiaYNFWXacAiEAik0x9BkslGIDOthI1/EykxWAgpcYoDVyX4ZbhKjDXhI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJil0TTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFlQ//X1Z3xxpQP6ImIDkvOFqfAjYC0vO4SikCnZPgK/MOV/8rjZ7E\r\nAB6ngeV9CB5S8BomX0axpXQ6WpvW4VsGdpsJzLml6l5lPVNiK88wp5FAaPnr\r\nhpQXjOw721REPwraJBSVujvn2mjTHXV6S1HZenm/gcWHboZaVFb3MLf18yxQ\r\n7afDb+Oepj7Pv5PTUpA/tQDFP8vNOlC5AJg4DDRDoN+0hEib5//LL7gviWan\r\nA4ukU5n06DsU8a4aoAOcfHPHBdzX90rQ8XP9+lnW4l9ShKU+OdaTLfgvYQqo\r\nMX3Gj+IMrgCk8QyQ1Ew0B9V/EU21jNJzYnHOpG/NT8vDGHoCO5tIwLS9kQmn\r\nYzTy2UBEVWWsMq6gw1HawOEoZrgkTqXx2sKvSWff3J6QtUL8jZRCosQylvcb\r\nz5R8euJdMi/cJQgaTkanmBKYGwkyasLt/An2akqRnUyL6ZwzwEbyoQg6wZVI\r\nWB+rRbpy6URZuFFXzoGIdRFxRUri9cXWuJcleBmQoykHlEF3KXUez2Wcm0IW\r\nhMRVWcoMv5fOOc8GHDBzYIilnK4Zitr8U2UeuJKUrw+EZjWuPjoj9zImI7Gd\r\nHO0GDqrFxIaxeWo5qMUk39I1PFlYTuNAVpymqKRoJKPzrYbwoz8mgwnP9GNJ\r\nwZZcpYHM5MiMfYodUoQQj8cTYG/05WRpJ8s=\r\n=n70B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.22.17","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1654080673706_1654080723092_0.5474240357643938","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1654080688858":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1654080688858","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1654080688858","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6309b8007e22ebc6a0adcecf914dbd6a7a033b59","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1654080688858.tgz","fileCount":7,"integrity":"sha512-Oo+KeJDEnm/DcA0u0bSgKqM0LCpJ1JQYuwKaKOog5pkYMg9yX59LX+OkAdDSYDMQMQSlCVK4qBR63drKvxElRA==","signatures":[{"sig":"MEYCIQDIpCk6NNwx78G0PW6Pm3PfXP6i0AmxHRcTyfny9Q41GQIhAMR28hOBGJo55HroysttKBMbY6ASbzORuTw7VXFpVZrg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJil0TbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoj3w/8CvpC++UkWRE1WLrAmOgYwr4JcIxI980TvjCFubp+UwD8+gbV\r\n4tuG10nlgb/WBpxPQZp4HfVwZLxl7QYMruaCItJdcOBbrtmDQs+YB30NDG8P\r\nsHWrki94fc1Cwo6ZPEqGvACKWczdfMO2woRMvmcX8mDxg7WoK9v2flkfTS4J\r\nlZVXdEEsjKZHI0SER8c4YsFhx3OclYnIYDe5/TAiNLhtNWRZ2ye0piGlURu8\r\nTSAe5U4TkNBDab8zJQmYOyALLR8MNdCAyCHDMVlEuAq2iPLhqCINVoTkXqur\r\n1+31gAGof2rNc9v8p8yENJFj+InTZOcNlAKyYk5wVLCPpZJvCHDlmoICOUvg\r\nmZZSMW32bWzriH5PUandENm66iGeAbRFhmZPXzunSoJV+93fmAgjwPPIoy71\r\nN+NYDLV6APxgNzOAE9JLFDTCgxnmbpuR36uSKqKX3xIOFKL9as4qBDwRhtcr\r\naTXffUhpzm5ASCPhqkd/vd/l+YuQvejmXfYB2Cjc7wdpSfq6Bs1fHPKIcWP9\r\nkzHPB3K3QpyMCwXG8jKFM+vr1YgKjGPAlo6iam9kIX4WlMaiDl+bzN7d7g6D\r\ntk1DVOTvCuI/uGKzucQZ2Pr55A807sC4k239bFUzdPquk0OX/YgDLnBFg/zN\r\ndG8L7JTqwMsqrqLpQPjoFExjqIarKac85nk=\r\n=mZ3U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1654080688858_1654080731349_0.6182828210895552","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1654080695183":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1654080695183","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1654080695183","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"6c4b50d018fe37c65d66678158a8c89f61af01d2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1654080695183.tgz","fileCount":7,"integrity":"sha512-MfeZFHl9qN+bYXlay+aD3bCd/wDejx8fcz8Kaq+rLXwkCL7djs/O0Wzyl2BhsEMcy6rIKavKX8nWVyorGqDBRw==","signatures":[{"sig":"MEUCIQClr2cokybCkWNIGPDG0eeOvEPfxNQeFY8JZ9FpqDcnewIgZtTqrq7bWg0qBXuCFyqDgkIFugt/1DZEkE6qrqoD/o0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJil0ToACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoowA/9GVCr592n8nMD0+YVBfqbUf8ijMHKugR8zTD0+FzX451bS0y+\r\nL/6ZlgHSEw4cyCti+lXwITgks+nG+vVQ+Ej56YK8bKATLOcfvHeu1WgEfDeq\r\nDTubuK/pUW+4IfPwvpklfb/qsANes5TZ3ACD/8aKMYcDfwNJRUuZet9BNTfn\r\ntB9P/dyAY0HwM/nX2Y/sN+81dQvbAfPVqmSooIi486gV3VyAjVn97ej+ZSrT\r\nHdMr3V1GiCLwwjHZcgLNfr030OoOAQHqK4LxMph6ADeVzyS7BhnWwmKSy+Bo\r\n3MGzbo7KlPfIhjJzNz7x+CLOJqkHuDMGp+qmNejf+WvYvDv7vXNC+upzMP/V\r\nBbaRV4xziD4j9uFUyRCwc14q3U+bFn4XlslzKNNavqkfBFIo1CY/J9HpSZ9C\r\nM8lIMScCTqJIfh6NhjitpbChGvldf5XovLbeNECyuh31oeJvpv4Opk7wgegz\r\nFtzSWbD9urUdgrSk8Z/1bG5uj+I+Q7l6SxjAaBq2ZMmeLLT43tXu/sT/GjVb\r\nuZjKypoDfyHRp5QCBWIQn6jiK14ipMJfUTSE+2vCcgYqjAlKjEMM/kFccEsL\r\nN9FYQJRf3T9yhKUO+rFLCDP3x+STSeZCMzHLRJJ4ZqsKXMzzrwroVaSKLQI2\r\n4ax0AxHMSAR6uL1XYYiXgGNyfj5rsVGfPUg=\r\n=KkFS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1654080695183_1654080744103_0.2649585026674255","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1654080739809":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1654080739809","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1654080739809","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"22c227832dd5995356901b40fc88dd7ab82fc74b","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1654080739809.tgz","fileCount":7,"integrity":"sha512-eaLOdRWaJWsqHEo6Kl+AKAPRrhxvgLbc/Yvde57wDIDKVtAs2EoOKLyRXj7au8OZgg7v9Hhiik5ZuT4ty/xK6g==","signatures":[{"sig":"MEUCIQDc8wR9gxMoPiepl8ZMxuklWgN/N9/Vemfy4y/J/vo6UAIgV1XoXdQwYQEO5R9zXBcq/zI/Sa34wE51HzoQbXIPgVk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJil0UYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrhfA/+MYoBBCIb6mkyg4JuRHwVuZmbMg0X364/mI/WwFxv5oYg0HGY\r\nBm+x+wUxrUaNZT3bmqzyVj7EGcstLu1MSb6gB8vHQqkMuuYCSiRViJbZK709\r\nDBOQf/FliUR4IJ6NH5Cb1YashJsAshuADbx+smJ6hoVygbyBd+PqK6U6vEut\r\nJRUBXXV/+cAiSggfYxOm7Gqqcazx3G4PmyszyW7Z696bkXQaQ9qXZHVUCs0I\r\nKa2cIoK6V1XljZjDwyWF3Ww6GcUXnVmAVw0iObwfblU1PLLaL2Yyp/j5rY6r\r\nPQuHF6VavvVX03CBkmeRMEBZQifdZYLwOnj/MdUrdD0+Utc6mDIDMSfGU208\r\nnxVcDUrvZwNosGQATr1IpfSN6SyST3gK/EhgP1czVhkx+QV5Voqpy8kxOQY9\r\nR+ikEmvhYbegNztTQxnEgI0scFIErtMxXvBOEJ6ToGQq+60cLo4QtgPYFg8a\r\niDMt7Xyx+kpvC8Z+SrLqihJAfoLcqNEL/S8zY0D7vqEHEPUuTwKEf0NAxNb8\r\nPb2CoO9bDvLjfI56W9lu7llx8X14zwmhtVgNYGzGD++V/hmBSbzs72flRIbn\r\nX46qJzqsv5SV9sD/RGzoBU/JpZ8HhJetrVvn18Bu71hblri8EM5BFiUU2moH\r\nsQMRKmwdFrcMsjvqz1K5Kqzva8vRncJLHnw=\r\n=X9hf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.16.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1654080739809_1654080792682_0.5674797311302644","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1654080746531":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1654080746531","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1654080746531","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a30e206c4cb5ad7122c03f5a61fcb2101f6efdb6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1654080746531.tgz","fileCount":7,"integrity":"sha512-omG+i88Rd1Inyyob/QsTpRpEZrxLilWoMN1e4exAMxz0Bkl8Z4Cu8QCrkomJopf+LZtVxb9ei2N/Fa/UvH0ctg==","signatures":[{"sig":"MEUCID1tDj0xM9zBV6L/uFBEZtURVf9OFcP76n5cWJNODjYQAiEA1Zrof+1kBbLllWAnLMrmuQj3McUY2Vn7G06v5Tzi1wE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJil0UeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqvHRAAlZmEuB+H4mk9L0WaF6FFQJbPzohvHVsVIzf5sOJ6CSF9q3f0\r\ntAQa1CD2rXXmn+IQYDXhxyMMCWXl6V3b2crvUaoj5NK2not4m82ePY3Az0tK\r\nIUuM2gxpyHCzCUobRPiNIC6yuU5XYQlxSvk7co1ZUvzLiDsNrxUhGnXtk2A1\r\ngbU+e1dxsU9xAoKaH5uTh68NWyXB9OliVoDTmD7zPi+NB9P0/mmi+wjARWh+\r\nTIOmxeVNkUk1I1StKMUofsr9274HZ1Yu9xh/5tSMJCCX0zD+IC6cid/RkXMY\r\nvG9Ac/WXeEvAjWA8wS5A/uA1oBcRD2QzjLVfullLZtVYw6EfXuwpKKjwxVdZ\r\nI3TJApqfkHvJFcNFnXzoXyIzEIcLO0PGCig/UoBgL6DzXCD6sPfwjHVyDvE5\r\nFQcH2BFcKjHHSk+myKT1ohvrdakko+19XQjfKsg32/HcYuKhcpN9uvQzXJ1p\r\nTS/QoXtMT13Ta44X+gP8f5V3FJlHzH7kwI09uJra9Aoxu/oWNQ3ubg4HtQ+7\r\nfh32cJ1/SigsuHRgtZCloO60VaZPT/pvAavgUYPKwbe1ZQINJSpx07oVFTB1\r\ntm6ryZEDTJmHTWk3nTFrSOScc2bFS+ENQG/k/ij+J8Czgs5zxrsuBxbF4iJG\r\nuCpz2DDlOW6eoom5dzRmCvwWHs4TcR/PrMY=\r\n=nfIy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.16.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1654080746531_1654080798665_0.561598655259941","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669712655":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669712655","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669712655","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"966d798d33646bc134c152193503373cb7ab2aaf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669712655.tgz","fileCount":7,"integrity":"sha512-JkA7CUS5VnDn1oQoyn8yNpZ/wJptZgr2z7PV1lzjuh/h1yqiptM5KokaU0tl41oYRRHOETOJPOqYdPxyfvPr1Q==","signatures":[{"sig":"MEUCIQDKeEtzHY2SGLXCVY+BSDYsT2YPKtMu5pY4LmzSQKCWnwIgbJrgAqBsXG4wqfbf2Q+C6RVufL82XRFsD8cWfs3QQ+c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsZWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoM+Q//RgnJVUYQdmSOwIRdx5tdDb8FYRH3sIG525mbsZyw3c8Vijp1\r\nJc/51IYGUnMkOiKh2mmIplzuQZsKofHgTWLvvULg6UOky8kjY547rrtVF5RB\r\nI4ea7AUnt8W6n5nLLRs6JG/Af++xXvhTB0+Aj0YisgLk0NVyaY3RQyzyQeRd\r\nzffLEb3NRsgEdIF5I73NWTsub0KKOh1fpEN9quxzd61t/rjY6rTIVaOV9x4p\r\nwW+5BW1luaNZk9Ejl7F5Rw9tCOTDbySG7ENnXnMQZxSADXA4IdH3/gH+ZpWf\r\nRnlMiUf824HmFAbgA7cOFkWgvl02XTlUGXnu65jPE4NWuhFj2E8bTzaCOxf1\r\nWSEeQ9TzAScON02NSZbsXXzq858TIHFMTMsaRXx3F0LY+fByKjvIOwmmio4Z\r\n1Ho+DPCDhWjA+GgRMdUsCabJf/+DkYpDZUUBAUiaoOSKKiB3YBuI2p/KJFHu\r\npNp187+4QEG6h5EiMPCHjYsjtYUHpulWYZFUKPMx3dTGRSCmft1nS5vj4VYf\r\nm/nLWRP/p+IBYc9k6Mifl9+tmo2w3hvYMMnLwDkBu33VwQLsE+cFoD0ZXtfT\r\nAV1zT0XOAKJYepiohPFnz4PGBa1EYgxPDniga4+D+sqylbt5HxPwo+eTIKhl\r\nEMiEfzqXCrbnDJbWzoOMXOgv9seitpjTxrM=\r\n=bAkR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.2","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669712655_1656669782764_0.8506409359643008","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669712623":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669712623","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669712623","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2405424e899452a3efc592414694bf27371b55de","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669712623.tgz","fileCount":7,"integrity":"sha512-UYHTqb2vG/19P/YOBzx6f5LJtJ5rRD1manMv9NNM7B1LDMFqD9aRqWgxAt3ho4pAXrWI0oWxFspmhdev10K38g==","signatures":[{"sig":"MEUCIQDLVpRfhC91ODfEOni9Pc9L7Kb+c7cUylyHUcdrXHQ/YAIgMU2GuMuwTxyDb0pFwD8RfC4gj3uuMiiJX1TjaUW7wds=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsZgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpYIg/9GEI9irPBdQT9iI1QpKWFUHvR2ePyKg8Z/5MkXKQ8A/M6I0cx\r\nr3dI3qm8YZFSfsP9jOl+otEmI4zq32NpGBaCoq3S0WIMih96wlExTH2EOy3w\r\nUx0IPzpYY87E1uBgr9EMKxSH02PmOa69soK236HajCPe8yFVtv3oGuYNP8A1\r\nskp9nhn0cBQzbWEtEzApen3Vgf5breG+Sr+EwlufR4M7rgrYHq4J/HGg0/Nt\r\n78acxgghLDOWwjcyZg+/933oNZG70tSovnDV1sBgxGf1xojnvvh3NN9c27Uo\r\nXuMO36+elg5NJDDoDpjVP8mg7cBvDrPbay//ezgO+oHUGpQx4PL7vxzSb3lI\r\nEC3Q+h+9ESDHsKU8UTSpNmawzn09dsM7nns5PwZthNG51Z8iPhl2u+jjm31b\r\n/4BTNSK5gH2J4Hl4YtSBkuzIQqnHCvgELOcck2b5olSGoHaok9g/tQg1bNwB\r\nl0HNQPQ3WHNjQ+OVwt4HjHMsmqWsiEb3y9poPMXdjhTF+4V5dfOY4e6+AVjm\r\nWvYZ64k0OVQaeSpBqAT/ScW5yx73YPt7pC7TVtY47gmFqx/zSYf9iWSs9Dtw\r\nCck1zQvIF/ksN5WxFZeG/x5y0q33DxsViEad8szhNtGyHl96VDoN8WCR27IR\r\nyaGnH89av8rXHN84zTMa+W5sARLLVVZTxqI=\r\n=/Yg5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.2","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669712623_1656669792705_0.25094569149092383","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669725600":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669725600","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669725600","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9dfe133b8ad5d254927c78b5049e2cca34542431","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669725600.tgz","fileCount":7,"integrity":"sha512-5lE4a05B3EGFj/AF86wgIlKOXyD+z2EQHG3VU1cmPB2K6BOfzK4iYhq9hbv5hXX1fSu697N/Bd+4kFVQHF1sgw==","signatures":[{"sig":"MEQCIAyyhibQwUr87c/lCk+4Jgwep6cmxTapbYud12PmCr66AiAM3ggSggTUz1BULV7dG3JCozkOv4cuqcXyv7jD6PutZQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsZrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpHzg/8CYh5Dnr+FZsonXQXw5GYnoimCJNhawE0GJIDoO70AXf/XlDX\r\nZ+qdsmMoPvbdhmWzE7C49AUldY98g3OIvGEHROxXiH7B1xHqDVIpLL7cPtxY\r\n5xID0v/mR8Fj49VcEwyvUD+lDTnhdMQWIsKTwUI0qE2uwHkewuHjEnKn6HBa\r\nJqE4UYIFZD6v3ow+03nkcRg8Qz3FArz55+sPqB4NAIGRFb97nMJNsPm8U/LG\r\nFplzlUs7jplTfyqSo2RQXByjITjHoTtTsff1SYb68KTSoNq7EwwScaLPjD/t\r\nH4gUAOi/n1VUCOuQlpBWccL74OIbosOYps1fSSpE9l7zYKewB+ddP+DJyRHD\r\nmIW/76CjjS5T6Tmp+irW8weZhiTCfu+HG6U6brD1kqyb0Aq0V/VIkp9g/NPy\r\n2+4p6i/yv+XlHo7Gnn6EO06q0ICO1Qo2SurTebauRvhLjZpQxhh22SKJFEO3\r\nqwqTrbRSSuuR3r79dLno5phx7cUvobTqJZ9FuTxII+rV+vmKiIvwi163rtDD\r\nY24c/S9wH9IOp8BteGFPpEQ/BONS6vKxMPxbVEU63od1ASc1zyntn7H8sXb3\r\nG7KoeDI/jIQfIDgleDydZyy/Rdretg2+QkxyH5YHw4oL3WSck5vI26z+kqK2\r\nwVJpWVMygi1GZldLkjHpOVtfirgbBPRXyOs=\r\n=sndf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669725600_1656669803196_0.3393843202100493","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669728078":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669728078","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669728078","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"42f25f2fdcfb0f171b0e94fb91b3c193f9c6193e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669728078.tgz","fileCount":7,"integrity":"sha512-bQW0dnD2HKLOSRD+Q7OzwjZYF9GDPc5S2MCznp+Km/feiIrNdEsR02qnbFBYuZF5o5XedODKGWlJZGaJrAG+GA==","signatures":[{"sig":"MEQCIGjjDKzK4QpS8pgb9iT2x7/GETHXurU0HRb2XqLwU1A4AiASdmb17DoET4ueOVu3+isylxAWGvjS9r9XC5YQ8OIZOg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsZxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrTFQ//cLWKdctOnFoLQ5LUt0y1ebIWh/5gehJDAoU1uUmc576Qa8R3\r\n2lsfuDoD8giliI3feH51hndQ+isRBsrD//MH6dSbHHKKuQUzB6jJcC+qt8GD\r\nwEm8L685ELV4pZZpkkk3+mgPpMEBee2zwyxb0UcGn7332fsez0PbyUREzwXj\r\nCA0IlFZuJkvWg/jbL+oeis4/cVOD0lsyYmsxsYoOI+ByKckkI0Ihcs2ny3Ls\r\n1ZbRrvp1XTh4SHKGna9uHQcG0fQjvP/Lla/0/ErMMssA7JSQsz/pib0utnUm\r\ntS4ZERMg0OrQnPxmtiUce5/128SGdWyKvV7g4QyrZWZNuM9htRgW7zS9TQ/W\r\nstQ+beA+5XrXSYSSiDJOjBKeQO6LlLmoYv0/4OTVyFbiewUCxtvHDMYInEH1\r\nKdupTRzH34Px577aLG9UeQm9L0eGqbd+X+G+bX6FhRHh3OkPOBjqUWn68s1j\r\nj+MqvHo9z5PLCwW7aOMRLKLpWjEQ5qwJCjE5qzu//kDtZV7IGUhuTspJq6NI\r\nrhyEmGXQrm15ST6n3FIzwgLyJNUcr0NXB0fyiB09z6jMI5gbGC67JIhs3A7j\r\nMiS7Kkamuy2oVDsA/mWpXzullq95Za+QJM7OzZEtODLqLG7bmLdK3F+bNJOL\r\nktKBVBGmhctLe4b2eeyvvsEqBgaeeGYl5nc=\r\n=QhMY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669728078_1656669809500_0.23173237775700684","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669811670":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669811670","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669811670","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"28282c7fdff8a25f08a7d633e520c9e4fb4b136a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669811670.tgz","fileCount":7,"integrity":"sha512-TPUvg5bXXcMJJe47NGt7mxGel8V9lN1aeo8oOF6fhcIFy9/wHjgOUwZ7rVgwWE/qYujJBRPgjVZdLiSX/osC+w==","signatures":[{"sig":"MEUCIHTLaIV9HDgT+VRjFKxbF1z9rDk3o4fEHlZHu1PchJ++AiEA7YbUQcYZnVaWkzh90C7GrtiZPtvVN9GywMEfTh64p9w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsa6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoUSQ//Rf+KwG5V3zW0JI2Haw+GzI5Dud3ItOWS4NX65+PHhEUjHyjg\r\n8XtR3XkAGFoBWzuhccdQmjs3xTC6WpTKSwM1KlBZpES8f7aig24iyPVBuIvN\r\njqxrtgy1rUCMuVZnuvS7IZDyudDlwNTTX25/qFnVnFoeUkx0Q43vUOpfRUFI\r\nEJ6YwaV5DC9jZ6zx/KCqmONvvlfYm4WhfmGNgX5kIOQSclrrFPeG9a5ma1nP\r\nJblQhwojuGqrolJ5gh60ybn0UsnUNhPdDC+dfPrUuTRDknO+2jgyMNiJGHtq\r\n5TCNiRIx0ktaywH1/ozM115tA3QVnRm72/Vb5xvFeCRnKklAf/+LMe0DyopQ\r\nKMZyNMr7IF6nBlb9LI6mkbWV2CnVn5snNtlUnQmWfr2ifLETkyiqv7uvwNiY\r\nDGRdgbk4bbnaoeVI/fy0aGcgpSYah/ct4UwwFXRgZFXLiYSS48KzD8pD34UA\r\nATURFc21jBDdZPyETyVZkDr0brdCmRgCWocQcZc5pweaRDSIOghC2DXbaCJf\r\nZuLEasRsI9l08EhKQCGW//26tYqrMwO/ZwU1YlPRCZPtx1CcrwpaGlaEvRS/\r\nT60j+iuyVsoSBrFp0qxsxliynoEiuPtfFIh2YChpk29yp86uSOhMkZmdw+rL\r\nBiwSdL3La+UDAgGpJsSL6LyQeTYqtI+lZi0=\r\n=sPYh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.18.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669811670_1656669881927_0.9722285249529614","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1656669823295":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1656669823295","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1656669823295","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f88ad657b2181dfbad11bc1878252930146416b6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1656669823295.tgz","fileCount":7,"integrity":"sha512-58JTEUVUhJwNc//y1NaZ0sQw0GA9W6vVjuT31O8gumSL11Kr0OrFebzESGZbtpDSUCf3bkxwx3v0lL4GIrIWCg==","signatures":[{"sig":"MEUCIC5+X2g5LG/4dLaNq48DrDyUxWoytfqcJrd5sRLWhZ9DAiEAvDQwBKBnEY6sST3i4f+tQtdKp5MmeCqQJjDpRg9AiGY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivsbEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpMXw/9HjA42/YeeRx8QJwHwgFR+HmaaQAIRaBdQT1fQXsVMTBisMQ/\r\nWA/MQ5yovL9dGxHGGWY5MBRZK1wPl4qqP6veB8sMV3g+3Cv/ssfz8co+71aA\r\nndPPf9q5f0sm1OoRBDi3N2jVEH8y9j+v1PSZ8ZRehGqCjc92YOqKOqeUC8Lx\r\ncW3iwfkFhK0o/TJalmEDxeerijDIEWb5JAijAHVLoKM6iPKh3PdBnW4l3AQb\r\nCrMerQbWghs6YjiUg6k+5llfNMuaNYbP+xf4bWlqj/uYWLzEJNCxDmPZgpC5\r\nQuwLCQzB9i4AyPy+qDLzafbcxZ+EQDESZg3xua3+YC0vl8iIA8EhOItkt4sk\r\nCDBuDkeWY9/QEJz8dgLAYEMESzX8jYHgHKgYY8he/T0+6NnKJSkBNgyCf/r1\r\nBQFAYVDIctyw6VjJk1XJECY2O4Wu+EqyFd96RMkiE0b7x1I5Pf0tt3/KoLpj\r\n9kPCmUMO4XjLPGUiPoCsbz6jEk2eNDoYzhDSZlrMOJ1RSmNXSNRyZbNyQCu1\r\nwZhjzhQQtuS8VPT0gtPhjk3yTvnecMcWpml6HhG7aTSDS1frpvhd7evo2zf1\r\njehfVtyOgUbszdqKJbCZH3hYMnjNCisEni6WEsKjXo6UWwxgqQX6lJIauAlF\r\n3CzXMocs8dE4KHNRgRfFox5b63YlAjmCvNs=\r\n=IPvt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.19.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1656669823295_1656669892559_0.00008817498801394485","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1658281564132":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1658281564132","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1658281564132","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"c87a89176d223babf5c3799f88f0f0f8bc1ff435","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1658281564132.tgz","fileCount":7,"integrity":"sha512-F5qv+0kWkFkdOIVlhit2ijuoXiWJhBhk1QIPg6PO4NSUjCjHwqU+pf5tOkUX2SOloPKmzt2Z6mSlQw6wGe9fjQ==","signatures":[{"sig":"MEQCIHjNl9GQVNodHVMz3rFcWa4DK3m10hRSbRpHkB/2QVSGAiAn2A8csXmyHh55EyS91fzeaIKzoGOQZedkPVzCS7FeYg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi116ZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoUVBAAkJ1/xaPIPgoNJdsqPFqDQM5YRiuWxg11G4Hz/cWK0HhmFQG5\r\nVKA9/QuZsQIVRAY2EhBut4UNPo4+7ohJmibQQXRhdDv/5gquyRKctqqGekl/\r\nYOwTJARSNq1tJcNvvOvsD2FaBNJ8beQJQRVbPBvhIvkoAobrMo6s8/rZqyqG\r\ncS/NFSKgIuMIxEr5qkSG5paC1I0HS3NsHXv2z0cituJ5oOC3jF1M/ABhQB1v\r\n1oIMIcwaCy/4+KCgz7ZJZE28Qfp5hhiyHX/kXuTNQ6wdbtoH7a6++OmDvYvu\r\n/C6yGlz94C1Jn6fWIt+QzmIOChJQuWWiEzag4t/y3D0l66udBvhS2uumeWYl\r\n+mmt5nz2Rh6xYpyBkXgU9Wujo3yewNooEzEQgwOS4SVy27bnWWyBrJGytxht\r\nkpnkLXZIF34WRvWVLj6IygOcUByrwdTCyP+XC/vLVoKlHSTqz+ZxN76/+C4N\r\nUoINBZBcFXSs4Y6lO6BkYFwyRidOWUasIKPiNmI/llWpof0Edr1+22ElkIVJ\r\nS+JlQqJ25Cx/m6BHP0ATDSReVPvH/5ILBXDyE+LO6SzfGf8eDY/77m+wozV0\r\nYuokSct+uwcR86rAU8sKh3v2mjs2VZXqQxv3W7V9ROpEUhCQ6TAwHECECrCs\r\nizTJZg8xaQqUyjUskTA4Kn7YCTj9t9rfZIE=\r\n=vvLT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1658281564132_1658281625170_0.6758359003987653","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1658281566112":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1658281566112","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1658281566112","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"58586c886a7a98680627a5563d5341e5a677d9bf","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1658281566112.tgz","fileCount":7,"integrity":"sha512-+xcRfZGWhu+Fg8KppDIPFVcNfECyLyeH9H8xRW6MjMcav19pc/I5Wl70DiLOP2g9ht1DHY5kLHP49tMJsLBrXg==","signatures":[{"sig":"MEYCIQCBHzfXvzkeCqRPdDqSeRyqfl5agWk/ffEJYNu7JoXUVgIhAJX0aXb3qRzEbNm2a59anMKglclenlx9LSDfjQzEjEKu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi117KACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/Ow/+NY8fktF3/+1cgVIguB0XVlpKlrk6tdpMOaJg6fL4oGqBd0py\r\nCXFWuQFpP7udDE0yhusSSX45qmNpicSgWXn0nm9THNyfEOttZqItK4BgDZLs\r\nJ2P2CXPPM32FpFuo5m9xlj2+7Iv0DpjKf807jz4MEPCULazrT9m4NbbqvMwI\r\n9RFEBLfCWKmg5PPBpM/hUsC7allLci5AdoEr8s0M4yvL/96tyF5ouEyH0m1G\r\n2tW+7JDwHga07pkxTbJ45ZYdRKg7VrQl547U9gAnaSunIMjRNpvFbVZXHB7y\r\nB4kihioZD6fcCCMGfNcFzzUv/78npxfbnrEGsZgFc+cNY08HJALJ5i+YKvEP\r\nf46GOS5zQtL9MG7LTbXSkr18aBWQXHtjAu5MHMF3RnAP21dOO9n/IjLA6fhC\r\neBB7S/Raa469+a+n+CR6enBYu7cHADWCuKFmoWpSUz1A3y0RYXCmryLM0sZA\r\nVHRTx99YGQiz46Vbi3qFsr99qi4Eo+eQpc6SJAZtKQTqNIOOeZWQYLpJG1b+\r\nXtcnCO+iEaimOxN7xf5io6LeX3em8D5EUIUB4Th/fDCYfwec4T1UsAh7yQNH\r\n7LbcfLyHvueVduxxnLFv/xTxyYqlvhSL1SW6bx3fjdt1cvLp2d2LRBvR+72Q\r\nH+ZlYcou8XDN6V0ER07Umh5fplxIDpiFkIc=\r\n=dN+G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1658281566112_1658281674559_0.5322591767031644","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1659348085470":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1659348085470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1659348085470","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ac072156ddc965b61609a199ffec1b14a3956b94","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1659348085470.tgz","fileCount":7,"integrity":"sha512-9bhbqNvLYnhL+sZWT5sOWUFWsLKa60i6YDQ8Z64gzr5hWTpy17cVgF9kSdyhONAsk8EDALqG0MvhX36WiWG4dA==","signatures":[{"sig":"MEYCIQD2PpL41Ihwb2V+0ot/bD6SIw95gZPhvO7z0E7yJDO1MgIhAMotpKpaiQtiLYcx6Fxt4z8zEECOXIiKTTL0+IDJpzLj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi56SnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpTrQ/+MUcj91BpnMprdBQRFtTOEKYewKFZtIfT2+K6rRRhA+dvdzvW\r\n5Mq5VGE1PtUHxdut5LK74fArmxNiiaAqlekvD39SAHsDXC/BSZto+laSn+/p\r\njKkR1Xwr+PfldUrb1HAJDpZyBnFBYBWrrMiHLc56j562a3jq/WLuU9kvwddu\r\nB81iZJaqgxmcjXuLdv0s9Fqwi3KnsNW8UNHpWehpQdv1bGOf6KzSBXjInTS1\r\nNO426YAl8vbgqEYVD1PK14B3yaYVODzTg8yb20mHYAEYpYkrW9KYa3j0z7rn\r\n9wsD49NJTiu9I7+Q73uk0HZ8Pzan7tndaHtG2dVTNxccrHbBz0VrWUkaxQe/\r\nK/8h8YQq5mIjftNwVQg2JUTqWlRMx/+sg2VPA6uLNT2cI8aq9GDWSRPZFB2G\r\nreQbASuOUxiJxWw8FNMBwUwh1R0p8geTpv2R+lCLASZfa+9EfKLTtdQMv+21\r\nsS7rci5wjtR1/1C/WyfWm8PwCijCkpHOT2IvA9jxPZlZw/i6H+fepqf3qVAu\r\ng8HkbtL0r1vhMWJ22JEDxji+iw4rvO8V/fsjBX5Qb1Z/xlpIB+kVEgEeWdjX\r\n5J2NuLeZVcqIOV7JW9j14KawSqqTsSJUXhN9nwebWSl3UB+m1WXc/moWkXzi\r\nrnYx9D4jFlSn4Bt5fFkJgttCMmsB9tSgCiE=\r\n=7OGD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.10","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1659348085470_1659348135661_0.2657957725850051","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1659348081554":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1659348081554","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1659348081554","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"af0771b2a256c9cf632913be6b5a166b33d45f5c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1659348081554.tgz","fileCount":7,"integrity":"sha512-ZhzghMVysXcIy8yZQ0pc70ftpVayDpR2zJGa7vY2LVWnJ8MpHLRgi27NHCWZZ6LNama62RWgKmFSmN2cNr5BzA==","signatures":[{"sig":"MEYCIQCKzSWwMssbfzUj6S5OKAkhAbnpFhThgjkn6OyAG6mtNQIhAITIUdV+WVH/5+NwYmseLLtx0LFiGlxP+c7H0euTEVGG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi56THACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqNDw/9FqTQwaoGyxjFNzFvTVoSk1o7w7+69R64iQAvVo8tHcjvHVfu\r\nKtRAWljP2UpodQdYVIFUxuRACOpeenkPSg8PeugiPXvBRosY9ePRYkeGWvQ4\r\nHCZC/TtQwwibCu5eGbw+FAUYU2msY+7sSst2Uq+iE+ibvRg4tMQaMlxY4zfy\r\nv67qpt/fmSoQLyvLxdbLKDdjqLBsfYcAMq1L9w1u2Ng9buuWtYuw3OpJJgIT\r\n/gTMClyaK6nikTOecnbShVzftHl5guUDhz1jFu/j++uUn8SU2ptNsTGdABe9\r\nTmaTbYFBRJZXtIR+tyTjup7eS8L8Pvcn9WtbLDxBaS70hhPdASELsChLHv2V\r\ncxS0c149f5atFnoYwaMp1QDc1YDr4sB4p38KrjPzN43f6Vu6BtJmXIkU/ez7\r\nVKSr4VPBlgCA4q4b3iDPEB2ZoSwnImF8R51SKQfedv2S5u6d3anJGZ07EGeA\r\n6FnxuAPV+A4z4D77i0pr+rj75ZkVNiM6DVl1X6SgUC710YpqQhUh+DIR8djE\r\njw2zs3ZRo73l58Y1hBJJ7FUUcTt2jZDlhRjQInoV3LXHmxsey/LLLdcnQLhE\r\n4XSm+1pPXm8vbDTAHzRpxi2aJAfF1fAvDh2pN9inGFbMSn+tbPLi/mHBdDMK\r\n2hOInXx1Tevx9EftugeX3552NkEWtuPT4Rs=\r\n=EIgd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.10","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1659348081554_1659348166948_0.28386331763380834","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1659348162304":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1659348162304","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1659348162304","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"202861a12d58851b3223aa65906e3ac5baef40eb","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1659348162304.tgz","fileCount":7,"integrity":"sha512-8YRMPpTgSU/Q1eXgtj4qgILeM3oEjBVltZ4nRVeOYp+V12493XMsmlEK/klC2E1MVydZ39oSLg99fDxCwoa8oQ==","signatures":[{"sig":"MEUCIBtANW/RZ5QzTVhr9r2Ed2hzGTLPb1pA88jWgVMKHmEKAiEA9KwBARObwt9eS5NqHI26zEE8PicS2OCDQpujfahslZI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi56T8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqMqA/+MS88VcADYHnHC8qgNCHZfvQ0FrBaIscDdcKDrSz+0jk+awIy\r\nejLE06MMaedAleq46yTOkxny7EyKp6wlLZh9epfkT1xYo2y1eoU3XySuwBiS\r\nbuuE/PSOmi4dyfLWjf1yYB6l9L4qbjpv8B1Uo27lxhjZcCkOOiUs/btQ+0Yf\r\nFgsT4iEfIcmvR1gyQclmusxhOhrKvapdap8JNxGyEHSkars8U2ULjM/xV4rp\r\nA7GO2nVZRwx/JOqdj9WIyTVlw2Mp9MNr0VSage3uAvCAlYtM4SuqI5BHQJAd\r\nKFWlv9Oe8E7btKayao5/qTxLieB4B9fllK91OQrH8turkBpQQLOKSW5Rbmob\r\nRFgfjE8/lrx9CCAKVFlKReO2pLz9LORtsHotWqa+WTLCCDDsHKFpRKM2Wk9/\r\n5T8CUIgzczic8SfLGZjCBcOgPfR4hVKpf14sEYO06DH0z/q822uSotmVFccI\r\n3qemHgp8D3XChJL+A4WSXfrSrCCGBpqznUtNUnj7I2n11DoaZ3FmAy6UmnBO\r\npXLC+ETH0BqOVFbd1/QdXfaUdDGERrUW8mOGT42SPSqE0QxNfekIR6sDNqpE\r\nxEKtrfVMKHwJ5idPYtzRjt68w9qezWqaV64zphl/5tZhsUNnlZCJYm2zwEfD\r\ne+U5X1nh40JqodXzziSCaIeqOsJ9ySSJsEY=\r\n=9zAQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.21.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1659348162304_1659348220041_0.34910655943287106","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1659348188312":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1659348188312","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1659348188312","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"78789d355417d3ddf1a7bdd033ee55f276ce8e29","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1659348188312.tgz","fileCount":7,"integrity":"sha512-r36DzpCrgO2w4wvK8xv7qrifw+JauxMeD7C/xHYmMdAJg+U3cTYUPoLeg/jQf2HMJxDnyh8DYM9bommCm7sRZw==","signatures":[{"sig":"MEYCIQCVLuA2ll09bhJAlq26NA7gz+odBf8c2NmEhe1ILUCkIgIhALiR93zUhqEmqSoSNg66fyFhXMoNlH6s5zQgMg70/KvB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi56ULACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxCA/+L5PSABceDKFm+KnZFSBFvqoaKxY5Yr5HpTg7JQkr/AgJ8Hdl\r\nNN7OO5VeLrU/38bzOFp2GCIYc9QoVU4ZLB3qnprqs0sYn16ugchRk5CU1tKu\r\nphqT5hrBoPnIWbxJds0mOGONU9ZGRXamffox7KO8fm4KY/CICOPqrZhfzDsG\r\nf1v87au4X2onARj47RdZC05Cx4wDpN0bRGQo7cVKRb8NebhvNlzwhiv+gmda\r\nhMz9yGlqEpcz570FLbID3tsNuCOtC7UK1SDasDHj1m+uOc0vEiRcOdtIStt/\r\ngwPAPl3cfyMPSl8SbOht4z7NvBbsG6o79wx4qEdhBW9ezJRn+u7R1jbIm9gj\r\nU3Id42eirBZvnRtjyEytQtJrK1/Ad4ibzVv0rouTLc/hSvIPowDWEtbiw3MF\r\ngUaokLENWr4KWUiGLwz3YmQg4xjd3h4ow8LwbLFP1VDJzDWUtg7b/vQ4QAC1\r\n+CbC9jyIRSRiz5sJkTIIJT3X+mNdfC7iudsfgTSWzFJofYEV25YtmxZNJ7aC\r\nlr73HbFK10aIuVRQVZtN/TKuxrAbgdOccM6x5P/uAZQLVljH6H/oY83DMm2X\r\ngyBWKSTUoTNBmmoiuyk256wHgk081+W/txESAXAdI1TOuEUQBvz3t7w2qZl0\r\nI7AnHeF+Vv9XZi6P/s3KrM4dh0fdAhHCRUA=\r\n=aiu4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1659348188312_1659348234608_0.9757037541931177","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1659348187111":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1659348187111","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1659348187111","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"764eec420bfd8d46519675b6219f0c54d0bd96ec","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1659348187111.tgz","fileCount":7,"integrity":"sha512-tMu+Cuw7/3TnidS5qZFB6TVDGpzCz5RBJqlOrkP6ZNC5tZhlx1ZpbohOnUtreaFZDYbWhEIIT4sxR6k8IRpkdA==","signatures":[{"sig":"MEYCIQCotBYe+0LvJ0ByPsxC/ekzRfzWOpTOpMdy8xNw1cVnrgIhALLi4P7b1tv0PCjv7Ra9xkw52DLX86xKEAGuQsqOSqDR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi56UWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo3qw/+PbOqdVkWA6NzoXX67aRIBmEgagCjqLg0WogCD4HRR1Qx+eIN\r\n8EVpqBcstJ8vktnlJQglnSbWPgm/NeF2C7amnHxSpZmGq3raYJMVnpS1HOEB\r\n2s4wSCJOHD+w5xpe4FGTzGJUpQ35q3ZTJezB2M2CnKz4/28KBfsQxjCbzXQp\r\no9lTOcEH7z+GfhnmDpkGE1aF3MZjmpMUGGuoNyLJEak7XTmtjX8xeErAo88H\r\nd01YQ7zQcZOZE4fOtrlTE0gIKkNo3FEKUy5mljJCvq350LxsIDSdtlR3ihuE\r\nslIWBb7mF1hdKDEnAYs9vLkQ2KB6OT5DVAsg8pq7nIqYLBnRSGkNU4Idn/eI\r\n+zoZ9PO5mlaRM2zIZvOewqgiOdvuzMOfx/NhzDF1w0wFipuzxPLSeBY1wJus\r\ni7x/yML/JTmcojsxkvSbrD00vxwUvFhB/aUCmQuUhWk6UXvvJ7qYUmpmvx2m\r\n/1sit6Omu/UfCDuaGwfu++g/DuIUQKiGGPNuqJd8NupwNIjd5PXMbOIUfVqv\r\nZQYfptQ1RKh4gLXBxAlU4PsrolFVaZTwQ4tbMfj23ywbyjDr/xVbrqxoHLpn\r\nVgM42R+HexudytT8lK28/IBWc5g+PvuYDgja7E77d3dEnSkzh0hZOWURZVh/\r\nUJCKnaOemA3TfevLHUOSuwG0IZUvW5rTfoM=\r\n=mHY9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1659348187111_1659348246456_0.418292595085461","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026514683":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026514683","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026514683","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ce447fc663aff99235a5e6b98e8179c59ea5a0c5","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026514683.tgz","fileCount":7,"integrity":"sha512-czK+3Tr2FWGbOWoZQgN7pNuHY5iYdETNVANxMFdxN7XT4n+yiBngUmfNcooe6kbV6qioIEjf0XFqoXDyiwCzxw==","signatures":[{"sig":"MEUCIGzAM90pX6Drxm+/aHP0yT0Sus8dTqooC8SE2vtbQVTeAiEAlesu9bKol+XHkaGLubO3NBOHVf/cGQLrYoXoLuspHjA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEINKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrwaA//WOSzlFdIo+z9OCBk46jxmJfMBrwXBD1wZKjuZlJA7a0laatb\r\nw4Kgod2Ae8gyj7ItkBpIvVFjzuWg1pQbMjq2O0LmpH+XnGlbJKrY47Wwl2nA\r\n+EtirBJ9vlL81ntZ9+VZf5qDuz65kmLNZv1eTVvn2+lT7UIn8t001kZNMyn4\r\nWXAYcDhY5t/MstCtkKvIHB+yI05b5ykyaPnDrUz5VRuFYknvVW8/36leWtcc\r\nKA49LBRNcWtnIv2ZYhmsG2yrJFfYW1DyiXDTHsDE6uMbug9YpYVpKragwVmM\r\nUV4m1hSi8+Yuc1XAi5eCXbt8TFZWporVYYD2bV5b6m+qIKB9kBAnWE4jyi71\r\n0SACPhf/mNOv7HLqRekoJnzsjxz1glxJM/pc3ZkqBMelqLx8LJ+P70p6LyrW\r\nx+qVW5/T6O8YjOQszJvuM/GVARHclzky8Pc03nlGc3juveJ9lNxOiNjDqsQK\r\nlPjOpaqIq9ue2GxLJaYYlwoM1p/BkWw31SUWTGT1lIvywFP0B8h6tCN6Rp+H\r\nyUNQsvG32URh+fV56uV0Y+Bd4ZeDxgGEFaYjkMgrUdXxF+7Lx5NOTlTzjrla\r\nKvWgzkQl2gX3RfwHhaKrxMkLLaj5c9tdEMZcULpNeeToS896bPJngNUL8prv\r\nlqIP4C+B4YEN9+xFiTkJW8aL1XwYwF5unsI=\r\n=WK5t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026514683_1662026569866_0.36975006011037737","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026564408":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026564408","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026564408","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ef11b2533b1ac0e197fd5aa09043fcd07af6df10","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026564408.tgz","fileCount":7,"integrity":"sha512-pOAUYugyrNuhzEpuX4RciBW43B1Aj7Kxs/KwIJrILOq+noz6S5UdZU48mLi3p+e/XNqKAH/QHFNG+zlbNsVDXQ==","signatures":[{"sig":"MEYCIQDbG+ODQWFgvx2G/oTvGKmozxooqesEQpKyF7fqZRHukwIhAOM2XEGoRMOs5ZrDxKLyhnxI6/xcR7MdNbAiYzYUk1LZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEIN2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpE4g/9FCGE2wuG6KRwxD07z/YSHLupGQOUD4XLR3JMAmMegR3+iEAr\r\nbwDCFvhhgO1YMV3ZE6xZ8dl4BOb7vf2k/+JXP5VeevmdqfUrz1RloWny0AhC\r\nBzj0HITDTbgn6yn2RhNtypqzn4wJk4C798wYNDgZnKd1p+mlTVyk3dU5y46v\r\n9/KZnDNketc4wK7PJ5JN2Q39rjZEbMHIveXWO4tnpSwOxnauj8tdtPbSlHnp\r\ni1KDNz8Z+ib8iyg1Xk3DTPWhWriK67Vxc8S6YTR7/DUxVq3i7RPuc8uWqUON\r\nDgAhPpx92kZ9NqkI82VKk7hEpycEmoJqu7tC+bEU6J9jUNaDGF3ff8Q8DP9t\r\nP18+o0Y+QfWV7InPeWSE0tgP3OVu/MKRTTROZIqHJLeh7pHXoxriMWj6MjcA\r\nqPWH527pSEbkw0n80b95BxYVLQ4V5ysp5+bORclNnso5WPwQR4lsUzuQHB6S\r\n2gboj1f3jAyQBnGTauYaRM8RAk8Byq5RV9H/EKpvrpX6sVDScBlnBRM6r4kZ\r\nO5eNyC0x8pGpHObAOWPEILRG7H1zUDH8tJJ2+IgQGL46t/JnNeU1cfjcymiq\r\n235cUtlltiQbDi/3Uu0d63t+EDNsLfTevPSAUkNlOdBrZizYvOmeJ6TTBaLM\r\nYO/L5dqIqCNEWTguoPkC1PFPTBMZkNDngbw=\r\n=5OU4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026564408_1662026614536_0.1508187667037728","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026567494":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026567494","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026567494","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"da9218d86c8050151591ccb70d25788f4eba8d8e","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026567494.tgz","fileCount":7,"integrity":"sha512-A1HxkZC5NbY+snFeXovgjyOOtRxUjrH0hoOY3TcM7myx1w327hS714U8KoT1oBywtVinRdj3aM6owJJmtpdQow==","signatures":[{"sig":"MEQCIFdS4wjao+TnZn+q7PBCf9Seb0wx3LVNk49Ew92lMCNLAiAKCBEJNDb8daifzPEhz3yLQl+4SqBmTIaDv7GgJKi7KA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEIOEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqoCQ//cHPtGXIYNAorOTUw5W+eEdqF0FDYTKF/JXceD8xEHP49JSK9\r\n2qLutI7hFfThptxgqQSKYzlCPp2Jdol0tNAqH5+EdBZL0Bzckj0CSM1JJpeZ\r\nyui0wnppCQ6/4foE+T/BvozU6FVpogLnS/oPWFL56RW/ggfHxIopFwe+VqpH\r\no/+aIIWMD8Q5mp6IyRSW9Yyo2r9v48gv+MBnObC0QamDKNydGukf8rPQ/pMB\r\nfTQ5AzLy91mas7uhJ2Ix/N8P1ZO7vEDRhTYtoWdEFlAcoXde8nivQ4g55CZb\r\nxRXp6n8g8bRUkZ+ncu4ITjKhftYMk/qqP4BKhf0cbWxt7ALA+JSDY/Q6eXQi\r\nJHvW5LO3vVIfTx90qzubtMMqWwqzPWHWQAQ9OuTGZaHSWiUj6JiueSa8/6Nf\r\nWQt7MlMJCVp7PJR4w7deZRf7B1iskt651zdhF6NqO0GvLRWPrpNvzimWKlQL\r\nypVca8Y1nnX4hhxVr6HxbHZmgvL5Hg67qReCMzZRL2PBfsykcwGfE4e+TSi7\r\nFmFWRFEeoARnZP+1AIP8T+6AqXUETusfkaX1DDsKaVJlH50TlzyF6mJBI9As\r\nhL3qggTaluuVzWyYUznrXQ5nDr9bdNkBCBMeTYf+MTrT6qVnwTqxF6alH6Ir\r\nj8FjwL97qqFq/DBWFL1l8HsdqGyKmjBrFUo=\r\n=Wpad\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026567494_1662026628090_0.852007414142401","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026600008":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026600008","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026600008","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d1e39cbfb74f3841adf7fb82761b2b51ffdb91d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026600008.tgz","fileCount":7,"integrity":"sha512-WadED4es4AkuNZp+5jdt4TFZ0RzJ7TbRCeDmqJEVh7neWEzXwvTuEYeQffRogOdJo4IRHImGCR3V7begrzjblQ==","signatures":[{"sig":"MEUCIFNRKe/9eaSJa0Lt918mh7QfC2YvWqsAqs9auoBdFMF9AiEAsyJGq7qyZ5UlbP8NSSb5kijnyTUNZldMG55HiAIukH0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEIOSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqyQg/9EsT8yRPE0a0ugk1I48ziaYxBcBBLKklZU3FLJo8cQzW/Y70f\r\nZxs690tTFPXwHyylBGIvWdQu52SOHN/efCVYk/m1HRP75cbyo/lz1ev5gs8P\r\n37tUDQVKsm3McvDEbcmDEDdWA1GdsnsBvS56yBr8cC/P4LxIRFo5z4Tuj0TK\r\nqu1VJ/+NpbCibITQ7MYJfDZqbZFEVW90AHJzoWzYu6G/uc2majCQb8MP4aaP\r\nbDlemlIEX8fq6OLKEW2UVoY8WW0vozKVEm7OFZu+3RwFAB/JqAhEnGx9644V\r\n8qxpXEGtQWZksZvZQJPrJ3rRvmkN7USeIXCHFNLPioVnNpYltXctMcYTuYXA\r\nSGiVPTDvvpCVsysOTZY4E0fStq0MWI+4rvPC+BIgdSMWnErY0jT3bkGLxjYf\r\nkyj0vqRgLGDr+3Hi5O3MBahzgDaTQOkSWEJQyz4UQig8GxJWn28X6371zfcT\r\n43mM5noRsI0DTJRu4pNp61qvPljWm931hVL7IBDLinsR3XryQ893Npi0ZXnI\r\noMQnQjMgk4MKvqQBgMJ6ieOMPTtzDa++xQOIgSYFQZ0BNn4mrcKl9XKg9BA6\r\niyQ01GZCKU0UmyKTdxKdARpMPI2tmLPRdhXyMhLrn30stQTyc0kEw1aEPcUe\r\nRknAom5/Hnht6NxdHYrDTcB6N9kIXbXeHxI=\r\n=R1N9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.13","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026600008_1662026641776_0.09943033005554658","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026600440":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026600440","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026600440","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"cc8df89cea0482227a14b54087e9706b0d6522be","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026600440.tgz","fileCount":7,"integrity":"sha512-oJzfIXFZu53p5eT5LEb2mCKb+gBDEWQVL5MaPVak/hscHh27Qe1WP4cZ7wxoDtJ5+lF98e2dlA7cbRw17/SBag==","signatures":[{"sig":"MEQCIG7U/MSD7qhQoUh+DlFOMUwy2g7Car+DPgr6BDPM0m5UAiAKMf3l4nqYH6XjfkzK1acu/JeOvhWdH91BJryT4PWLRQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEIOYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqJCQ//Sg4f6qZN7we9EY872qPKRPbwxQkKjLVsJSvgE9unR979fSgC\r\n29GWyUUzPTUoXSC1ZKq+CPuD1En1MN9a5smSsVd54WqTNYrNuFgjLWIi576R\r\nm8ooQIcOHALaFPBzTHJQ5O9mioRkCCUHhKY/rXtuxaUtk8nhGx+s+a/6rWiD\r\nldT4T89oIeIS7w5je/ra8vKNrY4oHNSg7/aJQfOEIpuslnQf818QbATwaXCL\r\nlHTRxv4ut/6Z/xRSoG03I8oGgt00TrZM43omL07XU/UtjPERUeA5SJu+yzMb\r\n8IDA/EvQwjjPEG9vkUIVemlBIVrjaVNx8KdIyrQQiRk3foCvAKQPP8rmRXlo\r\nrQGBA8JBXbnFDKw31Z/Tfci49eXh5Tf7e0zcM0ptxDJBfTGfSgXiZLUchWch\r\nGEioTvdJlIXZWbQGVcqUmi6nfPbuxNY0qVpUeoBcZgpb5Qm3f7YReRlwbxSC\r\nOSSOu3gcsH2Y+pmvQvh4kWg/S/yJ6McLaPp7YGfbnDu99BFfNsq0jNQe01dX\r\nuCmvWZ6Q8xOM/GecoBwXfALW5P+w2J33RAqUm42oLOLH92dWtZl+dPU+AAi6\r\n4bbdujg8lPWbkjP1JIrQ67KKvT1QvXlPfTDgS0B12Eb4g4dtJgvvWE3n24dy\r\n21CYxZIAdEa5SBYr7qzHh6lfY7ZfMS2uDr8=\r\n=vGn+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.13","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026600440_1662026648706_0.11254803136388136","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1662026583829":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1662026583829","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1662026583829","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"49bd142d2e3bbce03992bf70d6c46cb9dd7c9c1f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1662026583829.tgz","fileCount":7,"integrity":"sha512-IOEcm6FE2/995/ZYcGpiH6REIWh43t7SgJnk2HDAyhHu5LrhKC+y4rwZOMC/rXX5Dse9gMGNZLaMyewTG7IzVA==","signatures":[{"sig":"MEUCIQDJFSblFVq2BLWzrOk7PBK/yly+NRHfbSUEpuHo7DVFBgIgA5zOzie6q63351k1xr95HGDeeBcbTTvm3N6OKWaw2Xc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjEIPHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqyPBAAhmKU7HOK5LK3t39Hcef1knM+zH4E/Mq++XlItNO6vRAsY3y8\r\nuhVMZcFoQI5HenJvOdhM/aJ31fFD2Hnezq9TcGR4ZugsDeyvmHPfnR++5w/q\r\nS5aco+kmgznJoeeD6fl60FDHPDmnJPEjWkto3aEBNO1VBusLhRTWWXSQCjuc\r\nG7Di9nj3Jbz/UA626y5/mi+unFunorRTO6myxPxEVidcTc/C6W33MJXFHbnY\r\nnd52q8/XfCOkEhvtVOnwSmZPad7qmeoIVbsD9Ew2Vo2ajzMKJoC6k/YRfZcs\r\nC6JeDuWyMpqQ9WmSzPkZm67Fvqm9UQO21xeFrwPUh204XEHcDzFFJxXePyOC\r\n0IS6Vp9l9B6+dWxbrqE/bHv4ZwNQ99+uBe/W6y98jTRG7u2Q1yMwjIU71CO6\r\nH5zxS9FNRLAEflbmmZMEiay5e+FmjDEaMmtdsIUZvNGzIxoWcOLlYpyYqGzA\r\necWYMqr51ajjb3Anj/KOZFft7pWE489oghA1bvSYeGCzie1o+CUDN5sAuyve\r\nDzJYtHW7S5gcn8sxCx5REpLgEcItBYVWOH8rlT6JIHeHJKz1mGtfS74IzOJ/\r\nQ5mcWQDAegSdsMSsTU7Lk9/qHws7lVIlFwnN1TI23FfMvVrUG5T4wA8LTonR\r\nrUJYIM3TdXXP9CpSi1LNYNcFp1yeSwaiaUc=\r\n=lBQp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.23.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1662026583829_1662026695807_0.02087567443139826","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1664618478727":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1664618478727","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1664618478727","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"517e8f00d8582d798e54b69fbb4f7ae7471ada05","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1664618478727.tgz","fileCount":7,"integrity":"sha512-kkqTTdfFsc78tXD/W/eC5KWvXMm/OvXNbDcVaTNayrFv4aUh+II73k59TAbcgEqo5RxzRe3h+HcAOzszCnZE0g==","signatures":[{"sig":"MEQCIGa+O7ioeIdpK8gLjvs4zWqTehi6xGK90nAIrQyshLo9AiAl9JdLlgbJURLMGBvKMvwsCxVx24s8rPU+0G0z+61eFQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOBAdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq2TA//X2ZbU1bGUWr5pdq6plcsN6W9LbA0aq+DJmPWjz2oaJ5YCpId\r\ntR8iTmIUVZo9ywF8aoJ28WDNyKmdIFKUzV4bQe3DrX+RB8jDQ0OnDFdmFOx0\r\ngf1b/e2DXz/ID20iQm1C2P2Kfd/8ft3PtQhR5k19JYxLLtJbMf4detLNTUA1\r\nHBUPX2CkHfd4V4mBVhdyJgkT2B0mluns7CdFER1VuSxMJI3kWg/ppV6tEZ1O\r\n9atko5Guu/Smv9ybUj6uhqp2NH78EkmB1491xPU32Rc/u6+4YkbaDLYCsM9+\r\ncv1OKEshKtd0yEC+dGx/SRsrjUwZz0e8POVoQToK4BaSWBbZ8FqoYQdegoHv\r\nXCVBpl6kBG9xIDfbuTBx5b0zMCy7ZIGuOumTA5K/SFnsS+4hDEjB89W3xDrq\r\nzp81rIb9eJuR/VwFwwdWOEGKiA7a5dtOzVn3mvrU3AAPk6iFtvnpmRCKR8sl\r\nFrHH/V7EW8hi8C/AEdF83p/DeGFIVZXAVzdgJqny0RG5MkMpqvsee+NJiylu\r\nwA0PavL2wpBvuxjQZsyt4SaHUkeqtk+tu0TQ9L4cf/eoaJSEYk/5oSOGN28u\r\nQ8ixiWkEV1DtXifKkCJ060dBtR7hdobhQDFMNfq66wifkKndNNbHuU8xw/0Y\r\naVqoIeAbK/ltVhKinaYtCUfQmsbCKYBS1Zc=\r\n=shUp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.24.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1664618478727_1664618525411_0.8650786689895071","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1664618502429":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1664618502429","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1664618502429","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e64f29f9e7a77ed539154187e6968f6c06bfa558","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1664618502429.tgz","fileCount":7,"integrity":"sha512-wt1q7VCsnMwOd7wu2O2ElLEv8quD+erek+mvPaCLkCGtXzQ3SqKqWqCLfUN0k6tf9lRKbJd30SdGmIW+RBxEnA==","signatures":[{"sig":"MEUCIBQ8j8hPkRxLAhqW16MQ6GEsLGgGaxW2xq094BIpzG0hAiEA4uY2uvByNNJnyeEajaWnuaMKaI7VSjh1esBnICUAQCs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOBAtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq3Sg/7BB2msSF1LE7T+dnHfNFIDF6pzhcnrrQO7eekLE/xiFp5lX2F\r\nv+VDKda4FI2jz3Ru+Zhj5ZBz6wOMpkmwdRU/6Jb9NUk6vTLv23xVoWuurkPl\r\nNTOPrUrcfKiAe/k8HkdhI0fCIrP8rplcu+lIafFJu4iHN5UiJlqHm74HXK2o\r\ntj9Da9/1zhOhRqiGbhsopQC9cK6DposBxWCl50Bwh2uIDIGn7mR2U7pXUbCq\r\n8fvHfz9GQJWm43OKXbGtczmyvn+XJVfE/XFy5K3Mo9H+5eXMx5mBdM3zZRme\r\nCc1mKibyAE3Y7akOAJUrttZVZxfM15vdoH4ajLgjt29UKwBRq/qsiR4gOlZC\r\n6J4ZQ7eIY/vDtb8JbrxCvpAA7VutTwtJbAEt/t6vHlqWv2JTH+l71kKWIAga\r\nmmRK8Bdqynv41VME3oVwve9yZ61ZZCDL6+5FHA6pVhZN+6auWiGIxsz3JrZJ\r\ne2hQ8sy8aZVESMd6PBNX6698Nk6yPWEHr1rK2paj7yAuHmIr41Q8mgop+wBH\r\nBZ7YogOGxZ2IK1vO/DIVMNqWg/dx5CdgxNXOateRMcUj+QV5oKsqgS7e0Htj\r\nj4xgEiqkWb344MfTu7BUHeNUCRSPTQTX9DQOlgZPw6KRxZcwVto5iUMj4yRG\r\nHuW1LyzAUt5c2UlgGjqIcNewOvbHGWAtndo=\r\n=fjiH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1664618502429_1664618541482_0.41017832587699843","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1664618514891":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1664618514891","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1664618514891","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"da1d51e002bc7b2d50fa254f381613d53434c9c6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1664618514891.tgz","fileCount":7,"integrity":"sha512-A7f5yQnzpfcbKPdyS0zFdot2XTgBQNFVJYCPaa03MIG6rdcZe59aOcTdn0uX1GsZ90012LpdevlKNeSxj43thg==","signatures":[{"sig":"MEQCIG0Jr1Y+yJ2AIZ51DIxhNDmBukiepq3yQ2ot8kuUpmdIAiAPBrH+MnwSmnRUmgaTOEeyd4pHjkLe1XWIl/GNv2VQfA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOBBDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoUVw//RaOIPgY+vSLQnpMG+SnWySBSDbJV/PygxaeRbRpzVPg1IAHo\r\n3YSHKzSc7wQlHRfoX2DyJ9UTferdyAAgf5/I9DGwYZZkBwpomM00C1on5yrG\r\nd9kZGip6DiJI65wAyyU7+CVUO85rulQqoPsAWZGOE5C4JRQE6aSRWVLaDSC8\r\nD0ndYm5uAM0WtRYI+VY2fO/mxlERLdY1oCIJXkzo0kczpras5sHjZ6ACR38D\r\nKSo1MvphxiMHD+CWfIjzrHI3U5Bl7fFnKtpj97Hh3W2WOsPor9MmratCsOg3\r\nbSdzs5g4ZIxUue9jNq3NUm45vcAppvrHBQ++9JMGvjQEXim1qzbSDO1Tr3ie\r\n2KHP/grGVxRqUNl8Kfu/IRYn9WEzXobziQ1hta+Ml6eBmddYDr9zKVx1Ez8J\r\n/RKtUEjjSgrXUAjZu5HRHG480+i5tfBzmqrzYQRBVoi+nAaaqTUQFpUCh/bO\r\niG43eKulXcpHr0YOzH4W1JLUEnEL9hqsZbb1kdvboPwfva7zqWBuakncpdG5\r\nmkKsrksYhLmhHL5ZflVu8cJ1W/CU8haL+jt3Jp9Lp7AA5paQSrFZuWm7dd38\r\nAH5r6XYXjfVst8AxtEdDBVWKkR2MrLhV/kfv4OoQJC+vXdZyZyVh0So+7EHl\r\n87/91WhRcJVPA1w6JbA3yMsr+R0IB0O+F4w=\r\n=GaD6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.15","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1664618514891_1664618562829_0.11703161381039306","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1664618519286":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1664618519286","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1664618519286","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f9d66a777bd83d763771b1154755ef984e1ca710","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1664618519286.tgz","fileCount":7,"integrity":"sha512-IXZ3iZIUGSTOuDbVMOqf/krhYJ3PxxQhnBB2YZ4ni3AKwa66GN7xBNpi36gbzFv3boej8o18T+rLxB4tHXokzg==","signatures":[{"sig":"MEQCIAN/AFxXXl8CNkFqRVm2BlO3T3s3D5tagYSKsqG3zrN7AiBQH+IoTqciPX6aTaGpRc+66Dvx9z6ex2u9HT4c0gBNWw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOBBOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpA4Q/+PiHnMWcAnZejgjOHk1iN52kQCwpEmZ0Huf7GfYcZ8j4DHtv6\r\nIKHVb4GCVIC09N+wODRhdt7Y8uFqgrl3UtZUD7q1eHcNkMLIT1/+HC3nc2SM\r\nlhHc796E5RfzlTIk62cAwUN18JK7WEHqI1/zS5XR8cOug+bnkC854792DZYN\r\nwGG48fDvdEx2Ik6vEKSUy8mvfXaO3SaOvP2bYiN2fm9TqY3wD/h1CjswiPFW\r\n4hH4OrZZSigTHuJjGxNDq4flQ3z/TN3ycwy4qBrt3vFg1qvwC0s3GpYbb+12\r\ndid5mGCT8Zbh76wjyYGpXfAdvh2S1otVD181Ua2fCaJQleFtSOq4Frgv+Im5\r\nsC7P6WxZ0lpZbZDtZS5eHmQ2aRDADJU4hVU4Vfu2la7Emm1GmvfDG7DGQvDE\r\nxVyhEIkHkFmeN8+TARwtJBV5hizWvz9YcHXhLN0IRtfGZ1wJjGZXbSO6agEy\r\nDgccy2ipRF1DMQyeOP26ZSWSiOfhwYunuof0aZox/4KZNnkMGp+p9gX2F1dh\r\nKx5e1g5nI5vlnJTQWDAzLZDzezbMXGoV5Lk6zkYUYvHJ+HaTYOZebReJ4c28\r\nPtk8TXd+Pp8R7dMKLkrZcIKy6JDmTNztNZdij6C2zMhaCEg5MI+bNRknrY/H\r\nYkLqJbpY1wN4hVbq2bPpSnnU0fqXmzxeC/U=\r\n=bo17\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.15","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1664618519286_1664618574462_0.9719355488693968","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1664618506651":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1664618506651","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1664618506651","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3669cfe62845ff244622f8cc901e0716dcbc2037","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1664618506651.tgz","fileCount":7,"integrity":"sha512-37XlykXm/aj7h4+vCrDNHBuAid4fYAFJfTnEsFlvE3IkNiuYyqfH+N9ePvFNFMomdoTxtqlytEPgJEBxTKvDPg==","signatures":[{"sig":"MEYCIQDUVfz9TFZvwjnUIzquPiORGXkyAmLd6gRaizZN89sbhwIhANto+mCkps1X1FC8JMfCgao7oiIlu/3CYzqdeBjmw77g","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOBByACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoMHQ/8Dx6fkIENLWSlG7+ePeKVp1jYxOAqTiSXIByqwoEHI29zMOUs\r\nlquxzRUE7rcR5yYjU01ASzirGaKp4j/EdfhicjsWfg5Zrk340Z0K9epKQ7ML\r\nxTByNJ4NtEybZ7hHxPASDSyoGndBIVxlG+VG2yLFEvPYNQsbN+X14pTK1X9q\r\nPi3R18zXSPWpDUeC5JQRPgWRgbv06FHFU+cIAyaQr6h7FPNJtVG/xffi8T/P\r\nTSBf5XKdRehXPoyejwQ7J7lrklBikCMmNoQknO4K7aVybZ7nyAcy8Mqm54Ht\r\nIWrV0kiGQFJPKhvHCf+K297eqjtVSJ1xlZyS3fXYb/BP2kK/bTJ7V7TVAFCl\r\nhwwg9519OxD0lXj8nurYAhTshOWQI0qZDYpjnYTAenQCWHMd1m1I5hGtA0bf\r\nKyi+xrgCga5oDP0mzCKUr7sX2Ap9YvcGa9KFKeZIJTcr0m/gM5N8shakuw4D\r\nQuykOLn/2zj4ljST64eMWjAasRsswNjF2GJ9UgEzC20tM5okffx33Jt8W1Ei\r\ntKSDTXVl+LYqP4hSZSfX/YmO5hv76qdda93+nFmKUhf3+jNcIKLo3Vyuj6Xr\r\nsou+Sa9pARsCF2WQWfCV3Rp2804ySSCt1woXZduVU6fEgh+r0OXj7o+rc+zg\r\nPJGLSveOPBMejR15fAZQnJWm/mbhPjfWPIY=\r\n=0rtG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1664618506651_1664618610016_0.2305335167720175","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1667296909419":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1667296909419","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1667296909419","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"be238f4fd30dbd9e82080bf485a74ea4e35db335","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1667296909419.tgz","fileCount":7,"integrity":"sha512-8V0BAodQoa8A6ovlaN++ew2IFy2my9MCJPSZ0QzejRy1ovYIAlOF3MkDw6wtsZiYH7ccM4lomasRVykTiFM/eQ==","signatures":[{"sig":"MEUCIDCK1pPp98GFMWwYDCW+jhGH7gAbtIJyRxKkjyFzjicuAiEA81VCDoih5DDcIPt9OupAdIKfdjSrAYIbhQxWKGHO/qk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYO66ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrUYA//dwmb3OrMSod3h+9KL9fsW5IXxb9LnVVAYZjsSBgVlQBbPqKj\r\nfv/rWPihxBRL/0OxTv8h4XeOYI0QQ8xDc93+592+niOdcqdTeiEkEo7BzmB/\r\nM+gpTNl1m7NMWys6BJ/hUq6vMdG7QB+7aSruXUpKxnXmGSzZsgNKaZe+EDxz\r\naSRwJ5DcFgf9l6L1U2nAmh08enW1WbCTe6BFPa3T9O8wH7TH7ZmCuxbNIXhu\r\nKcNVl/fzO3V/Q7/0xP5Sg+VJ8zxhSkCzVGzVDbkyb3mP70JqGb5gaBBJTO71\r\nJyW5cFViTIr4nCm+obMDacWLtzV8W5uL2DdU5xmx0XCbQ/+j0QOvxKaSSu6O\r\nMpF5+TAi2hHc18FX9wPMHLEjZEWMvaCkUSDt1UCmgZ/4dNpayOCK3QHNBgFm\r\n1We3TYg6XKQIFSYS8GBk7/+qwQeYauk3Op79VOngpKj8HT2b1D0/F1u1LUTm\r\nToOB8a/J4DtzDiPnYLSd7aeknWoJS94P0EV3dnMnDJtD/OvhUU3gLlB6/+FL\r\nONPxBoeybMS1y1rs8WLTrVBdKxzQjf601cj6f5ay8dD1W0tsyhj4HFihPfcv\r\nWaq9vJWHoXHxauHx9ThhiC1hhe/GMRDC0gfXCnGw3niNdsmHp+yTd0MRDjfF\r\nzQf7DlSqDShnWkJP9zDBTCtbTIcb0SBFzFo=\r\n=HO40\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.26.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1667296909419_1667296953969_0.8864183832517634","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1667296908891":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1667296908891","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1667296908891","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"2b83272bbbcc38d7775525b39335a4266e83fed7","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1667296908891.tgz","fileCount":7,"integrity":"sha512-M+Jipp+WgEa+hhPbpT+A6Fw6tL62iuPRzkWj33mPsvcyJ7uY+K4+WNQCYoIw38u4LMeG0l+Ti7C5ZI0VsSeDhw==","signatures":[{"sig":"MEQCIDQAkEsGvLA6VTA0TFK3yrRkxFt2WiFSz3otC874DmFVAiBJoCDXqWh2mdFA0BZ2HfvhoZ2T+vgObnOxhd486Aiz6A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYO7BACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoKaQ//SJ7ceXtvx4gBAPqLjZ/V7LaVmlw+twUSGQlpHFkqXxxXEf4U\r\nuSoTfo/QE5JD0CbDB9EEGL6V+o3JLhA4NpHS3EChMtjPrnN1PklJoDQlfHBD\r\n3UVo6OwP5fM8XwqFvVQWeHh0/JP+yMhc48oNhARkp4m0ifNSZ/4EbvTnRetX\r\n/SjeuRve2+lMOPLcVYg8cdbqN7jyyVD7ydRRIbN1StR9cgpRORveGE+48BTJ\r\nhBIc0JFbEiqfQcPmesuvbLLoTA62ZtXcnf5x00gCNIn4n9iKKlLQAGb972w1\r\nAG2AykSsIOJdcVr3P4RVkS+s32YBjPUsnx4T6SaIb5Ov6+3Kn/wDey/oNs1m\r\nx3nLdcK+h7g8JLThlIYasTMAm1cLQttPTgpgNMRagpNNMzolg1YGCZ9/PMCd\r\nvh2stCq/tmd6ikCox+xYmz0xs5GnAIg423/Rr/vgx/Gxuor7Z2jtu5LeBA3j\r\nT8R4jRpEYxWOB4NtNPC42ZWjeB1GYtcO9RFqycJm7vvhkkXopJ3QiJAF3MuQ\r\nmFHL5NuOURsrcVhRTAQxEBPV0/yCacjK2D43VdLW6yP8uCBXTYqBXTYvQsgD\r\n6RZ7MoTMFsp5aQSuUmWRohgFFRYmVb9weyvKP+ZF/wIF4z4HnKaDkFCZSy11\r\nuvyubLJ/KuFU71GHmxUxEz5E/FAqSUyScqA=\r\n=rgbg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.26.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1667296908891_1667296961068_0.0006789824014981072","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1667296959258":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1667296959258","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1667296959258","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"083ab34d47f4328b4914636fb9fb1747d327be89","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1667296959258.tgz","fileCount":7,"integrity":"sha512-2lA6WgxWS905p/JzZKq1Og381ayczNSSofUp/9lm9zVaBw48xgL5QUGjdCjAEruDzUCk9j9SsHmwICEHYZhEvg==","signatures":[{"sig":"MEUCIQCLEr30aefkJ9gvgCSTjxRPzgq+RTw6sAJaHVteQC2CgQIgRMQILk09+axwfJ5WNCE79v8WwoNtSa8TIapYywBRdQA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYO7qACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpALA//TAlhp3942G+3vb+GxCZoVG4tsQ+pnhvrPlpGY/ruMrQyodnk\r\ni6eFguNZd2MzBcnGYAt+oZC+5MLFfl7FBthz8aJwXzXUivF2KW9KkUOFgowM\r\ntB4c0pcdd3MdyqI3RG0j9PmU0u6Fp6EqdaXkEgeB5oDu65WRAu+gYrqwjask\r\nbhMGQCrLaUcGzVBjVpmH/giZdVs66fkPJ3a6gdDtZrrpiLkVjNTjg4t1kmOn\r\nR9+14TICqx63U/iVYhOrXvxtgFAJI+h3l1Cs4INVomc8Q9i0Bv3u58kmKtrV\r\n3ZWSucDJ3cdag7+83ffux46CLlvRv9MtaNuE0Y+V7ewKOrHcWoDoWO6T7PZ3\r\nKQgFwVrPb5XDYlWizrE3+mHQfo0i6SdAaS6P7whT3pyryIgbFZWDCvSKflhu\r\nVZKSsF3t0x5Jd5s57ot2ExJai4I6WdwQu9NYXhyv9misS7ROorhqlSBJ5FNd\r\nhIs697oKFU4O31gZXYeO0mfuMz6p0p1tKyLMKbwAudUr0aYsBOsa4CTD1qJA\r\n6j2DhnM6XvhU2OScu6wFPeY5V+33BbFjCC1XawoTvtCbQM9ob3pwWgpsf38p\r\nIME3VllDAo2qChl9gx7/N2i59LajQPOt6DMZEucH6M2x4Lkmsynt6e865XqF\r\nbPnID5cFINeXodq4qSxYJKsD8A/0eL4N1FE=\r\n=28mS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^23.0.2","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1667296959258_1667297002593_0.33072154732205195","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1667296963164":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1667296963164","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1667296963164","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"52fbbce1339c5088402438f58bc84f44eec6cbf4","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1667296963164.tgz","fileCount":7,"integrity":"sha512-EkC1un8iCOQIk/wJed8pcTEIEaHqYoBKLG8IO4s9wjTEfutif254e1+PpMB35ELlrVdTEfgIi/qraTJirnXxtA==","signatures":[{"sig":"MEQCICxFrkOPruu2+/nADdvSAEQ50IC0Xeiuw6eaW1V1NyoMAiBrawmynDcOIgViIKwpZQa9PeYzwhImcM9E4KesYbWfWg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYO75ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpNFhAAonM+r1sRM+zu3i6Kk3BBthVnjbEyyiS4T03FOqpxNep5meBT\r\nUr6XLpbbDDncERMzVjWtE3I9zZTc2/HJcvDyG0nGFWneZl8VlgR0a8sqIuxZ\r\nA9eyny1kKBdl7Q+v8yAk9KAUHe69vJg+MtOdUOB4NZaM23o/0MeQoSVvRsU7\r\nGPBd5OB3p+hibj9kHIx+JNYJo7PTlXRvF7EI6f45MZ2hCwN3fY5FQDsCQU29\r\nTJMtIx1d6IKAzUdOiVMXuJHv7VbuJYHZIYXyfUrZv6OFbcZ/52UIOhaGB/zs\r\naJ0mTPaaB7QhnNFbW1JvnvGYtILLho8STY6LQ47WUMnSTipLUyHTJV/TEr5Y\r\nn6/4mLVGYHJRrNgxAM85AZuY9khMYTVGtQ3ADOC+YoB6MeFlTv72+Oz8+YUc\r\nuS9ENpeNL3vldDLtuS28XN5eB35ghnXDf4qMPHrHvyXjhGByfArenNjBmJvX\r\nI+CBF1PNBGdCmnxEGZblrSGKHentO7am2Oj7KWz5RZuGNUEyGh2VpSdfx1np\r\nZZNCKU6rBzecm85CqjPJQ+3lhSdQ1vsjw3OBaOjh+y0zxnqfp03r0Cmnh5zK\r\nrMK3mqAHRz7UCrWtBYgSMsaFgycF0dXSPM1qteguCR6FSeCHrS2zONhqW5jJ\r\n4IrX9/+29uNSIQUQM8ZUpr/T7Rt9qvJHMgY=\r\n=ZsV5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^23.0.2","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1667296963164_1667297017403_0.4180707205330241","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1667296977305":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1667296977305","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1667296977305","maintainers":[{"name":"akarst","email":"alexandre.karst@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"09c4482fd6daf739b48801776ef076e31b3b6f0a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1667296977305.tgz","fileCount":7,"integrity":"sha512-o3ZU3gcN740uEOtA4PgNImYLa+SPYcUBF2K7jn8+yoyMYeclmcww2R5nNuLXy1eVAgskWH7fJqJRNPWhUyOj3A==","signatures":[{"sig":"MEUCIFoDH0WaAqslET9tT+mzZXxowBQ7H3E9tLnvDF+4jXYwAiEA6GPXma9GuepFvVCThBFsGkvz/xgIcDMeyucRrYnYoOw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYO8HACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmruHw/+JQ2dSX3SaGW1dfXV6Ov2/vh1Yf9nI/OMG7P17Wl5N72w38aE\r\nibXZ/jHA33bx2fquVXvwx4w9gXTk2zAGVjgLt5sI8NeXFWVAd8xvsohQzizN\r\n02BhR4T/y3Q2aTD+Mhrx71e5WnEe66Y65sGe6Ysqe9PogQhQCfkFjsUsJ6zY\r\nUSltByw0tq/D4RqIoNHZCQl4sql3vbWAWNclN2CGjhvzN8aYkbxTquVN0UHC\r\nuwve8IjtPbd2l+DnGXICXPfJogEpubyV1LGhvC6dQMzeGSnz9OTQFTmrwrnA\r\nn/1p9zQbfT1AQyJdvxnjg4eL+l+HcaHkfR3w5e87cPyk061JL7tpe0A7iyUG\r\nbDY6ucUaFgJv6O3XSQ6231NF1nMXEI1uldVg/9cT+ab7RSYgtHB0FqHLolpz\r\nMkYzJaQHZs+t3ytNI3fwLncXB6kVXN8raNgxsooic4ATdZ0l0zGImbKPC2L8\r\nZyveccc8eygwPyGStTSnJiaqtkWQ9fPykOoTM0KXKp62r68SaN8mIzOZCErW\r\nb8jmfR6T/NxYVWc5zuliVtFbysmxNkUNgSANJRO92jfOZpHmKDdrq+Jf0Q9E\r\nYp73AicOk6ljfJym1DZBGzELZMwNp1LDCPHLTYlwor2oy2QWh4+5QKpTFUC6\r\nqu4ysKWX+LBeRr2eKxL/58JqQIlc9EcBHDs=\r\n=Nwvk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.19","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1667296977305_1667297031203_0.18689354116299262","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1669888867650":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1669888867650","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1669888867650","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"baee0eddf28a7f551a3da7e3972644516b999f3a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1669888867650.tgz","fileCount":7,"integrity":"sha512-Wzo3lKoVpE4kvRgXE5l8Wz+L3N+Ejk8eup18TrMsCvi8zGz4/cr5jh1RUzSf4zczPMj6mkDG9PhePDwmUyAm8g==","signatures":[{"sig":"MEUCIQDB5J+FvvAw2Xzbqx7rtGC5x3Mpe79O6AMzmavUngc7QAIgW0Fx/4ACmMWVXjxXq3tMOwTp2JnypeH0yV2w0Pe/X3M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiHuPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo9CA/+PLLnBfRSGBg8ulqbCeCjinEIqHFbuM7kNK0vFeU70jF0/g6k\r\n4BXkY6Z7T5Xj7f8aoiY9C+x8kU7HSLSVbWxNn9tu/1FJv+odR58oWMSGDrvs\r\nOe+1ob04TZNNYskVwZg8RuCHN/VEvFY4rxZf6HofiWKjbWJrT8flu6DicDJs\r\neMEdhM1q+PQcGnW1vy+oVBo4WBOb9PduDaZT9gr+lPkJDNj8wPKJDv90Pndp\r\nvprgy7sXi1spb9H8aq1uHQdSqzM/MUyZ0F7S72BUG1OydPqoVfyAOnbuKgsz\r\nLt/nRUhEf4pEFFmj6UR3ArJV46+R1GUY5ugiJmE1F3Y+WRSh0D6otLJUlrFn\r\nQF7GEk+z9XyblH8V1hfmNM5oVxxgRtpRU4zaHqRwocbazIVBsMm+VSGhRnkX\r\nBXuly12juwvbcxS3aho2E0VsBzMgyPbZ0G3jAwHqWLmDiiO8Hf0bg7Qx6qy2\r\nuhx6XPaUKGBIbX6NhHF774dJ6Fbj03pk6dpJPRcF2VQ1Zs/xEzsNktpAWuMl\r\njqKo5o6jWsSEmfb1kNKXjri20te0YFrmwv7whHwcilP4TPaamnBtKm4fFrGx\r\n93Zg0AoCrZsEcw5kauWTr5xmyU+5KZONxLMzSrsOWXTecn8VU+DSEGrUeUvy\r\nRNuOMt+b4ztfhk4ZdVQiZJK5mFFMJjeFoGI=\r\n=E39P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.28.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1669888867650_1669888911087_0.7838379302179335","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1669888874011":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1669888874011","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1669888874011","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ccfee5830ac734a2d528338395226dbe3407a73d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1669888874011.tgz","fileCount":7,"integrity":"sha512-uS5R1j/RhiLqC8bGapU+XLAUm6kLCgH4M0M2JySf/bgVexGgwwX97NF0NyrDSyj6Sw7D436KvYBCQo/WH3iunA==","signatures":[{"sig":"MEUCIQCAw9MIUBe9LDkk3fgamvMhomIWkmmFBojPecNaW3+uOwIgYJzrnENFBAblyMkM2yEQRzAHJRxu0HwFHpGmUXEIgDU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiHueACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrKOxAAgQgtyu7S92Ljfswq0ENKTpaHo4gmAoeLv/rsXHaR897bGW6J\r\nM6vIT9hDReQBAsGjjvYUxHJDrGx4LvFI3FxPSfaKKtfWtbU+q+0pomxkZFC0\r\n+NSiQM/P6rL/+VsmZV2sj5TSV2ydGxCXfNtOXodVK4tzaowxLgzsGZQ3vLyJ\r\nLHzoK2Sboo6mdsHmLnJrJ5kGDGWdG0vt8jueOfXhnjgc78AbgJb29kRoN1Yd\r\nHbqTo04vm7qltpeeJZ0e66ktkfW35XnSfiXjqOPL1ZYhs983y71/fmI8CP/L\r\nucLslCR5Db+qErWz4+oUqpFP/N4vYLq7w11gQoyYk+B2iwJPNFkBWA4Rxiiv\r\nV9yKkOBW9ofEEQRVY5cMEOHqNeP7JVC0lQTx3jfy2oFBC4Zi9GLTUN4CBswW\r\nxcCT94XezC0tqPVbPH8UtzzlehdmqpSPJ6iDJrHEH7lkI13e68gXpsI9gveX\r\nAEqCNHLFxWH1sWzVcXyxJA9jAl3s3rP9G3BrODZ3rqYo2aL78Ydq+8shugI+\r\nT3DO/kyfOwHKeTuP3G29Z+mLeVfhi7xUYZRZF93SPsxup62YZ6lu/IdnngHJ\r\n2vVD80zCCUVYytZG7TV8vDdBKlyvFSpSoSlTLi47TpDsjH5yDbIkpuX6Whel\r\nQaFxxTOBosDlzZFTW/ndSPnAhC70NYcFofM=\r\n=uN/x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.28.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1669888874011_1669888926741_0.37923234983050613","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1669888930734":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1669888930734","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1669888930734","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"23878662ae4fcdc302ca043d876502e53b6e124c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1669888930734.tgz","fileCount":7,"integrity":"sha512-SabrtV4yP8RKLLB4Lfvm6Gu+K/anQCm5TrH6FJbizpwqoldn11YSEQ3Djz0cPQPlwRM+3vIerN28X2UrPBd8RA==","signatures":[{"sig":"MEYCIQDw45eQd3ZoCBWOucfVD7S+zT+szg5zS9saTPJYRzowuQIhAIhpWx+2MC4NmANLxwZZQcIrqiSMrbG55RI83xoYHrK9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiHvMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqxeA/9Hf9FU235hkxPgW1AcVphUfWGKgwAoJfs9eikufSVRYCRdCXp\r\nC9XL/QKUJUdFXiZuSM/sBHlYdiNh54j0fEpq+pjp84Z5x6woio2DTCS/T+Hm\r\n8aDL9T0mUCajRs7iHB0FKcptYF//SyyR7mHWncA9L1ely99STBcfJdVBnT1K\r\nSgCkek4RXvyLgnlqnoQhalctds18I3BWJ6OhbfR3DTT6udaEjdf9xyGAatU7\r\npDta+/GdTu3rn0ok4Pcr4mwJSFgY2139VadFwGPaJll4D3nL4EG4L/A5Wcth\r\nMqxZFZnFbKMlYqYaAXViGev4iz0MoUUYEvfUrhVSvhx1a27gQbieSiloL1yX\r\n2yaFTNeN/xwsYhVLS6xjv8nsQg16Wqypq/VoYrJm27uX+RD2/8LOJm4d2q8A\r\n8odNvnCNSNnD3MsQW8xMPOQoBI7dAagtsZQ7ABIi6/Fu665JwtHY+/7bInKE\r\nq4fuAyRcaRSSSy4wXclcLyavhUx9PlWtfQZUKC+F7Jb5UXyyF2K8uSACZOHr\r\nEznchPXmyG4YaYhhvExE6wyvdkhbzM3CGbt/G4BHNuRd94LmuS59U3I4d/P1\r\nWVCx/YRS8v3jd0kqszxpZJWJF/vSNA7bIOqgbQdzBstP8p8np+10RhcTw3sU\r\nOnyhHZTXKYgsQf96M72eBIi6j3sLxZN13cE=\r\n=k5IM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^23.0.3","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1669888930734_1669888972200_0.14051974354180885","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1669888930533":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1669888930533","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1669888930533","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ca8f29758af0287bfd973bd4a101b4256fce9a5f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1669888930533.tgz","fileCount":7,"integrity":"sha512-DMN7WLeAuperQn39y+V22Yldl1GNUg8V2Mn2ZeWcaqV4lFs7HOwZA7+eHFRla6xt4nHV0p2fMUWhP0XoDPAAeg==","signatures":[{"sig":"MEYCIQC6v9DYEccy4xcfAwyIZ3xX50M8UGrr/FDznse54/e1jwIhAKqlSAbfdiGswZNSjSWwK5R5dQk5KyoL13iq58X2PWLM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiHvUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrCmw//bqDq+kDiyQ5euXqYQbgFbkwV3jPmIexVKms3NfCJqfbUMUD0\r\nKUFTySRnflxjYXDOI+7pKIY5iZpyOmrgmQgACFFYKgvadQaxjsSlAhhTTVbs\r\n/tdnzLS4HD8S2OD7XyctSZ2pmGF5n7ElSTGr/pmriIac+MIRPwTVRcn24+lG\r\nJnd610rI8Gisk8zAzl+Az1BLQCsOqdix8HJKan9wPpecZTH1voh3wCuwFleR\r\n0J4Ingvnu5x5dDj/2FZNAdT3T+WH5uePccroCcuhPhgAZ5WiFJaGW59ODHTD\r\n9CKowsmXoVqJV3X1fdPn/6DRR79fpHiPXpzRqaubsk2EIX84XPQCzIwQjY+k\r\nkIMnVEN0TsfvieiX1STHDQdi69InQ9L68rGv6Tk1EhmGGZTl0llN82yv2Bb7\r\n3gsf+tfgLcQbbx0G/E6LxuhHfEmV8qNWluUwO+C9721wBGJT9316JgsSQDTP\r\nr7HQtX5DSBJLdKG/jsLyPjizOHLyfs5Z52W7tXsNEZxy3OJuvVdipcsYO8aF\r\nImXE3YK/Mw2B6b7kbehCxCT4zKnvB4OemULZELSX7Sg12zM3PzKkB+V7yuzm\r\n5QN4lBsIcE2fVYcInIMQ1QUkNFN4f5Sk9kv4tsCEaXRncSARqwYe7Oitt8HM\r\nuQFZHSAbtjjL2q/Mb4KipaWeDhp0gZPhWsI=\r\n=sqAc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^23.0.3","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1669888930533_1669888980671_0.49898556347116463","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1669888962006":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1669888962006","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1669888962006","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0976b626444ac3a4c42d1ef32150206873a0aa65","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1669888962006.tgz","fileCount":7,"integrity":"sha512-9xQu1qgyZ2jDoCPp9y+QY8vJ7hBl/R5C53y60fCs40zQ35yOgejxkxc7S0ugkiAyofnSABDViYV+1IAucDk1WQ==","signatures":[{"sig":"MEUCIE1zOFcrP0Cv+c/TEhe/olt9onhX0m7IeMuTApQ3lPnLAiEAscdmpe+hRnRG/rzDYxNQspdxiBzD8O3yqyNUlVh1rQI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiHvsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr6eQ/+M0xQ8HS6QzQtgrnuqSC7dAl1zM4TgqzMRmGlw3snJ8jcPmbZ\r\n8nnqyL/MSGNAUv+ItNcqZdV0CoE16/wKhI/qzKroBya30Ddxo1EpQQlhIZzp\r\n0q9Hl8gJniH3UsF640W6e1GMAJpSteDFHvabhiAAYNzp2V3YgoHN/7Idc+i8\r\nkBiEd80ZnpYXouFUwFu2oRhk/xukKEfkm36A5ZOZUqY4JT+zaQ+Zc+4TH57M\r\nIcBmeDxXTh52645KQmkevoCD9XIa3QrWOYup4P6+/1xRhgZ9PNYY2xDziv5e\r\npgqFCFJyalAVFqN8mGxAI+JrmTpQGvRuE41Vx7l/GEqlHjIeHCrx4q7Exnc/\r\n52MA4P+yNbUt+GlWRYVTRrss+Ing2WbTu+cbvS/xwcymIkrU6H23jSeXeImi\r\nqWLt90qq4kCN2ep8jajvzH/OSsjVNh5CSxS7fESogY1CTTh+jxbc2pN/mH3G\r\n1dGCvztZtBTfrpHKcJ8amVcBoHIJsczgArzX1lIwTpdyQ+y+p4rB7NCk5h5M\r\na3teYKU33KnO/k4nt7XFeBGaf/0Y9lOS0l/Ho9ipUuLbsDWkMv9MFTAJ9teK\r\nb8WJjVLNnRxNO+4haD50cCtKSw9iuJPGlT2kbYDLaPLCtxuvr18Es1T4Yi2L\r\nX4SUH/DcGY5VTeZP8AyodYu4oeiaq9+GmHM=\r\n=1R93\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.21","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1669888962006_1669889003851_0.054077289713989396","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567249462":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567249462","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567249462","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"793ac22874b98ab84fe1e183f455f31335346e56","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567249462.tgz","fileCount":7,"integrity":"sha512-9pwUAAlx2i9YoaVlYXqQNpnmlw6HAtIbeZxlWU6B2SJNz5rKTq9O4lsLdMuu8/FV+9ZzgiHtqI0hlmh/ffnYtg==","signatures":[{"sig":"MEYCIQCm/FMDJJ4fam5XM9+NCqq2vWGNgsAiimBnYpKcOgMqngIhAK1EmRnawsPKV+au+tn3taiUzm9w9MxJewcFW1TuqdyK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVn6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq9Jg/+PU3qCPs6NvFF2aRZw+BtlyQiU7tTPLErDXIj8bH4ztLpBKCs\r\nB4bY5vP7MwsBVywEyHGLrtLmyxPzpt3NZIM8pK012w8f4mHr81A/MNvO0l1w\r\noY7kooxZfth1O4XgvBRZClTIomorPMYZwAk9URcosi1lBIREgYTSpKYmWrOV\r\nB95TZRFCFqf+VXYVLH/DVf+vkfiMBBe6Gdh4/GbzSK1qsZoaypcOrYpGwR5X\r\nA7ri4KLsCV0RgqniASSk4PfhnqVMEnazXg7xrVgby9VbnRSqbIOBjjyA9e6B\r\nQh2E7GThmYsbSrlX9S0kWp91JMUv9rAgtKBMrBttArTBvuDutCgJ89g9mKOD\r\nZVO9uUQCiaRzh0hM+tPOMXIpqSoOmiK90+6RzlKXK/JVF9H4zcWQ4qgPXRzk\r\nGxrDQWljbkPsu1yxZFYVS7soxyaH6b85D9JRAVXnVzfQWYdvTnfe8rTT+/sD\r\n/zsvnAAAAnVTDvtzaFtNFMuBdq32uMr8akb64D5A8wNVX9f01sJk/lQSWbU5\r\nSn0WXKdX8eeWpbv6uPWIR+1h4llsPHY+/DdJ44lqCkv7TSBAKHV7+T1YmFQj\r\n7lTbcZDCXSba5QuYKmMn2qULAMZeo6XWbBrfSqQhWLZopbJK3ZxmLjhzyc0T\r\n5MGjwc15NtZ1b2p8C030Nca8213Mz2PuWOk=\r\n=1tRC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.31.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567249462_1672567290224_0.05493964112458638","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567251540":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567251540","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567251540","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ef660f09b928f1c1c318f7338648e7c85254730f","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567251540.tgz","fileCount":7,"integrity":"sha512-8nuWz4+M35Bz1IzgY3lQmtWM7VMPpLFSs3H7rYrKfYN6uUCVmDjNqojLP/5VcoQGZlrZn0TR+1UFm1E91Di9UA==","signatures":[{"sig":"MEQCIATVmBES3IgcE2FbvBhaRuHzTP0Q+SszxCF/xJKjnHnwAiAv5CRZINWft/0DhvG+nlQQPlJbs88X3IZU/UegdkdRMA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVoHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoVmw/+NF6bSbIJ5tPdQd+bILpL/bu5vxmn+NJpm8dFBoAb5EIxhOBq\r\nKKfmlx+Z9ndmvyZ1WUGXDk3PuqFJcjoemiNc9ctbSYOIzfjtg3jO7vUc3+jN\r\nzs+EH3P7I3vXLq7f8zpyuZUf9TOT5sb6lXAMs6WR8VQ/QIDWmsWEeF1x8OBe\r\n3DaS5V0y5GCPOONZOvJs6TM2dRViJtNUSPrhUPgqsh8X1T71CJ6Tb2+fOMpk\r\nFb75Q3vBZsvBlQD+Y/TT/qAzgcocjL31ktxascKvUIRG03vIYj4TvSlNEKg4\r\nliMeoXzW0twpULINCEoTSPb9JVtIcof8wVy3N5WtARfhLxRKGkg1Bx/3a8E+\r\nMxCjFeRIGb9t5m+a/bdNnDNt02qtrulEw0H41w2L9jqrtzOW7++tWkAeKo17\r\nvQAwSLb2yOamdhCndNxrANKIXKmj4O22jotNdqQ5DxQIyTg1qBfp7PsCtAcL\r\nxvfKhoCLqjB4F0YW9mKLWl12VokQewoOREjFEx/nlP8lBWaTfa53gZZJRthy\r\nCi1rDN/YKmOXyPf3iUgdq3RFjgbg1U1CRFE0XMoJaPeA8E5IpLQlWxg4Bf87\r\nzIoSGlDisDpzL2+COYxSEBTlpIVjfDfYvtJpugYt8h2bQsAD9kc3zs3JbwpY\r\nWSJh0BFy8nIWEcu6boufronM9p91kBSf/go=\r\n=ml4z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.31.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567251540_1672567303043_0.18794662264869855","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567390401":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567390401","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567390401","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"0f639138edfbbfc1759a45eee5967f9eb52cc200","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567390401.tgz","fileCount":7,"integrity":"sha512-nMa1jXAqKijhOmhwAK5MIXUMX0tQ6nNRjYI9gWLjNGS4+KBGq2LR2nLqAhuWPeS+u7ECFvnhFAqRsjxi3gHpww==","signatures":[{"sig":"MEUCIBjViasE3YD1OcqSr7YwqKo5NC0cS2nw4+4UCL6UXpPJAiEAiWg30/hGrnqE/kNsu/81IDr3eNekmawHFbb2tdkCI6Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVqkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpW7hAAk+6ESC7CF1yBtnsXyj3u5ITbq52o4CFbjGwlZMZDQg/35Qad\r\n+9tK4WG1IJ9yBwQMjRNF14qoKQAcHdG+XkqksX+5CkWn4XaafJq1kwZA5sxM\r\no5I2vm9o+P7OpSaYcM33/1auNhRp+IC0x7gHC/lxeu6yCI452ipnfOE70WKH\r\nSvYmx3cUPOmjycE0qauyLltZrCmB/EPjjhM8DfGOmugS3wPpuC8ioBf/0Wyf\r\nKUF1VHG1Jdkmm8KXOzjE0pD9XdYCgR56C9vreMHCe7rwErw4x7RjQnxRAGWL\r\nDhhViqQtfno98lJ9bx+N4FHQhD0MPs7sKfkMaKAUKpVmIYgPN1NCLjRKsaCz\r\nzQ+NL8+sAk2940hxVa9oh+Xq9vqWUXs3KU55grIN8rT+8m2mjRxaprT12QPv\r\n3d/KBudrkpX3njUYWtHgX4GvUclTuV5DJf3lZBP4auByu2VaWsLDC5c9Kfh2\r\nGjNug+XJeOfP8sEeId0JA4NKZSSWO/i9AV7g836c/WHfyI8cnQGq1ed1JHjm\r\nG8kpo7Sttg45hvPFld5Dfzfnb081C4etU7U9Ql5Aoun9/4CCol/c0HHm/uXN\r\ndL0C88XEzL+ai+Rl5r5l+3ue416+E8y8kixMHhpyhjy3h0aQnLLg7ArqyVnp\r\n9g3jci4WLMYM3gOtoZ/LiGVnLh2rnZEfOh0=\r\n=pY2u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.23","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567390401_1672567460336_0.7131750563181991","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567369746":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567369746","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567369746","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1e0d87c250757007b6015292b02e16313ea90957","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567369746.tgz","fileCount":7,"integrity":"sha512-lpXsxi0EPUJja0ta/JOtX69NpDR9WOjj5Wn4fY+eDIHCYwCmedNOk/p5uOsIwm7WjODKIqNLXphXcvphlYgyGg==","signatures":[{"sig":"MEYCIQCt4M9ihUe6sYFcrP1Haqyt+zhrcZWtBWw+AT+1RawwFAIhANmoVgH4JVPxeExJQJ8FptGmv6wbYWwMBgGd40MgJInA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVqxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrt+Q//SV64TD8SOKogD7LzjdcidBEMxdVFIFtn+e0vqgqJ4g+tpRJA\r\nASiioEHYChB9ipI0IdEOV4YAhsK8Br9iSpGqtJvFmFAvifMXQ0h6/0xw9aGa\r\n+jGsbZc35OW6ysJWz9KbyR4j9ANnYOYsmw5PnP2JsJ2KHh0C0FJg4w3JPg3W\r\nlFNsx7sdp0yV1Ko5JLZkQcPQ/hrN2oDyUP22OTorXpOnA45QBWOx7Xchai/X\r\n4Wuqqu3vAX0yBtJqbcVDETDoFJ565yB7//QnLKOgAnMmT1UCrs0u/xn9EYrx\r\nnxvYXyvuFzQ63YHKYegW0cwJcCA2ieiGD+nbpXXKKHSes9U7pGdrHmQ0aWma\r\nfGjSs460BicISPrS/cvUKOC8LHQap4pHz8UB/Kpe62Vk366ivubx5w2trSYH\r\nGeDIiT80CLFK5PNcl5ZmIl4fEESZ/eaehDmIiQpIje/OefrDOWemW287NO7O\r\nC79CUyVgbd4OAJP8l9mJRy21mJWTngGCceJJCjqVExHgoNVhCFiG1Z9P4L+i\r\n/OHTDElEv9+kAWx4pto5QPOeOmvGzZeYPQRARfgiLxdNmGBKFFGJ/9gL9PlJ\r\nEm57EHDBJHUyBfKYLQMlTSK5TyZqswbtHg0kPFDr67s3VzK4ypykzUgftqXy\r\nk2h3OAB8Fdd8EGxlOg6y4DHrZ01XjQpQRMA=\r\n=HqPq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^24.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567369746_1672567473531_0.4314246411439544","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567389564":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567389564","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567389564","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"ed4c976a72b2c838e23ecb3e9cc9ddef5aa68166","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567389564.tgz","fileCount":7,"integrity":"sha512-7CkzsA55Anuk2kFR4p7P5C8OZqvvZ7e7Ii+CbxjpzfdQlooewX59l+EjD7fVLDyiQWJ2Fo3pyISdwE/GsmKaPA==","signatures":[{"sig":"MEYCIQDEZmtjHmlWbFyLlE2Piybb7P3dZaxUON1f93VNb989iAIhAM5FvHEtZQx7xUzN0SFMPw/UVSY7/tURMXMGV6C7F/zU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVr1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmquAA/+OjCOrXtO+8DccpqrsvgNxcMNaaqZveSi05CdQDR3CBKsGFvJ\r\nvaP/e50EmHPkCa3h83HQW2z5amWjWiUrmB9bEhWx7joCfeugcZrVVoNeDnFF\r\nIbzRltfctkfJdnMTs1KvekkRlDUUERFPkT/CZrvnmLsuLyRel/gkI8Ff3Rjl\r\ncia5bN/eKo4FwzOGY7PO+qnPQJJkWpWqmbEGZ02gXPkXR2MMTSUAcQ7NXwgP\r\nkDam8V/B59rj9QA0WhH53JG6neTTdZsAnQE4WDOHN97aYIEaYrHYb5PCM4yC\r\nV/uNP2yq6mssD+YGdAD6GNfC5j4a9lK/xl/sa+Ul6mREzCqJeqdM0LQRgklp\r\n1KcALITxaYQ3aAQtRHlhs9c9POPTEN1X5uMqiglFn8olyYMOl8zcPgCylTWP\r\nID3pkQ8xjA1j9rjQLsUua7h09VDlYcGC+6lxBulC+QtaZAlE305b9wUzuGDE\r\nz8kpJ0XpBn3UNIoPWipmWe82c36kcoN9lMRKb4o1xCrWeM5iGZvUhCo27Ii6\r\nsMreE3hoq+c6mobChk+lBW60D4rNzwfuedLwh655GgTSGsPAqOWpUvICybII\r\nxY4xDM0mzAbLEfrCfuyh3dzwXl8wrF7klENOGVrVfHab3jwJOGYm2pjeaEMc\r\ntidK8YfvVqIOsbSUW/xSL0lYR8saQXwYBfI=\r\n=HGjl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.23","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567389564_1672567541359_0.7664162735047104","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672567433421":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672567433421","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672567433421","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7af6f1a963706054782398b7d11b51e989580dbd","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672567433421.tgz","fileCount":7,"integrity":"sha512-ua15Zovl17jt08rRQcN1+x9u+Lt5S7jYzfLRa39MO0vJowQ6Z4RJYGLNTnzn7JCZJpom4xGiUZDLvRPC5HGXzQ==","signatures":[{"sig":"MEQCIGfc6G/gF4v2lPfJudyfoxyKYBM4Lf3GGzaH2Y85jC5yAiBtQAoFM2m77QX97KCjZnLni+HndyVmCEUg2J7EeH7U1A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsVtJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxsQ//ZDr+OW8zJs4l9r00bLizIq+woegWq/4Uj6DwlHpA7r5mXKM7\r\nRMaGdo2hOm5AJwbIg222XFRzPpW6/ar+19JMtRJ5T+1SaM8rhYNqT9GvcWnc\r\n3qch51rl1mDF6trJFPEXh6JrQn1qPYrvEVLl/zFPu6lnC+dlM7ONqq/WavBC\r\nBq24W98iiaos54wynRFkjNlk43H4khCqnaKRF8Zza4rmBd4RLU1/rlJpMK84\r\neT9zIUtuxc1QiSOXfaHQuyGca+fafpBp9liOC5IuWm/imvtowVnHT9cXzDsT\r\nHZ+u6J0grSORhus8XfeYlk/F+69pwFTtrLSqGmTOoloE4LJhhiMA406yszH4\r\n3iKDULRJUgSGoifQSwgsjWniz49/Rv4WS5W19AFAeoC6+7SCdHBiFBaM0GVn\r\n8mc7ij5iyi7j+F36+Vh1RSiGCPv5gZMeH1as9ll8/3tBsYcI6oq5h0cxFiXF\r\nMImUJsiwVPEGN4JSsXAkE3DP7ifc6JJZBpVTPSkRMkF8e/Hu8XuVnbHemBJh\r\n0PakV9Io5kUluYyJ8gj1O7m1L2oCt9oCUp4c5xwIKtXcDpgtIcHw38K7dmbP\r\nzg7xkfwEvhsHp65HDaAPVFNyTrdyDgAchq0MXbUnDs0sANrrIqiAQhoTLc32\r\nkODHNjWgUT2KXjP9GIU99TUzt0uB8gBBnCY=\r\n=hKFg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^24.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672567433421_1672567625127_0.038732569970077124","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672608188846":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672608188846","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672608188846","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"742d7eae0f3f217b0ce6e15baebefd8d8936d9ea","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672608188846.tgz","fileCount":7,"integrity":"sha512-ubSjhDjvg9izqF+/1LflnW9fMDuVfFFRXNcx/jVdq/L1vs1+zgftWNhHcGpGZosn1InkpRO0VgGo4PyvcPXYwQ==","signatures":[{"sig":"MEUCIHks4LywpDQxcXAlBndgFFsZwO7dbRbhPMSQkvaP/lWOAiEAqw3wdjEspb1aMmDcUVvCN1tb3sZ6+wTEDqs/dxAvZR0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsfnnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmosBw/+MUP/RgxGcPEomq3jPeGYK5EZKjuMu8fb67aCaQCqbXdsotLE\r\ni4vJxASa2znCRHbPhoijfEjnbpzn5aaK3b+rTCaYD1ZfvtQnf0V7K9Cm3mn3\r\nJmeqU67+TSdq9NnSwdmn9vS8yX5n1bWpc4fSuRzhoVNwzIy4NO7bEgX5MEkl\r\newrtW2plPWEsQYTr1d+fiY5rIKlfcmq+B/579ucKmOP4IDz6bj7/BnJZ46LN\r\ns8ukcEn3UIowtvu9z8RYzJoWwyDjLOQCyx6TkYIMH6zCJe+VMvdDM+uXukRh\r\nnWq4wFZLteuM6luDGCBgseEBiYbXNDtJ6uPggnngj0mF0PAZhYgKB2W+Ax+n\r\nitmbUGjfAwhVGghSGgo4x9Z+6uG3dVazii15VDQFXimeKzuCgZxNaK+2hNVY\r\nAUWJ50g0zyDNPGLyxj69WcHlNmKR/XpEQJEToEVZTmyUjJ4cpz3QDaZEjo3C\r\niuhdu2HKlE9jw95ZlPCBTufFqaEl83WlmCM0l1hZyU9+OgZqhR2E++ZQXVhB\r\nDQJRsm8X+0901FxwoheDHl4iFUDuda4fG7J4knweZBYN8fRaoa+bhn3T269B\r\n9OSkcL/F0SXSTC9EEfp5EK5UrZgNl6oxXTtpRksPnpdH93MuBGU9C5UAAvh3\r\nzd2w36dNG6V3Gdt8QpFxtEJ9HYGkKsClJKs=\r\n=DmV4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672608188846_1672608231608_0.7647649962850098","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1672608187797":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1672608187797","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1672608187797","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"dc34817ed51c583a57b733496bf9f1f43ffccaf6","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1672608187797.tgz","fileCount":7,"integrity":"sha512-bnbDo0ZbmPR1QEzKlBbllepWh0CfhK2TMiFlg+573vFGazR1gG2P09IxsQ99Jk3PVkPGLBRCHnmIXqnjPGvdBQ==","signatures":[{"sig":"MEYCIQDzNkmf5DKt6H9ugskg3UerAIe5l2CrOoT9vmPYOPZRKQIhAIz8i2lEbdJ2sn6GQ6z4JJlurfGv/Hfu0z0cHSR7DJTs","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsfnuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr8dQ/+NL84SZK9GnknePWjQyUclCzgY2pJtl3henYtzP4oGLEQ4ElW\r\nUBiFUhrVyGM4ldFz4kyNdGfFrTO7DJoxcKnz79qSVexCTIxhLIZ7m1pCH58b\r\nutJSsi4V3z5qIYJ07tsm3An3C1NHRvFIpaK+cVIxqFipEwp1IgC8uJm1A3TO\r\nMC8gJLIdx9fNl7sdKyLk2AksYea3xUjIcTzsEN2x37r+tQ1CPMVaX8MCJTia\r\ndNxkOsJoFaaXp3JfR8EomB6Asq+giSHiakhJSO6A/H30wSi+/XmF7ckb+7CE\r\nQaY+xbTTXfglCkT9DBJeGuoWuMu048sOzHacq+lwpl1eOfoXmkxd9OGtQ6fs\r\nCWF4uVNDRwV57Tu/dZzBX97J5zdt9NtEpLbT7b+6JPUAm701s9wE49lTkxr1\r\nbnLHF33PkSECG1oQp+txPm2k6khf6pW1AnvW8dj/kV/7795wDWo9EiGu1Jy3\r\n7Yqh7OAADkD2Wwh5whpGjVd5sON+lLn11+exf7FSGUmYHWKj3Sr4CLJJ8UXr\r\nrY5GlSK8BEB25Y8eOng0zx8YeRL5YHZGz7jP8oTi7OZr9bLff+O63e/z/q2s\r\nT7cmUPJSc76gOOvQZZXKvI1trc0hrjAwnt/sHz3/41k4fX2VLH235OBmgnfI\r\n4c0Z3Ci5QfWyEjXo4L+VLy1QJYsR2IBk2Ug=\r\n=jWDp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1672608187797_1672608237883_0.8606428055558646","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1673120755098":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1673120755098","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1673120755098","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"e062bf76884e94a232bd88e524b6970879758313","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1673120755098.tgz","fileCount":7,"integrity":"sha512-fPeAB6mndHBzrBOAbMdjX+HLNPQctf8aStuntgNwo+zuHzAbXvedBsjsDBZShl+HW3QXrmlAJnv3qBeo7B2yng==","signatures":[{"sig":"MEYCIQDUAo1lv5PALJ0LZLJfb2ddMyYaM2nq8R27DPT+Jw7flgIhAPRDkUY0zB6fVe/xUJuIzGpSUcS9YDjsseP+mBtvwO1A","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjucweACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpLkRAAkQjPDYOmTCtpy3ZdAbNyJ5Z4zoGCDodZ60d+xqnnBTOvPxmc\r\nr3EOyMmf9QaoPNdW0bIcdf9xgQtTHduKIH3t8L795e4AlSgxx0ttfw0b5O5A\r\nI9lwlsZxWWhBTHRLSKFojVEXJH75hFPoohnf9OStTCsTUik7QkFaxxb7H8nd\r\nJfHJUJ3kp6KNNndHNF6E00Gar7wyG1HLsSrhwz3LoC9vU/CwccPYUWBY/cFc\r\nfPAj9hyXgUmD/nHCpwy+/9eCcuUW1dxijuqMN0WJ2j3O2+6MlrMjZgXkfINw\r\nXhk0GMzk/L5Ioq5jZPuIKPu65VzcT8JYEfEHSB/316WKaYyGaHDgKHRAjuaH\r\nvqYi5ahOpo9ts5Tm0p4F3ugULVILqiULEnUWtg1mFimk5jfn4/zWIxS/IKoM\r\nox5TxQ8Us6IJ8dFtLrsZltZRIegH0i7IbBZ73hX6yiZksmPTJ4px7eqCdgk+\r\nqxQt3yeAq5aMnAtkxwqEpmzzAuoXc3rwphoTyWRd+9BiLJ7et1ij3yYFsfx4\r\nF8YWlWWsyOAASXwwx3V1IfUmuBVZoZ5I79nthRSUtZ47KWuhme5WuWHkd2IW\r\niP9/uJBiwtQETrt3Db1LqopPHTmgWEVbHkjzMMW7xurKjm89XBTSDcD0cep/\r\nK7uDS6QJzBBpbjS/vmCQofRUO9gUAxApVY8=\r\n=I6wA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1673120755098_1673120797853_0.3442030972609753","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1673120756019":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1673120756019","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1673120756019","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"a73499fdd18f46a107b16241e8b3d57161ed1133","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1673120756019.tgz","fileCount":7,"integrity":"sha512-a2XRJXmiBfr48pCdMWTA4GbxrB8l7uq6pi825vOU25A0YOuuzkL6s8rvohblVyTYGgI0VdPcl7ZNE3BigQDJhg==","signatures":[{"sig":"MEUCIGWhpEF1PygfJ6y/pCz/0W0uHVJn/hyClnR9+SxAJ9lwAiEAujpxhV9Yr/tUxPwDcofOzq4S4L9BhV6f/wV8KYVQng4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjucwnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoYtxAAnNPmreBcFzpPtr/djVVBMiCC/YrIvjDW5ZcBjNFK/wmESaKk\r\ny4ztbeOpliLvEH0pQTMLHv5sxiE9EqUhQNwcyULFaOfzxsYUMWMvNE94T1MT\r\nT1sefaTgIDB9Js5a1iKeskUBDM3+SCV22rcWaHyh0QqEcjJDVC+yr4OllYNJ\r\nbq/OcGduO/IDCcglNEYb57RDVPjGVfpL+mt91VTc0tKeQiAcqXNlxnLBAao+\r\npiKPFE/rU5DObcm0mdy3qTyevH2pBh6fkKuAqeXnCPBzLB8c3m9eYKX3rG9M\r\nFHJAWYoFCxud/tFlCmPmB/I31RGXR2YvCpKE6BlIRjvh+iPSQ7yTAo68ycFM\r\n4ZRGQX/V5ySqs0XFxzs0Y2SuyQCF6MVeK4q96vqlQ+lkIJlhwMsJUoZPCrrj\r\njASSfMe9T/66bWZKOPu5t5GzIe5kzGVvEAGntQkXLG7zzTNAWruOXNHoh0b6\r\ndp3m8X8uBqNChtFOjSEu27ECLsl2UUkq7tysXLPQrtTs90Gy00SAGlONPqRg\r\nJfFiiUXyb92YAh5Fb7OA5R6A57EKpX7Mq8l32Wi9K2aPZpolxK3es4YSUQ3V\r\nF86Hkg9U4h6glJDrNyt70AscYl6WKgBK+Up2cy1mTqGyVs70+dGMx3yOWMnj\r\nC3UvJFGdeUx6+84NtmiQLxYtVaxAOABiWPs=\r\n=dtca\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1673120756019_1673120806828_0.6184425192669194","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675245718232":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675245718232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675245718232","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"7ffd28c60a3f4619f63c72edd3342f11e1f7e97c","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675245718232.tgz","fileCount":7,"integrity":"sha512-7Y05PGUeb4lSw7ZFLM8cDUTGhtHuQbVVV3ljdPLHvCxDyMGJoIPWyZr3IPeA+B8OjTgFaZ1jt5xT3yyMFkIuHA==","signatures":[{"sig":"MEYCIQDkSVBsWdCUoN0e7D4k75frWvoWcTNatQH+9BpKHyYAcAIhAOL1yP3G/raFGUapFRukqFcRWzePUPVlJ+YDdwIMSfjd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jjBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpXaw//UxtPlqBGMXTpK80yXJATv4VQuoYDgFmpYJXUpS52ajc4rUao\r\nYmtmI012izHYmLEbi/LXtHf3DTojDYZ9oiyQgwTDvWrSi7c5O8biON1XIEQz\r\nsOKNd/PzGOZdo65BBm7UdQ1eecJbMVkBrZeZ1sgh7yURTW8VhxejU4MLLrab\r\nRZx9nPB2E38tDqcC5d3u7EwIEbJCsYA9eHoYnb7A07NlI5ZN1tqQah5D8Qzl\r\ngl+XGZLzsIwB6jj0AKPppObeOXo1I9lGVVU3xqM6pkF7rg6qQOCx8/6vQPnu\r\nXasgktpuJEy5E50oFAq7nFIFHZilpiITn4UqgLxc0SSAXcZ+jqAGglXbkRPA\r\nfCYt3dmPrQoWavqewn0wPTLMXAg9aBM063YvvUDNGgMj4hL40rFlf5qRexYJ\r\nxWb5x57qccaePp82Y7A2l2K/kTLGT+3PsFyO68Q3WnHeaAva3Z2GFoPKZ4+7\r\nqiSpSeWhbrIOZ+C12a+oEoBNANwTqL8MS0NlTThxZrZYHduVq0/Ihwi6s/7B\r\npniB3KCgHhoKcXhPqsssF+0iLjEOobecvK4aKpSstB3E3UDuf82I3Q8P7rsv\r\nxXVzOh88rg9bBnoFeM+diQ1SLgK86frWBgXYPGfy3fjVbZ84jJOF2MXG2lUT\r\nRyjCroLEQfCF7Bdm0Cbf0Qv+hyjyE8aXLxg=\r\n=6EdP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^24.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675245718232_1675245761118_0.6781861780848801","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675245719544":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675245719544","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675245719544","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"724eb3a2b9f6fceebd152e3b6da716dc84c22733","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675245719544.tgz","fileCount":7,"integrity":"sha512-gjicaZsbnhkWGCFLP12wVPBHqZYehcIGO7X0V7aQmynEW0RqZaAEtvKE8soyvNO0JpaEoljvKMCLun2Xf4SLmw==","signatures":[{"sig":"MEUCIQCJeVBaqZNxKdxGjeNEaFLfJHDx+Lz4+/Xa3Te6BoBhFwIgfv4mPDz1imexjvA2whlGjZ/ZgJkfgQ5b4dtsEx9sIzc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jjKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp21hAAnpIpXCpuuYtDB2K8C0TgQU6fXOa52KAQ37v/YWZm6hP9hRAx\r\nXVsaWcvdx+BNHvbeOx0RORnKL/q/iofnIfn9XaCD/i8+Vjrehci9j6HlNURU\r\nnVdBd71ANPwnXvQpM+HjC4gtKF2BHLNDPP8LKKjDkYcuDd7fqb3pcQs+to6X\r\nxNPNw0e9xGJJHMlA85jZyjUduZatO6VqkW0+F5XFKFvNE7YiiKEP5n94aZg+\r\n7Vupo6kQK3RbbO3dsiRNGatbZZDjtVKQEk7mIh3PsIN3q9l0tLUX9j4pu42u\r\n5lDF8nka1VVNjie+64u5+YDnYi/idRQ7t2xomyfjhLSE8ZI3JoizH4Qwk7zY\r\nxStOwwiKjUtA3SNW+pnJ5ZUPIgw1T32HfDjCwxdPIkDcET+3Rs8xcQ0ofPpO\r\nKNUKwZUC3wtzvuYBk5V4OZc5xcvhI1paBJKiDZsIWJsAMfiL2XgFz4XZhdxF\r\nbaFf86m8JR0946gCZCJynHtE7A2jJaS+2ul5vBwGpzGl8aDaiY1bKAmK1YCx\r\nNVoVkiONLrD1qx4kSXMYkyLd0XGOqQKj9QOBF2JthsLXrnRuwv8OPqf+E6A7\r\n0WNEhC5NLl3JK5XXgeANlMVCbnmSrqhGUOmFRd9X6ERpc4QvWMzIsUNFkDtw\r\nM9yRlreiru3Y+Qv58xby8ahDJbHKNJaofAk=\r\n=QAC3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^24.0.1","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675245719544_1675245770429_0.7038460051778359","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675245752989":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675245752989","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675245752989","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"24d6545a7a1ef115ed88dcb1d3022cccac66523a","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675245752989.tgz","fileCount":7,"integrity":"sha512-0f7yoW1KPshU67cPfLgx6+AFBdIH7mQ5YkZHt0oFxzNz9J7Z29OLnKL/UHBrP/HGTbE+yv8TSV+F2cSMmEArIQ==","signatures":[{"sig":"MEUCIQDeH9SKcl4XoF+eyv3hCoJt0+N1Aq0v9qfDD93Pt6epzQIgIKfT+XBFipEZvBako1+V62aBCR+ejdFq+s/W483RCWU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jjmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmolehAAjXPGlmST8nm8roCMbRjh/zsjwT0HfwBUs1sYLhPOZ7daM5ua\r\nxnl6OO/55BT9LzlOSPhvDKJV8Eu3X5qu4IjB1zy1zRrUNrGEjwagkcPrijEF\r\nFN1fUknC47eOOjYsGJFRSnwgBh5/GS7GnpK4hrtdZ9Jx74itzZg3pzGMjr/7\r\nvEyubDKqsWgf8sriXCn/OxMAWbLYUMP2xuSUOylkppCnrF3BAW6X0dh2jlzM\r\nKvl7ISun1qiplFlGwPqfkNQlCIFr9GMAQvhzSq2WJAEQb4HQY7eEG9fTHmi6\r\nhlqEZQkCXUmFZAB9QNc31L8lTxwsHNGQ4/4Zx2B/WK+uix5/AFaqBuDlgWl1\r\n6GAWIuOJMeHkSAIe8KSO8CUicmwFRovmR26aeB4tcNmW4o+ZlEVXjKtBmcQ1\r\niOhHKShEPK0XPztqmw1TWhmP1b01iYr2FEYLQuLHslMxX2OAcXgaB17lzgWt\r\n4D1Fo5VVrlp3U6gcKEih+JKv3tl/aG70gGBaco6GshsHPLwma/loiF8OoFeP\r\nCbg52KjvASmZIVYYMg1ECbwzJo2SOAb72lyM//YZdcPL0lDoRpdIyAXLhD+K\r\nhQ6JCM7PvuuFM2rqOrFzyV0grC9mej76FS36BNVOpY0mUqXce9fD6j9RF5xv\r\n+OIVlPDs6Y4ErIF09bTm6aA8lh1mytIWT/M=\r\n=Jiav\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.24","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675245752989_1675245798284_0.24158626990175835","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675245753523":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675245753523","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675245753523","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"1d3e3e68330275abfda4a5e1beecfb2552ee9e33","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675245753523.tgz","fileCount":7,"integrity":"sha512-QfMBcX08dojuHbV6XwSZ/eGaAK89W7OOI43i9hRT3CtOradEo86cklV2I7t9oiQ1lS7BgeOCnqjED6EFdmCSWQ==","signatures":[{"sig":"MEYCIQCcRcLz8q5zcuN5mOqTnHthsyIDYcVMbrtDW5BzFCkg0QIhALxbxLoXp9EWGIhtHW55MQVZkH+mU135d/wguk5EJfTg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jj1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrrvg/9E55H4B5Q4ASXHYX0f/boA2v31rFxQEAWPIuYSmCn2AUZHFuQ\r\n9uJi79KR4l4wXRfnp5W/GH+mC969lhCONQNQWkXiRaD/PRkRjWBeHfsnqKbn\r\ne5rzJT5FUwQMCJLlEfCFKcWDwo3CB5108hsxd/V/tW0DsJTP2AwvrSTSd1Yy\r\nOhwutvAvr13nKOkNuQU591gqMUDKW1wiHwp5PspLg2ITXMd8wZSqCd0uS5Ja\r\nZQD1/OESA979Ji3cHiH1SynzTgn5O04WL01ZcaKOSmXzQm+DI9k44GFkopXz\r\nk7IS6V+UmMMCIrSlZXTzeu2+bkZ6dk5qExtisMSE9dBKEz3D3kEiSS6g8wOR\r\nQd39SLqYJeGkmoxcVjvgk5eGJoC24ayGeOgGo6VKd8RIaLzfEcKyXPlDfUw7\r\naIyeGKfDvVyDROCH06XWSGKtmDp6dwng93IYxAycH5OSjKtW0gkm028Rn0oT\r\nbunTN97TLyJsM4mufgW5G27fDyUuayzIWAMx7y+SyZ59berShvvNZf6eHjic\r\nYiztUi2zb92eiH9o3PgivtjQ7hkXc+ZSaOdEFmkABoV86AiukzPhzuaqgtnV\r\nHbRzkNuc7Dam39YLH0QoJZ/Vtw0IjfWWr9q0a370yLMrPaWcZV76GGLcPpWU\r\n8H61fCu6NNOb7b0va3AgZzROZEPOpB3deqY=\r\n=HTvw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.24","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675245753523_1675245813769_0.9913708271846533","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675246016133":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675246016133","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675246016133","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"b78ced46319a61c36d587d7dd5e7f7bf1ba943dc","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675246016133.tgz","fileCount":7,"integrity":"sha512-XKP1pBRaMIVgE9C2k8MOPSeol4j/4BCWm1l10rghyjWtyVdzofT+8zOixjgVjFJBFeC1uf2IQaXo6ezAw/raLA==","signatures":[{"sig":"MEUCIQCzsZhETUNSpmUSpYbeT7INsIy7J02MRdCcRJEdOwkk2QIgdaJkp5d9IIEY+1aDguVcHcBSRgwXb0HSdiZFXIFX1+Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jnqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrZFBAAlJ7q62EfnO/y8ina+/PBC+SZsY3AW0KdKRHqnTnQmMhfP4Ph\r\nfWOmDfP5Lkvz001Ko5FqyFiD82Kzb7PBW34A5bTUTuMYrIfR3hy3ot7P/0Lq\r\nujJ0GF31uIrSY9eDE5RnaRc8T9ORMnbBUDS8iBYUnUg3oNq9u5rW50WwKoIy\r\nbQBY+BEgMjNyHldj71xNKbIl0N2DZ0lvrBtcN56QLJMhMjPRtuExs4bCdSW3\r\nKno9LifWz4x/80DqzptlQPwLRjJthUWh2HXgk9s0GNVJ1zYuPKUegx0R8fU7\r\nPK7+lZxZ2znGNbTcbk7ldo1t7ZIVqKkLaX0QFvTQog6ILFpoOtPmJwd4zIPP\r\nxlAFtu5hyiUdnPT+Kkr8tE8yB+OQRsR/CigrNlHEEMfMGsxZTTkg8hphkYQb\r\nqr2oV9HqFNBAnmkNJqjpWQSKLw1BkfK+h8jjUJcG8Hx9fasIECnin9qWpHAz\r\nfsAvZ6V4CeaQ+Iwffmd7/gYh4D3rl3UQBQjxB53UmCc3FMLn0H701pL23RiJ\r\nMgi8/jgpma+Xm9RtVMp2r6ZLYCXm87TQD8GtaL3Bg4veF44U46qUpk6p7uko\r\nKUz8PHpEhYi2BYurKQA7crMC25bU7n0XUvdW/A+C4os2fWPBkX/MyRahdyr6\r\nrMc2qC7tMU+QHEEyHR/GhZmtaK2GRG/ePAM=\r\n=4SqR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.33.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675246016133_1675246058697_0.3073730416014211","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1675246015945":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1675246015945","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1675246015945","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"3c3154e85ef83c1cf0c6e17098e0d3b070e9e6ad","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1675246015945.tgz","fileCount":7,"integrity":"sha512-8ViL55PgZfdXvLvI5YPXo5BtvSfbxJ3R9nSAwWweXldDwQail50R2uZ5dhnARAMSQjuFvFfkmRqn3FbrXal3qg==","signatures":[{"sig":"MEUCIQDmgzSrGeVl4bkt5pR+TO1+AKNff6hfUYHKmEbfXDJHUQIgJFtrqthFVPzWaDyunbRFY0l82TDhm+EiKT+al1kdT+E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2jnyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoJDA//YKoN4jqLq21a7RC6OmLKoSgMVbwlXKwAqxZPC6LOCDrYXMc0\r\nwInMvq6Qzzdddwm7kKwElI29JUii/eKPrwQKU6SbDYafFP8QZHLNy05xZunG\r\nk/s1A28K7BOG4iJqV9NYo1jmO8bS1/EoolMwDkY5Hd9Li/pDK9dOKO4ia7mW\r\nOTNozP6ftLweWXm37VSzyiYnxrMqFrkUr25ZePwPbTEzMUUjheA3kWL40UYZ\r\nH8PEQQ4C6aX+SrlwrjQGvor4nt3HSZ+/EQnjLtvWkFgSA9rVrhGmVTinLyx4\r\noiq5XGpwO30ePX/J0Q9vEg7Y105b5xC1ggoS3KzVdcfMYalpVRvj/6/nfruj\r\nM986OhYQ4M//cfjUyDDpxb0bb2rK6kTt2pqXVjOPJKGSROUR+kPGwKDRI8vr\r\nIRKWIHEkY71J+0HdnuQNzkLzhlMt9CySC8BbyUUihmooCy99LyTKiAESwslH\r\n+CmTvbpYfLlX4QkKqNRc581ODCSMfu3wj1NX5b+nkAjCY4tdRa/JfT/hiRdy\r\nC3xPzKPEGkiH6b2wQZTJtuhkhu3342nEzWT0nPBTAjggha8kqT2mMPqrFUbx\r\nmiXRnsZwlAJLxKUzFr8ch5gaqH2zkts77s7MAVWYup5JrxXFFjMGWVgPDHFG\r\n5BDYNix28IhXr5XluFnoEwqT2iGPAL+oaP8=\r\n=4OI9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.17","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.33.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1675246015945_1675246065878_0.5866282888049545","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1677668266932":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1677668266932","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1677668266932","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"9e6a836005b897f087daa14b50a9760c5cb2be89","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1677668266932.tgz","fileCount":7,"integrity":"sha512-x1aCm2nl6+oLk2q0IPBtsGdBcsH15gQkZ2/VrYTtfSUTI4RSJHQo9exAY0gTO08t7AnuW/rRm326ftyVRmymdw==","signatures":[{"sig":"MEYCIQDGRco+6dn9PeQztip2ynfxYMMFI+0BHZG1L8WXQwqmOQIhAJVILh/W3OPFGguFV3cRIT8WHZni6Y/kRJGMI0PVVd+M","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/y/XACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqnWA/9FzKi81berVkC4VU+AyTV7Yed3oWV1MIcrui3j6AhaxOP1fE8\r\nXuEcUjcCyPUtt+TiDhPYeMVdwRIxrrI9CgrXf+fXE3MxLhCyQIc9DAgpx01G\r\nsgAEeRqIl3G9DoMhX6B07ttdAgVxEh3jUoVpDiS5MuIr7lWHutJFfpgL9OyW\r\nK/ULcUpe8tKweAO6cowtDUC9vUMW214Lp0j7yAUnyWlIqrHhxsLb4W9hLlgb\r\nCX/I7Px3Xn8l1pI0qhGAx7Cpuy2AdycPJKIGrbzKdoCw3eerMnHpyn1qxcep\r\nRkO0BTzlN/YEIBAh1qEG+xrh9+hC4yUOzR5/FSY4E9RQzIleaPIt8CR9XKJZ\r\nK/IbTlwyjjTNdSPhEztTOnzOX1MATUNLvcNiUfsKpoXm45vyNMIWd6cs1AZB\r\nO+qAQ+/KScFMZhdfP5uVQwP2JhZ9e3J5uM3EPRCWt2rSIbL8vl+02NdgSJay\r\nT3CjDSFE0ufe04U8WfgWE+1pfAnu9JSPj9CVhmOM1Q6Eea7ZCUxZTgDNbKf4\r\nHuVJ8kdhQuBVFOK8ZjTd+RazkdIohhJK/EiTRODvsenZyHTJX1qzuSxpqJj4\r\n6ALY20E/I6UjRETM0NdgR7DzmjBdqC3vsvKWGIv5vOqWwvRNb4dxymij3WAl\r\nlhJlYRp1e+24srlpL6gRtMbdQLLWjeBVuGk=\r\n=BOuy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.35.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1677668266932_1677668311055_0.8868079929919361","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1677668371867":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1677668371867","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1677668371867","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d218ae5213c205230dd0c101c52f0273e49a2a6d","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1677668371867.tgz","fileCount":7,"integrity":"sha512-sDQGKXkkXZZtAWakegBIJK5Jnx0gtgtHI/76yzWNPWXnLYwhH/R2rqi5fQtos74g+XqC7LUwGP3Icyms/6BH/g==","signatures":[{"sig":"MEUCIQC18yHwmjKsxiJnpTJqgm4DNjqXQmbSDyRXbmd/bEmLOgIgCcs/ZEdj/2xO8Fs9D6XQHSr7pkvrVCOa+Dk5fF0wFMA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/zA9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrIZw//cvqx8pzvbUx7hQ0iDVmafdsyfN68unFTAEOLL2oGIyYDPRNB\r\nGIA2JhftLRwDo+5vFjCPOb8Dqg8HDsxVPZ/wMNSjURDfcLAZiBbEEuWnx8la\r\nRcCwVA8xtebQSiCSh8faQcFpbgnrvHPOBZjY7vWupKBF5owIFpTLFUFd69iS\r\nJpUkEOzmdmNsZw4rLzoheFVArpZM0rDSbQPWpYGerBGmUL7ldP4pSkidx4Is\r\nnYFhAmeA33xvxYCgnxECPW9GGmQBm9gXvnKj8hGNrkclDNHzbl2Diyln2et+\r\nVVyTphml+c1FyeJunaw605Z7VxYhAEWitW8zbt/c5Xtwf3Hvr+3dr5mUBZw6\r\n4b+g2ybbtYSSqtWNDy9Jc4wuFrvWYTX4LItEg5qGZSJgoF8l0DGVuWWWC6YH\r\nYGXZXXBWzbg9Xmo3cTvPJx4biqUhJIMoZ6C4LJRxf5l3RAw/+cY76jaWT55/\r\nYNiDeoWu0ACzq4/V5xjogZobe+4eJEtZ2E04Cw0JR22aRS1Nk6EbenLAIsLD\r\nGRSOGnXy4DRp3vxtx/hVgQ5M/r0XAH+SmIWp2fzBX3qQZ7kWwdfSwR3Ud/Fw\r\nTrM87TMSSIgSU5OtgnrdRSuhZdh7+92ezxudhqfnx11a3pBOBLNk5x7PEKRc\r\n7Bynwrtlz4QmPm8A7/JJEfpqAiQXfrnEtVc=\r\n=Merm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.26","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1677668371867_1677668412860_0.6655993412728141","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1677988516446":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1677988516446","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1677988516446","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"d99bde27c849b242bb9393f1194cf23cac0925db","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1677988516446.tgz","fileCount":7,"integrity":"sha512-Bxu3r4JalmvMtcQFEDni6HygIJaS4DNeKGQzgU2xDp3nnGUZivLTyQu3+9pSz+vL6NgFdRaWDpByfI8hsJDDVQ==","signatures":[{"sig":"MEUCIQDYcHdKUcXqx8LZQgJ/QMtG7Bls1GcxDKA1PdnuUt9xTwIgQ7pV3G9snnioErxD/KJpsysSVbOvvNI9Uwu/9SOk2ic=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkBBLLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrMRxAAmthY9hATbPl0o6R53/eWYuhUja+ZwTrTmPHoWulOFm93EVb9\r\nCVey2gQvt5LrZQJKQSjp+yjfYgeK+JjmElI8Oc1p9hnJDn1RBSl3ZbXEWQsE\r\nz+zAPf0bJ5kntu2lNX13eVAe3KUt83GutzB4zMBeJU1EVyyjQU5LYnX/aeoc\r\n+leiwIttWqEbbeIyssrNxtr3TKzLoYwi9fIhBl7buh3huieRrl/9a/uPKTA0\r\n/TTcUf5DtVbh2l6Unuq81Na/HCrVynZORq/bE6RpO3DdXaryLkC6jL7psZ7G\r\nZkUTTLzDSJCK7aqsHaobHwYF5VHvxhbF59PnBJFw6A88cWsahKZo+DXnyGRB\r\nKp3gIAanbFDLX3JUwCldVzknLKqlb3nXXOT0xXM9p28a89/0osSYxaSmYOgk\r\nYnXLtrRhow9k7v4IGWkRwUIvKwupidxTuQfkObBGM97ZHHiQ2XwvxeXN/zaX\r\nBnaUoZ4/o+7HoEFW6ANLR0RKwHWH6TCbd40EEn9BKuhBGOpp5OAGz9LQy+Rd\r\ng+FFNqij/w36fFpxQVh/kfLAVae9l68jE5QkfJG5+lfhV9F8iMnhysCgR2a5\r\n5CGnxh65n8QVmpFX0hPLsBLCewiNyQJPP4qcE5+BV0sLYQerPUXxHV5pCcuX\r\nsBqpbuhA1nLyfd4Px4NCJTk+mvSD98iiC6o=\r\n=o80e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1677988516446_1677988554913_0.6664731870523035","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1680346625012":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1680346625012","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1680346625012","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"8e6e38114a8420bd0d223c8288dc58fa0e837238","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1680346625012.tgz","fileCount":7,"integrity":"sha512-VESt7EOXSP8OHzYn/jeg2MhvnrzVUFMxpDEDtkcWTJjqs+penXiYKwcV5pbQNWnPJwghoev6GxYXP9hsjKR3sA==","signatures":[{"sig":"MEUCIQCUTANxQ7z3jGP9MTDwf1Nl1vi9203iq+DnEF/XF8/w5QIgW47islXDIEQUkKoI88+WvhWvyZVuTu/0QcROY2Bgk90=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkKA4qACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmopmA//VeoSczxw2cDsQbSyKS2aZux0+2/cn1UwmD3kV+kobpw5h05u\r\nf+VBXmaHSg6EfEp8PmkiJj/Fto0qFVb1XQ2yh2pz2FznLjKznRcBkteA2gF8\r\n+6DHzboua+hJFgUF2C2LxxlIgxEpPU5iY0poPr0RbMopTeSgV4LBNUK53yxR\r\nrwr8WNE9qR+R4ibBHYgTqjWRw3wzKdEy20P/KOrEVoKICPKyiJiewuEwXI2c\r\nboh95OxTVNFUR6JMYMjKeLTLTZNGS9p7mIWUy0UMu8FrYvDQHebDyyfs9xLQ\r\nwic6lY359H8QtuAqvx3797AuEUFdj5IA1sx+5GLEnl9MdY/kXd++/cId+P7b\r\nDbhyB2mmfoimPtgKh/v/qcoj4H2ntbgZwHwjhAygZWFtkL/ca/BMQ2hREZMR\r\nIIjASIvEKFdhR267jcjGR2msb+UH/g4dunkZfFoS/98bEHFTzkoYlPKvbd6Q\r\nt1RPj73o8ku7SNwRvGUzhPV1YPW5uepSH20PjTC9/9RVFkb/5+MksXqUCwxE\r\nGy9YSkeviueq5cRaBAEy1zUmjrezPOcJV0Xwv8D1d9rEwxgDUbdyVGdKyGCk\r\nXvqYvxBsHNq26C2+e2kYsUMlpd8BnfngUI4Qv+QVwhydPkjj5HX8H6lsLtTC\r\nlN1aClUrw/s2oAXvTSnPEkkC9al19WDGsuE=\r\n=c/9Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^8.37.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.21.0","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1680346625012_1680346666151_0.7493839114242593","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1680346697411":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1680346697411","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1680346697411","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"bd95bbeef2c5fca57a323f94f8137fd68069f6e2","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1680346697411.tgz","fileCount":7,"integrity":"sha512-cnRTvG49mJQh5Mhpd6KEvVXtG2gBh+TOxWSMa6iIvRpjMrMFdclb2xMBtBbyRuvTmlXOgPzJ58luFiPa51b0ng==","signatures":[{"sig":"MEQCIBNaPoB5O2rIKhDZX6LyQX+mkHBg843QIbYRHqABE5btAiB2FvjGVufPXiYP03nUi0Iqt8W+XqhPpmviQprk6XjXog==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkKA5wACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrUZg/+LnF2mt2ItIrXz6x1ibye7GBXV/y2YoImMiCekDrzw+E3mcPi\r\niLFQRvUWvhmsZVVOQ772rWm1dJZoBZkExG+XPriV0gTIl4vVXQzCDaUZ2Mkd\r\nEj1tsCADEK800ttE3TEpZdnWm+0NUJ1GiNcPiuuX6q2OOD1P2I04fiU4T96T\r\nmQWIV1rl9DGXDLrVtQbIzVp3jXeVHZiq2NcYx/82eWKxH7ODl7n2m933mIS2\r\nhSubGxR9gzhMLCELqjgnYFcFTJkVaosduOc4XdQAHn0LroqGNDhZ6+qeTQYU\r\naPq25uzLItXd+2VWKSuyn4YNCRzjzzbf5VjJnV1DV382aUv0R4WQN0uRrSN+\r\nSsiazoiCeH8z0xzASOCozGg3EPQeOkEeNv8siFC3a0JJN5XG2ccEJEA+C8mN\r\n2RYV1+jbH1aiyWm/oNe6vMBet0yuLApjEldQszUm3S8cTqBsv4mPzU4Qq3ph\r\nhLu8OSWmZK06cSf4Ca4XlVADaV2zLtOuj6sOU0LJPCxMsEwA057UVCT8+ody\r\n/2+A1DwxKWUqxZWRRrjj6XeKOM5rz+InQWQzaBQY9asfoVE8jhx690EKr6BJ\r\n/wp2NIKUVhsnPxPbXV1E9TVIOPgJoMVDf/LVw2OlLUulCapkrtIxiTtg1+ez\r\ndC4cT0qF3Z+TWxa2otUkfoTgB4FKvQRbav0=\r\n=yez/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.28","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1680346697411_1680346736388_0.9699980861430246","host":"s3://npm-registry-packages"}},"1.1.1-canary-08d62d2-1680346698641":{"name":"@iadvize-oss/store","version":"1.1.1-canary-08d62d2-1680346698641","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/store@1.1.1-canary-08d62d2-1680346698641","maintainers":[{"name":"etiennerd","email":"rouillard.etienne@gmail.com"},{"name":"jules.trehorel","email":"jules.trehorel@iadvize.com"},{"name":"cffparisot","email":"cecile.parisot@iadvize.com"},{"name":"davidiadvize","email":"david.bonnemaison@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"}],"homepage":"https://github.com/iadvize/store-library#readme","bugs":{"url":"https://github.com/iadvize/store-library/issues"},"dist":{"shasum":"f38b72bf3953d8f163835d5480f508d857825500","tarball":"https://registry.npmjs.org/@iadvize-oss/store/-/store-1.1.1-canary-08d62d2-1680346698641.tgz","fileCount":7,"integrity":"sha512-pwLK5C+rnn1WomN4vZqJO8wKREZ6FcHOKJAW1Cjyh0lvUZ/aXNhcZ5lUSvkXv/u1Yk5wxx2asejqqLb4BDrXJQ==","signatures":[{"sig":"MEQCICoc5biHCHGIMRAULKSs+IWGuWjtEq2c4AcZMpV88dFHAiBXsZYyic5JPKcXCno2/aDWnKvPG+OybhTyWDgCuC0iKw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16849,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkKA51ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp2fhAAi+orMycdvu5AJMpyM7xjzs9bALsbavr/tj+BY9p3ed8UnOku\r\nlzqG6w/U6ioqfeuNtH3eATTEofvQWVBfOitgtcUYiy1AgS2dKhDYSWycGDHO\r\n2OkIo88DAhOkTpo2CIPlODbIKcmdDRcQ/QvYcf9wg+vPQUt/9BGDGLsyWHHk\r\nKKj9NqgwtBaUR1sPzp7rxE+338RJHxhxzrbnGP+vWbiTGh/NsGAtpfEqDD2m\r\n2JEqosXvBoUbXLUIVK8uCzw1Rn8Bw9wVMZyU6I3ykk0Y5GcMGi4LxOcCSLGk\r\n3DP8EdWKd5wnGSaknMgKrh8Eu4GauxcERvIvQo1ixPNAO1UPsj77RQiHPo4m\r\nBsr6Eb8CkK5aK+8JB1NT4xf8rm2Jr6b/+zOhZZen9pTlPJEA0EF7o3bdOo5X\r\nW72GHd8xz3cC/xaugIQZfcS2W5GtEX5uu96ib7JgbzZP5MNOxio4ZXN9KArj\r\nTfsoOu74PMZDbXdPknbsAkHup4/4oOh/5VR05iklQtW9vQL9iuMcHlDwkiX7\r\n0kv5CJ6fVKlRVHVf/ioSLm4VvpDSw2xvCsXr55hK/RBcHdiLQC3g0zzys4H7\r\nOcs5+CKO+vvtiUHwUABSQltk+L1P8N9fOOeUnQo602+IFIh7C+/jsja+fbkC\r\n3BJYm65KOwyy+xUlkompCgCYKlNXZ24TRek=\r\n=rndG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/store\n==============\n\nA lightweight Javascript store library.\n\n[📖 Documentation](https://iadvize.github.io/store-library/packages/store/)\n\n# Basic example\n\n```typescript\ntype Todo = {\n  done: boolean;\n  label: string;\n};\n\ntype State = Todo[];\n\n// initialise the store with an initial state\nconst todoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" },\n])();\n\n// create a reducer function adding a new Todo\nfunction appendNewTodoOnState(newTodo: string) {\n  return function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ];\n  }\n}\n\n// associating the reducer function and a store instance\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\n// create a reducer function removing all todos, ie. returning and empty state\nconst emptyTodosReducer = () => [];\n\n// associating the reducer function and a store instance\nconst emptyTodos = todoStore.apply(emptyTodosReducer);\n\n// registering a listener\nconst subscribeToTodoStore = todoStore.subscribe(newState => {\n  console.log(\"newState\", newState);\n});\n\n// applying the listener\nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// triggering a change\nappendNewTodo(\"have drink with my colleagues\")();\n\n// will log:\n// newState, [{done: false, label: 'writtings some doc'},{done: true, label: 'napping'},{done: false, label: 'have drink with my colleagues'}]\n\n// emptying the store \nemptyTodos();\n\n// will log:\n// newState, []\n\n// removing the listener we don't need anymore\nunsubscribeFromTodoStore();\n```\n\n# Reference\n\n## `Store.create` - Store creation\n\n```\nStore.create<State>(initialState: () => State): () => Store<State>\n```\n\nYou create a store with `Store.create` by passing it a function that will return\nyour initial state. This will return you a function to call to create the\ncorresponding store as many times you need.\n\n**Params**\n\n- `initialState: () => State` - Function that return the initial state\n\n**Returns**\n\n`() => Store<State>` - Effect to call to receive a Store initialized with the\ninitial state\n\n**Example**\n\n```typescript\nconst createTodoStore = Store.create<State>(() => [\n  { done: false, label: \"writtings some doc\" },\n  { done: true, label: \"napping\" }\n]);\n\nconst todoStore = createTodoStore();\n```\n\n## `<store>.read` - Reading the state\n\nCall `<store>.read` to read the state.\n\n```\n<store>.read(): State\n```\n\n**Returns**\n\n`State` - Returns the state. \n\n**Example**\n\n```typescript\nconst state = store.read();\nconsole.log('state', state);\n```\n\n## `<store>.subscribe` - Subscribing to state change\n\nYou subscribe to state changes with `<store>.subscribe`. It accepts a listener\nthat receives the new state as a parameter.\n\n```\n<store>.subscribe(listener: Listener<State>): () => Unsubscribe\n```\n\n**Params**\n\n- `listener: Listener<State>` - Where\n  `Listener<State> = (state: State) => void`. The function that will be called\n  when state change with the new state as argument.\n\n**Returns**\n\n`() => Unsubscribe` - A function to call to apply the subscription as many times\nyou need. \n\nWhen applying a subscription, you will receive in return an unsubscribe function\nto call to unsubscribe this specific applied subscription where\n`type Unsubscribe: () => void`.\n\n**Example**\n\n```typescript\n// prepare the subscription to change\n// subscribeToTodoStore :: () => Unsubscribe\nconst subscribeToTodoStore = todoStore.subscribe((state) =>\n  console.log('new state', state);\n);\n\n// starting the listener\n// unsubscribeFromTodoStore :: () => void \nconst unsubscribeFromTodoStore = subscribeToTodoStore();\n\n// unsubscribe when you are done\nunsubscribeFromTodoStore();\n```\n\n## `<store>.apply` - Updating state\n\nCall `<store>.apply` with a reducer to update the store.\n\n```\n<store>.apply(reducer: (state: State) => State): () => void\n```\n\n**Params**\n\n- `reducer: (state: State) => State` - A function that receive a state and\n  return a new state.\n\n**Returns**\n\n`() => void` - An effect to call to apply the update synchronously.\n\n**Example**\n\n```typescript\n// preparing an update function\n// appendNewTodoOnState :: (newTodo: string) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done: false, label: newTodo }\n    ]\n  }\n}\n\n// Preparing the update on the store\nconst appendNewTodo = todoStore.apply(\n  appendNewTodoOnState('have drink with my colleagues')\n);\n\n// Applying the transformation\nappendNewTodo();\n```\n\nHere we apply a reducer function directly on the store instance and trigger the\nchange with the `appendNewTodo` function.\n\nOf course we would need `appendNewTodo` to accept any todo rather than a preset\none:\n\n```typescript\n// Preparing the update on the store\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = (newTodo: string) => todoStore.apply(\n  appendNewTodoOnState(newTodo)\n);\n\n// Applying the transformation\nappendNewTodo('have drink with my colleagues')();\n```\n\nBecause this operation is so common, we can use `Store.liftAndApply` which will\nhandle the parameter passing for us and cut on the boilerplate:\n\n```typescript\n// appendNewTodo :: (newTodo: string) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodoOnState, todoStore);\n\nappendNewTodo('have drink with my colleagues')();\n```\n\n## `Store.liftAndApply` - create a parametrized update\n\nCall `Store.liftAndApply` to easily create an update effect function. Pass it\na function that given any parameters returns a reducer `State => State` and the\nstore.\n\n```\nStore.liftAndApply<\n  State,\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  Fn extends (...args: any[]) => Reducer<State>\n>(fn: Fn, store: Store<State>): (...args: Parameters<Fn>) => () => void\n```\n\n**Params**\n\n- `fn: Fn` - Where `Fn extends (...args: any[]) => Reducer<State>` a function\n  that returns a reducer.\n\n- `store: Store<State>` - The store we want to update.\n\n**Returns**\n\nAn function that accept `fn` arguments and return an effect to call to apply the\nupdate synchronously.\n\n**Example**\n\n```typescript\n// appendNewTodoOnState :: (newTodo: string, done: boolean) => (state: State) => State\nfunction appendNewTodoOnState(newTodo: string, done: boolean) {\n  function appendNewTodoReducer(state: State) {\n    return [\n      ...state,\n      { done, label: newTodo }\n    ]\n  }\n}\n\n// appendNewTodo :: (newTodo: string, done: boolean) => () => void\nconst appendNewTodo = Store.liftAndApply(appendNewTodo, todoStore);\n\nappendNewTodo('Groceries already done', true);\n```\n","private":false,"scripts":{"docs":"typedoc src/index.ts","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.d.ts --cache","test:js":"jest --coverage"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"_npmVersion":"6.14.18","description":"Store library","directories":{},"sideEffects":false,"_nodeVersion":"14.21.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^27.0.3","tslib":"^2.2.0","eslint":"^7.27.0","rollup":"^2.50.5","ts-jest":"^27.0.2","typedoc":"^0.23.28","typescript":"4.3.5","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^19.0.0","rollup-plugin-multi-input":"^1.3.1","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/store_1.1.1-canary-08d62d2-1680346698641_1680346741297_0.5655780083292363","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-07-03T16:11:27.754Z","modified":"2025-10-22T09:22:12.776Z","0.0.0-canary-78e185b-1593792635481":"2020-07-03T16:11:28.153Z","0.0.0-canary-78e185b-1593792638910":"2020-07-03T16:11:32.323Z","0.0.0-canary-78e185b-1593792885775":"2020-07-03T16:15:26.900Z","0.0.0-canary-13f6145-1593794403652":"2020-07-03T16:40:56.196Z","0.1.0":"2020-07-03T16:43:16.514Z","0.1.0-canary-a6c5fa6-1593796920106":"2020-07-03T17:22:41.484Z","0.1.0-canary-a6c5fa6-1593796920964":"2020-07-03T17:22:49.741Z","0.1.1-beta.0":"2020-07-03T17:26:35.364Z","0.1.1-beta.0-canary-73de7a8-1593798188999":"2020-07-03T17:43:53.086Z","0.1.1-beta.0-canary-73de7a8-1593798226665":"2020-07-03T17:44:31.062Z","0.1.1-beta.0-canary-74383ec-1593798750102":"2020-07-03T17:53:12.800Z","0.1.1-beta.0-canary-6077dd6-1593799113386":"2020-07-03T17:59:28.506Z","0.1.1-beta.0-canary-9567506-1593803816026":"2020-07-03T19:17:36.516Z","0.1.1-beta.0-canary-3af8852-1593804133324":"2020-07-03T19:22:54.813Z","0.1.1-beta.0-canary-3af8852-1593804135256":"2020-07-03T19:23:10.615Z","0.1.1-beta.1":"2020-07-03T19:29:23.161Z","0.1.1-beta.1-canary-1531df4-1593861446694":"2020-07-04T11:18:15.452Z","0.1.1-beta.1-canary-1531df4-1593861440069":"2020-07-04T11:18:37.753Z","0.1.1-beta.1-canary-57cac7c-1593927162716":"2020-07-05T05:33:34.754Z","0.1.1-beta.1-canary-57cac7c-1593927167449":"2020-07-05T05:33:49.360Z","0.1.1-beta.1-canary-7904260-1594063602125":"2020-07-06T19:27:29.609Z","0.1.1-beta.1-canary-7904260-1594063600692":"2020-07-06T19:27:44.363Z","0.1.1-beta.1-canary-f56cfed-1594069922695":"2020-07-06T21:12:56.072Z","0.1.1-beta.1-canary-f56cfed-1594069933207":"2020-07-06T21:13:03.761Z","0.1.1-beta.1-canary-f56cfed-1594069930240":"2020-07-06T21:13:58.038Z","0.1.1-beta.1-canary-384a133-1594150944060":"2020-07-07T19:43:20.706Z","0.1.1-beta.1-canary-384a133-1594150947511":"2020-07-07T19:43:34.998Z","0.1.1-beta.1-canary-d607ade-1594151271343":"2020-07-07T19:48:37.448Z","0.1.1-beta.1-canary-e44d33e-1594587835409":"2020-07-12T21:04:55.200Z","0.1.1-beta.1-canary-e44d33e-1594587838184":"2020-07-12T21:05:09.108Z","0.1.1-beta.1-canary-88edb19-1594594071665":"2020-07-12T22:48:50.107Z","0.1.1-beta.1-canary-e9134b2-1594637375619":"2020-07-13T10:50:28.381Z","0.1.1-beta.1-canary-e9134b2-1594637375609":"2020-07-13T10:50:43.894Z","0.1.1-beta.1-canary-e212c6b-1594683871709":"2020-07-13T23:45:25.281Z","0.1.1-beta.1-canary-e212c6b-1594683870301":"2020-07-13T23:45:31.692Z","0.1.1-beta.1-canary-2977a54-1594684461938":"2020-07-13T23:55:11.149Z","0.1.1-beta.1-canary-2977a54-1594684462812":"2020-07-13T23:55:23.839Z","0.1.1-beta.1-canary-33c8496-1594712079540":"2020-07-14T07:35:42.537Z","0.1.1-beta.1-canary-53bc6f1-1594764933441":"2020-07-14T22:16:19.492Z","0.1.1-beta.1-canary-a6e3fd0-1594851515219":"2020-07-15T22:19:20.365Z","0.1.1-beta.1-canary-a6e3fd0-1594851513160":"2020-07-15T22:19:30.607Z","0.1.1-beta.1-canary-a6e3fd0-1594851512413":"2020-07-15T22:19:44.002Z","0.1.1-beta.1-canary-9cb04e0-1594888633620":"2020-07-16T08:38:18.008Z","0.1.1-beta.1-canary-379e9b2-1594888650110":"2020-07-16T08:38:31.760Z","0.1.1-beta.1-canary-9da445b-1594929200743":"2020-07-16T19:54:08.353Z","0.1.1-beta.1-canary-9da445b-1594929201253":"2020-07-16T19:54:23.092Z","0.1.1-beta.1-canary-e85d998-1594963537461":"2020-07-17T05:26:20.183Z","0.1.1-beta.1-canary-e85d998-1594963539813":"2020-07-17T05:26:30.860Z","0.1.1-beta.1-canary-406844f-1594968886419":"2020-07-17T06:55:32.089Z","0.1.1-beta.1-canary-1b89299-1595047682462":"2020-07-18T04:48:44.335Z","0.1.1-beta.1-canary-1b89299-1595047700113":"2020-07-18T04:49:14.901Z","0.1.1-beta.1-canary-15d40df-1595052603714":"2020-07-18T06:11:02.987Z","0.1.1-beta.1-canary-4bc65b5-1595052865085":"2020-07-18T06:17:34.984Z","0.1.1-beta.1-canary-b59168a-1595089727762":"2020-07-18T16:29:27.797Z","0.1.1-beta.1-canary-b59168a-1595089729543":"2020-07-18T16:29:37.653Z","0.1.1-beta.1-canary-d68ccd0-1595100102604":"2020-07-18T19:22:23.984Z","0.1.1-beta.1-canary-d68ccd0-1595100106026":"2020-07-18T19:22:36.917Z","0.1.1-beta.1-canary-5c15244-1595100183220":"2020-07-18T19:23:51.586Z","0.1.1-beta.1-canary-5c15244-1595100182405":"2020-07-18T19:24:18.532Z","0.1.1-beta.1-canary-7c78c2e-1595100661712":"2020-07-18T19:31:44.993Z","0.1.1-beta.1-canary-dfd0e87-1595100822165":"2020-07-18T19:34:22.886Z","0.1.1-beta.1-canary-6658d39-1595395283198":"2020-07-22T05:22:06.273Z","0.1.1-beta.1-canary-6658d39-1595395296782":"2020-07-22T05:22:45.819Z","0.1.1-beta.1-canary-94717e0-1595522684840":"2020-07-23T16:45:28.312Z","0.1.1-beta.1-canary-94717e0-1595522686478":"2020-07-23T16:45:34.701Z","0.1.1-beta.1-canary-94717e0-1595522681171":"2020-07-23T16:45:42.735Z","0.1.1-beta.1-canary-7c6c410-1595530728682":"2020-07-23T18:59:34.276Z","0.1.1-beta.1-canary-0db5dac-1595530793940":"2020-07-23T19:00:56.571Z","0.1.1-beta.1-canary-7243d09-1595548894831":"2020-07-24T00:02:18.761Z","0.1.1-beta.1-canary-7243d09-1595548896165":"2020-07-24T00:02:27.360Z","0.1.1-beta.1-canary-7243d09-1595548899533":"2020-07-24T00:02:34.711Z","0.1.1-beta.1-canary-41a87b2-1595927098919":"2020-07-28T09:05:45.345Z","0.1.1-beta.1-canary-41a87b2-1595927100551":"2020-07-28T09:06:15.562Z","0.1.1-beta.1-canary-f2bdef4-1596105909955":"2020-07-30T10:46:02.636Z","0.1.1-beta.1-canary-f2bdef4-1596105915606":"2020-07-30T10:46:16.613Z","0.1.1-beta.1-canary-2cc7f9f-1596109319511":"2020-07-30T11:43:03.011Z","0.1.1-beta.1-canary-8bac19e-1596109317428":"2020-07-30T11:43:19.967Z","0.1.1-beta.1-canary-3bbd938-1596173579623":"2020-07-31T05:33:46.398Z","0.1.1-beta.1-canary-3bbd938-1596173576246":"2020-07-31T05:33:50.271Z","0.1.1-beta.1-canary-5c638ae-1596193307470":"2020-07-31T11:02:43.232Z","0.1.1-beta.1-canary-5c638ae-1596193307326":"2020-07-31T11:02:57.832Z","0.1.1-beta.1-canary-d816a04-1596238573598":"2020-07-31T23:36:52.896Z","0.1.1-beta.1-canary-d816a04-1596238574602":"2020-07-31T23:37:10.460Z","0.1.1-beta.1-canary-0836c80-1596406709591":"2020-08-02T22:19:26.084Z","0.1.1-beta.1-canary-aa451ca-1596492929392":"2020-08-03T22:16:26.490Z","0.1.1-beta.1-canary-c01bf33-1596579274849":"2020-08-04T22:15:19.096Z","0.1.1-beta.1-canary-ceb9e9c-1596672332082":"2020-08-06T00:06:18.093Z","0.1.1-beta.1-canary-ceb9e9c-1596672339865":"2020-08-06T00:06:39.430Z","0.1.1-beta.1-canary-8b35b3a-1596753592307":"2020-08-06T22:40:37.580Z","0.1.1-beta.1-canary-8b35b3a-1596753627736":"2020-08-06T22:41:09.412Z","0.1.1-beta.1-canary-1b01986-1596824997735":"2020-08-07T18:30:41.076Z","0.1.1-beta.1-canary-1b01986-1596824996142":"2020-08-07T18:30:58.826Z","0.1.1-beta.1-canary-b7da9f2-1596830003325":"2020-08-07T19:54:11.437Z","0.1.1-beta.1-canary-b7da9f2-1596830005960":"2020-08-07T19:54:14.885Z","0.1.1-beta.1-canary-cbed595-1596934271099":"2020-08-09T00:52:15.393Z","0.1.1-beta.1-canary-cbed595-1596934268193":"2020-08-09T00:52:29.097Z","0.1.1-beta.1-canary-c5fe0ba-1596978391327":"2020-08-09T13:07:25.305Z","0.1.1-beta.1-canary-c5fe0ba-1596978388611":"2020-08-09T13:07:40.919Z","0.1.1-beta.1-canary-40e8fd1-1597044224222":"2020-08-10T07:24:37.289Z","0.1.1-beta.1-canary-7335af5-1597044237825":"2020-08-10T07:24:50.644Z","0.1.1-beta.1-canary-5a84f2a-1597044418286":"2020-08-10T07:27:52.935Z","0.1.1-beta.1-canary-6a4672f-1597044441137":"2020-08-10T07:28:13.594Z","0.1.1-beta.1-canary-a4f01e6-1597044580143":"2020-08-10T07:30:30.086Z","0.1.1-beta.1-canary-62ce1fc-1597044587007":"2020-08-10T07:30:34.380Z","0.1.1-beta.1-canary-0fa5751-1597044771127":"2020-08-10T07:33:37.700Z","0.1.1-beta.1-canary-1a37def-1597044770687":"2020-08-10T07:33:54.142Z","0.1.1-beta.1-canary-c8a8e12-1597044976405":"2020-08-10T07:37:00.824Z","0.1.1-beta.1-canary-9a115ff-1597059582264":"2020-08-10T11:40:26.043Z","0.1.1-beta.1-canary-9a115ff-1597059582601":"2020-08-10T11:40:35.163Z","0.1.1-beta.1-canary-e5008af-1597142542661":"2020-08-11T10:43:04.424Z","0.1.1-beta.1-canary-e5008af-1597142548118":"2020-08-11T10:43:11.336Z","0.1.1-beta.1-canary-3ea22b7-1597266328879":"2020-08-12T21:06:15.611Z","0.1.1-beta.1-canary-3ea22b7-1597266324713":"2020-08-12T21:06:21.750Z","0.1.1-beta.1-canary-52bd956-1597326379200":"2020-08-13T13:47:00.912Z","0.1.1-beta.1-canary-52bd956-1597326377494":"2020-08-13T13:47:11.039Z","0.1.1-beta.1-canary-90db262-1597348988111":"2020-08-13T20:03:55.355Z","0.1.1-beta.1-canary-90db262-1597348990029":"2020-08-13T20:04:15.815Z","0.1.1-beta.1-canary-20c3df1-1597383020273":"2020-08-14T05:31:06.703Z","0.1.1-beta.1-canary-20c3df1-1597383024073":"2020-08-14T05:31:22.203Z","0.1.1-beta.1-canary-c00a01c-1597440826470":"2020-08-14T21:35:06.163Z","0.1.1-beta.1-canary-c00a01c-1597440824908":"2020-08-14T21:35:21.095Z","0.1.1-beta.1-canary-a400ff8-1597448982542":"2020-08-14T23:50:29.044Z","0.1.1-beta.1-canary-a400ff8-1597448982395":"2020-08-14T23:50:43.176Z","0.1.1-beta.1-canary-e545cb2-1597467241547":"2020-08-15T04:54:48.828Z","0.1.1-beta.1-canary-e545cb2-1597467242331":"2020-08-15T04:55:03.291Z","0.1.1-beta.1-canary-ae0fe20-1597553513561":"2020-08-16T04:52:35.661Z","0.1.1-beta.1-canary-ae0fe20-1597553515893":"2020-08-16T04:53:57.475Z","0.1.1-beta.1-canary-c1aa20e-1597556676637":"2020-08-16T05:45:18.242Z","0.1.1-beta.1-canary-c1aa20e-1597556679855":"2020-08-16T05:45:27.751Z","0.1.1-beta.1-canary-80b0cea-1597607674216":"2020-08-16T19:55:30.086Z","0.1.1-beta.1-canary-f7f7483-1597607678531":"2020-08-16T19:55:39.739Z","0.1.1-beta.1-canary-e1ad6c7-1597617944168":"2020-08-16T22:46:25.670Z","0.1.1-beta.1-canary-b5fa4cc-1597702483719":"2020-08-17T22:15:26.151Z","0.1.1-beta.1-canary-84c57a8-1597820670814":"2020-08-19T07:05:18.186Z","0.1.1-beta.1-canary-84c57a8-1597820666754":"2020-08-19T07:05:31.163Z","0.1.1-beta.1-canary-52fae2c-1598078449417":"2020-08-22T06:41:31.363Z","0.1.1-beta.1-canary-52fae2c-1598078451504":"2020-08-22T06:41:35.541Z","0.1.1-beta.1-canary-75ead24-1598101775909":"2020-08-22T13:10:19.072Z","0.1.1-beta.1-canary-75ead24-1598101772693":"2020-08-22T13:10:36.568Z","0.1.1-beta.1-canary-43b0029-1598508135656":"2020-08-27T06:03:04.587Z","0.1.1-beta.1-canary-43b0029-1598508136298":"2020-08-27T06:03:23.455Z","0.1.1-beta.1-canary-58684f6-1598511208985":"2020-08-27T06:54:14.571Z","0.1.1-beta.1-canary-58684f6-1598511209293":"2020-08-27T06:54:20.916Z","0.1.1-beta.1-canary-302cb2f-1598511379174":"2020-08-27T06:57:23.873Z","0.1.1-beta.1-canary-6897d81-1598592530680":"2020-08-28T05:29:36.498Z","0.1.1-beta.1-canary-6897d81-1598592533896":"2020-08-28T05:29:44.824Z","0.1.1-beta.1-canary-9689f60-1598596145106":"2020-08-28T06:29:45.811Z","0.1.1-beta.1-canary-6199248-1598596356042":"2020-08-28T06:33:29.894Z","0.1.1-beta.1-canary-6b88c0d-1598708236487":"2020-08-29T13:37:59.959Z","0.1.1-beta.1-canary-6b88c0d-1598708238957":"2020-08-29T13:38:06.508Z","0.1.1-beta.1-canary-28dfe14-1598710108101":"2020-08-29T14:09:25.613Z","0.1.1-beta.1-canary-28dfe14-1598710108757":"2020-08-29T14:09:39.935Z","0.1.1-beta.1-canary-e0a33c4-1598712180924":"2020-08-29T14:43:54.038Z","0.1.1-beta.1-canary-e0a33c4-1598712180584":"2020-08-29T14:44:03.038Z","0.1.1-beta.1-canary-00fd3e9-1598814050788":"2020-08-30T19:01:52.030Z","0.1.1-beta.1-canary-a75e93c-1598814068384":"2020-08-30T19:02:06.490Z","0.1.1-beta.1-canary-898f6b4-1598814018783":"2020-08-30T19:03:11.304Z","0.1.1-beta.1-canary-4efe7cd-1598814242233":"2020-08-30T19:04:47.218Z","0.1.1-beta.1-canary-e245248-1598814300145":"2020-08-30T19:05:49.072Z","0.1.1-beta.1-canary-9f2b9c5-1598814370340":"2020-08-30T19:07:01.654Z","0.1.1-beta.1-canary-91d1219-1598814441744":"2020-08-30T19:08:23.550Z","0.1.1-beta.1-canary-60dff67-1598814452451":"2020-08-30T19:08:42.570Z","0.1.1-beta.1-canary-1259609-1598814658339":"2020-08-30T19:11:49.640Z","0.1.1-beta.1-canary-b727291-1598814833332":"2020-08-30T19:14:49.448Z","0.1.1-beta.1-canary-93368f9-1598968508523":"2020-09-01T13:56:05.414Z","0.1.1-beta.1-canary-93368f9-1598968509830":"2020-09-01T13:56:14.005Z","0.1.1-beta.1-canary-179958d-1598975322761":"2020-09-01T15:49:29.061Z","0.1.1-beta.1-canary-179958d-1598975321633":"2020-09-01T15:49:33.092Z","0.1.1-beta.1-canary-20ea584-1599031353261":"2020-09-02T07:23:30.741Z","0.1.1-beta.1-canary-20ea584-1599031353802":"2020-09-02T07:23:47.868Z","0.1.1-beta.1-canary-7873fe6-1599035636524":"2020-09-02T08:35:40.298Z","0.1.1-beta.1-canary-fecb9f9-1599035863913":"2020-09-02T08:38:25.924Z","0.1.1-beta.1-canary-6c430a7-1599067321261":"2020-09-02T17:22:50.380Z","0.1.1-beta.1-canary-6c430a7-1599067324562":"2020-09-02T17:22:57.856Z","0.1.1-beta.1-canary-48cf9e2-1599145708326":"2020-09-03T15:09:22.201Z","0.1.1-beta.1-canary-48cf9e2-1599145712094":"2020-09-03T15:09:39.574Z","0.1.1-beta.1-canary-4eddecb-1599146632825":"2020-09-03T15:24:41.541Z","0.1.1-beta.1-canary-cfe90b1-1599330101855":"2020-09-05T18:22:30.825Z","0.1.1-beta.1-canary-cfe90b1-1599330108663":"2020-09-05T18:22:42.298Z","0.1.1-beta.1-canary-d78862d-1599333660354":"2020-09-05T19:21:47.808Z","0.1.1-beta.1-canary-978b682-1599339842002":"2020-09-05T21:04:54.996Z","0.1.1-beta.1-canary-978b682-1599339847878":"2020-09-05T21:04:59.176Z","0.1.1-beta.1-canary-a374874-1599936643095":"2020-09-12T18:51:28.460Z","0.1.1-beta.1-canary-a374874-1599936640605":"2020-09-12T18:51:36.155Z","0.1.1-beta.1-canary-196f9bf-1600038347756":"2020-09-13T23:06:46.175Z","0.1.1-beta.1-canary-67661e6-1600350617017":"2020-09-17T13:51:07.439Z","0.1.1-beta.1-canary-c1efd1d-1600350621428":"2020-09-17T13:51:35.799Z","0.1.1-beta.1-canary-7ff4b0f-1600526223693":"2020-09-19T14:37:52.465Z","0.1.1-beta.1-canary-7ff4b0f-1600526224209":"2020-09-19T14:38:00.541Z","0.1.1-beta.1-canary-f50cb2a-1600532263453":"2020-09-19T16:18:33.367Z","0.1.1-beta.1-canary-fc3c95b-1600532456987":"2020-09-19T16:21:44.580Z","0.1.1-beta.1-canary-7885fd2-1600599358148":"2020-09-20T10:56:45.726Z","0.1.1-beta.1-canary-7885fd2-1600599363854":"2020-09-20T10:56:53.612Z","0.1.1-beta.1-canary-53dab58-1600653936493":"2020-09-21T02:06:30.893Z","0.1.1-beta.1-canary-53dab58-1600653937140":"2020-09-21T02:06:54.165Z","0.1.1-beta.1-canary-a5f9f0f-1600670413494":"2020-09-21T06:41:05.688Z","0.1.1-beta.1-canary-3dbacad-1600677846752":"2020-09-21T08:44:52.644Z","0.1.1-beta.1-canary-3dbacad-1600677845280":"2020-09-21T08:44:58.240Z","0.1.1-beta.1-canary-bfa0287-1601096686023":"2020-09-26T05:05:40.268Z","0.1.1-beta.1-canary-bfa0287-1601096684300":"2020-09-26T05:05:55.566Z","0.1.1-beta.1-canary-5c9afc1-1601158472785":"2020-09-26T22:15:16.815Z","0.1.1-beta.1-canary-5c9afc1-1601158474544":"2020-09-26T22:15:31.116Z","0.1.1-beta.1-canary-fe7cb43-1601223881235":"2020-09-27T16:25:32.685Z","0.1.1-beta.1-canary-54573f3-1601461240206":"2020-09-30T10:21:29.610Z","0.1.1-beta.1-canary-54573f3-1601461243537":"2020-09-30T10:21:35.930Z","0.1.1-beta.1-canary-0733957-1601948722979":"2020-10-06T01:46:16.971Z","0.1.1-beta.1-canary-0733957-1601948726081":"2020-10-06T01:46:31.654Z","0.1.1-beta.1-canary-381fbfd-1602084705666":"2020-10-07T15:32:37.330Z","0.1.1-beta.1-canary-381fbfd-1602084704750":"2020-10-07T15:32:47.184Z","0.1.1-beta.1-canary-3308ad9-1602101761366":"2020-10-07T20:17:02.795Z","0.1.1-beta.1-canary-3308ad9-1602101764632":"2020-10-07T20:17:07.470Z","0.1.1-beta.1-canary-3ec1053-1602243271924":"2020-10-09T11:35:23.797Z","0.1.1-beta.1-canary-3ec1053-1602243270932":"2020-10-09T11:35:40.725Z","0.1.1-beta.1-canary-ab9ac0e-1602418192575":"2020-10-11T12:10:43.237Z","0.1.1-beta.1-canary-ab9ac0e-1602418192166":"2020-10-11T12:10:50.004Z","0.1.1-beta.1-canary-9fe675e-1602425573579":"2020-10-11T14:13:47.370Z","0.1.1-beta.1-canary-9fe675e-1602425576737":"2020-10-11T14:14:05.952Z","0.1.1-beta.1-canary-8e9ea46-1602439728465":"2020-10-11T18:09:40.988Z","0.1.1-beta.1-canary-8e9ea46-1602439730529":"2020-10-11T18:09:56.939Z","0.1.1-beta.1-canary-c96f4ba-1602448353930":"2020-10-11T20:33:25.870Z","0.1.1-beta.1-canary-1693660-1602448357683":"2020-10-11T20:33:43.552Z","0.1.1-beta.1-canary-0c1a65e-1602448552513":"2020-10-11T20:36:50.614Z","0.1.1-beta.1-canary-152815d-1602694695133":"2020-10-14T16:59:03.393Z","0.1.1-beta.1-canary-152815d-1602694697256":"2020-10-14T16:59:11.910Z","0.1.1-beta.1-canary-7beab2e-1602713711468":"2020-10-14T22:16:06.654Z","0.1.1-beta.1-canary-b5c481c-1602767725686":"2020-10-15T13:16:48.074Z","0.1.1-beta.1-canary-33e7e8f-1602797116973":"2020-10-15T21:26:15.062Z","0.1.1-beta.1-canary-33e7e8f-1602797113994":"2020-10-15T21:26:20.113Z","0.1.1-beta.1-canary-c2ebe94-1602798174729":"2020-10-15T21:43:44.899Z","0.1.1-beta.1-canary-c2ebe94-1602798178147":"2020-10-15T21:43:59.351Z","0.1.1-beta.1-canary-7b553a3-1602819032151":"2020-10-16T03:31:31.839Z","0.1.1-beta.1-canary-e710c02-1602919231114":"2020-10-17T07:21:18.422Z","0.1.1-beta.1-canary-e710c02-1602919234464":"2020-10-17T07:21:32.537Z","0.1.1-beta.1-canary-b8cca2b-1603032136207":"2020-10-18T14:43:04.806Z","0.1.1-beta.1-canary-b8cca2b-1603032136594":"2020-10-18T14:43:12.114Z","0.1.1-beta.1-canary-ce8d42e-1603093098559":"2020-10-19T07:39:24.933Z","0.1.1-beta.1-canary-5ada8ad-1603177651383":"2020-10-20T07:08:21.629Z","0.1.1-beta.1-canary-5ada8ad-1603177653544":"2020-10-20T07:08:31.015Z","0.1.1-beta.1-canary-58e42d9-1603181165470":"2020-10-20T08:06:54.638Z","0.1.1-beta.1-canary-a425c62-1603293284350":"2020-10-21T15:15:37.367Z","0.1.1-beta.1-canary-a425c62-1603293285871":"2020-10-21T15:15:46.086Z","0.1.1-beta.1-canary-cccb9fc-1603355719722":"2020-10-22T08:36:22.006Z","0.1.1-beta.1-canary-cccb9fc-1603355721493":"2020-10-22T08:36:39.665Z","0.1.1-beta.1-canary-bf93fbd-1603391418573":"2020-10-22T18:31:09.656Z","0.1.1-beta.1-canary-7b79242-1603546469918":"2020-10-24T13:35:15.806Z","0.1.1-beta.1-canary-7b79242-1603546472380":"2020-10-24T13:35:38.850Z","0.1.1-beta.1-canary-aaab049-1603615990675":"2020-10-25T08:54:00.784Z","0.1.1-beta.1-canary-aaab049-1603615990774":"2020-10-25T08:54:06.432Z","0.1.1-beta.1-canary-239c3e5-1603634516284":"2020-10-25T14:02:45.443Z","0.1.1-beta.1-canary-239c3e5-1603634521222":"2020-10-25T14:02:55.056Z","0.1.1-beta.1-canary-80e2987-1603653124215":"2020-10-25T19:13:00.147Z","0.1.1-beta.1-canary-80e2987-1603653130583":"2020-10-25T19:13:15.613Z","0.1.1-beta.1-canary-fcbb76c-1603666226712":"2020-10-25T22:51:14.515Z","0.1.1-beta.1-canary-fb2522b-1603826833807":"2020-10-27T19:28:02.216Z","0.1.1-beta.1-canary-fb2522b-1603826835054":"2020-10-27T19:28:19.803Z","0.1.1-beta.1-canary-1c50815-1603839105229":"2020-10-27T22:52:34.874Z","0.1.1-beta.1-canary-1c50815-1603839106313":"2020-10-27T22:52:55.663Z","0.1.1-beta.1-canary-f559cf4-1603845393759":"2020-10-28T00:37:23.066Z","0.1.1-beta.1-canary-f559cf4-1603845395668":"2020-10-28T00:37:44.300Z","0.1.1-beta.1-canary-ea5e0da-1603850067955":"2020-10-28T01:55:15.181Z","0.1.1-beta.1-canary-ea5e0da-1603850066538":"2020-10-28T01:55:23.942Z","0.1.1-beta.1-canary-5a8be5b-1603908642665":"2020-10-28T18:11:37.423Z","0.1.1-beta.1-canary-bd589fe-1603955408835":"2020-10-29T07:11:07.520Z","0.1.1-beta.1-canary-f555d5a-1604107425250":"2020-10-31T01:24:40.903Z","0.1.1-beta.1-canary-46370f1-1604107425119":"2020-10-31T01:24:56.717Z","0.1.1-beta.1-canary-b940b20-1604128025754":"2020-10-31T07:08:05.056Z","0.1.1-beta.1-canary-73f3b6e-1604128189160":"2020-10-31T07:10:47.113Z","0.1.1-beta.1-canary-9b83162-1604213894680":"2020-11-01T06:59:03.137Z","0.1.1-beta.1-canary-9b83162-1604213897064":"2020-11-01T06:59:21.182Z","0.1.1-beta.1-canary-6f4bb5f-1604256854854":"2020-11-01T18:55:09.413Z","0.1.1-beta.1-canary-d69cdc0-1604309872417":"2020-11-02T09:38:56.857Z","0.1.1-beta.1-canary-d69cdc0-1604309878676":"2020-11-02T09:39:12.029Z","0.1.1-beta.1-canary-b7a693b-1604310605242":"2020-11-02T09:50:53.815Z","0.1.1-beta.1-canary-b7a693b-1604310606351":"2020-11-02T09:51:06.117Z","0.1.1-beta.1-canary-02f98dd-1604310761792":"2020-11-02T09:53:44.489Z","0.1.1-beta.1-canary-02f98dd-1604310763912":"2020-11-02T09:53:59.663Z","0.1.1-beta.1-canary-689e2f0-1604310799590":"2020-11-02T09:54:12.031Z","0.1.1-beta.1-canary-42c64ce-1604313682126":"2020-11-02T10:42:07.033Z","0.1.1-beta.1-canary-981f8b3-1604313888096":"2020-11-02T10:45:38.307Z","0.1.1-beta.1-canary-c238ba0-1604314075192":"2020-11-02T10:48:47.082Z","0.1.1-beta.1-canary-7a18749-1604317639806":"2020-11-02T11:48:10.625Z","0.1.1-beta.1-canary-858fa64-1604321035138":"2020-11-02T12:44:50.425Z","0.1.1-beta.1-canary-5250c51-1604322560399":"2020-11-02T13:10:10.245Z","0.1.1-beta.1-canary-5250c51-1604322562496":"2020-11-02T13:10:30.977Z","0.1.1-beta.1-canary-a1c04d2-1604480736704":"2020-11-04T09:06:26.463Z","0.1.1-beta.1-canary-a1c04d2-1604480739664":"2020-11-04T09:06:45.885Z","0.1.1-beta.1-canary-c0823cf-1604714980569":"2020-11-07T02:10:39.308Z","0.1.1-beta.1-canary-c0823cf-1604714981529":"2020-11-07T02:10:56.819Z","0.1.1-beta.1-canary-d6d4fe7-1604731086994":"2020-11-07T06:39:00.062Z","0.1.1-beta.1-canary-1a49b13-1604731276512":"2020-11-07T06:42:00.480Z","0.1.1-beta.1-canary-c1f8c87-1604843153245":"2020-11-08T13:46:37.393Z","0.1.1-beta.1-canary-c1f8c87-1604843150437":"2020-11-08T13:46:55.582Z","0.1.1-beta.2":"2020-11-08T13:49:29.023Z","0.1.1-beta.2-canary-0f6426d-1604843475214":"2020-11-08T13:51:58.254Z","0.1.1-beta.2-canary-6e6139b-1604843474038":"2020-11-08T13:52:14.051Z","0.1.1-beta.2-canary-9f897d5-1604844864243":"2020-11-08T14:15:26.256Z","1.0.0":"2020-11-08T14:23:13.752Z","1.0.0-canary-3978b38-1604847784718":"2020-11-08T15:03:57.439Z","1.0.0-canary-3978b38-1604847790524":"2020-11-08T15:04:10.445Z","1.0.0-canary-35a4b53-1605363609642":"2020-11-14T14:21:04.709Z","1.0.0-canary-35a4b53-1605363610538":"2020-11-14T18:27:00.753Z","1.0.0-canary-c0fec3f-1605482157044":"2020-11-15T23:16:55.434Z","1.0.0-canary-9aa4f57-1605687850707":"2020-11-18T08:25:09.150Z","1.0.0-canary-9aa4f57-1605687851778":"2020-11-18T08:25:15.053Z","1.0.0-canary-06061cd-1605912872689":"2020-11-20T22:55:21.808Z","1.0.0-canary-6f8acd7-1606086831199":"2020-11-22T23:14:37.727Z","1.0.0-canary-3149ee9-1606630354710":"2020-11-29T06:13:25.046Z","1.0.0-canary-f400b25-1606691727983":"2020-11-29T23:16:22.832Z","1.0.0-canary-b3cc713-1606761918497":"2020-11-30T18:46:15.048Z","1.0.0-canary-a386769-1606808729482":"2020-12-01T07:46:18.889Z","1.0.0-canary-9a000ac-1606808921917":"2020-12-01T07:49:29.897Z","1.0.0-canary-c4cfce4-1606854759294":"2020-12-01T20:33:35.311Z","1.0.0-canary-c4cfce4-1606854771115":"2020-12-01T20:33:46.587Z","1.0.0-canary-89f8f42-1606984144532":"2020-12-03T08:29:57.322Z","1.0.0-canary-89f8f42-1606984144060":"2020-12-03T08:30:02.979Z","1.0.0-canary-9aa153c-1607102838054":"2020-12-04T17:28:19.846Z","1.0.0-canary-9aa153c-1607102840391":"2020-12-04T17:28:27.617Z","1.0.0-canary-9aa153c-1607102869148":"2020-12-04T17:29:27.728Z","1.0.0-canary-3f0a65a-1607112463965":"2020-12-04T20:08:28.848Z","1.0.0-canary-77484ad-1607156245287":"2020-12-05T08:18:09.312Z","1.0.0-canary-77484ad-1607156251673":"2020-12-05T08:18:20.900Z","1.0.0-canary-8013d0a-1607234711158":"2020-12-06T06:06:03.249Z","1.0.0-canary-8013d0a-1607234744329":"2020-12-06T06:06:36.027Z","1.0.0-canary-fd620a1-1607242686255":"2020-12-06T08:18:56.781Z","1.0.0-canary-4b4ae82-1607405501575":"2020-12-08T05:32:28.238Z","1.0.0-canary-bc4cfca-1607421291219":"2020-12-08T09:55:53.058Z","1.0.0-canary-496d087-1607461191397":"2020-12-08T21:00:37.159Z","1.0.0-canary-496d087-1607461191330":"2020-12-08T21:00:49.069Z","1.0.0-canary-6f52564-1607640030795":"2020-12-10T22:41:25.549Z","1.0.0-canary-6f52564-1607640035089":"2020-12-10T22:41:36.048Z","1.0.0-canary-97fc170-1607945148568":"2020-12-14T11:26:31.697Z","1.0.0-canary-97fc170-1607945149539":"2020-12-14T11:26:37.179Z","1.0.0-canary-905f286-1607957930160":"2020-12-14T14:59:35.436Z","1.0.0-canary-bdfdef3-1608328935551":"2020-12-18T22:03:19.397Z","1.0.0-canary-bdfdef3-1608328947246":"2020-12-18T22:03:29.538Z","1.0.0-canary-3cf6f45-1608506047799":"2020-12-20T23:15:00.079Z","1.0.0-canary-6a3dbd0-1608570240923":"2020-12-21T17:04:50.460Z","1.0.0-canary-6a3dbd0-1608570240342":"2020-12-21T17:04:55.828Z","1.0.0-canary-ca2ec15-1608592601058":"2020-12-21T23:17:24.067Z","1.0.0-canary-9d7c67c-1608765293684":"2020-12-23T23:15:41.735Z","1.0.0-canary-c22ce68-1609181445796":"2020-12-28T18:51:27.846Z","1.0.0-canary-c22ce68-1609181449264":"2020-12-28T18:51:39.971Z","1.0.0-canary-4277c88-1609219419948":"2020-12-29T05:24:22.456Z","1.0.0-canary-0e05c60-1609264777995":"2020-12-29T18:00:31.383Z","1.0.0-canary-0e05c60-1609264778879":"2020-12-29T18:00:38.795Z","1.0.0-canary-34f1387-1609272408823":"2020-12-29T20:07:43.610Z","1.0.0-canary-bb2364b-1609286726295":"2020-12-30T00:06:21.887Z","1.0.0-canary-bb2364b-1609286730276":"2020-12-30T00:07:15.841Z","1.0.0-canary-f213f77-1609363135444":"2020-12-30T21:19:46.573Z","1.0.0-canary-f7b8a66-1609465237193":"2021-01-01T01:42:24.621Z","1.0.0-canary-0100fcd-1609492864296":"2021-01-01T09:21:55.300Z","1.0.0-canary-0883853-1609541255340":"2021-01-01T22:49:11.401Z","1.0.0-canary-0363764-1609557107467":"2021-01-02T03:12:35.561Z","1.0.0-canary-0363764-1609557109409":"2021-01-02T03:12:40.459Z","1.0.0-canary-af28370-1609557256034":"2021-01-02T03:15:06.389Z","1.0.0-canary-8b416cb-1609564185832":"2021-01-02T05:10:34.168Z","1.0.0-canary-bbbcfdd-1609638823580":"2021-01-03T01:54:27.383Z","1.0.0-canary-bbbcfdd-1609638823716":"2021-01-03T01:54:33.090Z","1.0.0-canary-aa92248-1609715650286":"2021-01-03T23:16:05.227Z","1.0.0-canary-67a0e3f-1609715773702":"2021-01-03T23:17:04.970Z","1.0.0-canary-c986ed0-1609791552981":"2021-01-04T20:20:34.417Z","1.0.0-canary-89fe5c8-1609802242521":"2021-01-04T23:18:19.128Z","1.0.0-canary-a7dec2b-1609802373061":"2021-01-04T23:20:22.950Z","1.0.0-canary-6c6d256-1609806743713":"2021-01-05T00:33:18.589Z","1.0.0-canary-9305283-1609854149140":"2021-01-05T13:43:16.722Z","1.0.0-canary-dc72271-1609854266237":"2021-01-05T13:45:15.352Z","1.0.0-canary-e942ee3-1609888652343":"2021-01-05T23:18:13.010Z","1.0.0-canary-6889c81-1609888809847":"2021-01-05T23:20:55.900Z","1.0.0-canary-f724266-1609889790834":"2021-01-05T23:37:16.780Z","1.0.0-canary-ff12119-1609910669802":"2021-01-06T05:25:12.830Z","1.0.0-canary-ff12119-1609910671576":"2021-01-06T05:25:19.314Z","1.0.0-canary-1e06a51-1609944005991":"2021-01-06T14:40:59.889Z","1.0.0-canary-c2a2646-1609975263623":"2021-01-06T23:21:58.119Z","1.0.0-canary-17235d7-1610061466343":"2021-01-07T23:18:51.602Z","1.0.0-canary-e5c109d-1610061508520":"2021-01-07T23:19:20.465Z","1.0.0-canary-aa9e786-1610061564488":"2021-01-07T23:20:11.431Z","1.0.0-canary-c59173b-1610061671033":"2021-01-07T23:21:59.168Z","1.0.0-canary-2e2ac88-1610223842439":"2021-01-09T20:24:48.644Z","1.0.0-canary-6baf277-1610320471022":"2021-01-10T23:15:19.092Z","1.0.0-canary-5be35b1-1610320504988":"2021-01-10T23:15:57.827Z","1.0.0-canary-d7a94b9-1610320577158":"2021-01-10T23:17:05.442Z","1.0.0-canary-1772cb9-1610320581307":"2021-01-10T23:17:10.412Z","1.0.0-canary-4ce702b-1610406977151":"2021-01-11T23:17:09.069Z","1.0.0-canary-756f319-1610406991200":"2021-01-11T23:17:16.640Z","1.0.0-canary-e26010b-1610407115198":"2021-01-11T23:19:21.354Z","1.0.0-canary-0578e60-1610445790482":"2021-01-12T10:03:56.598Z","1.0.0-canary-7ffa224-1610446103166":"2021-01-12T10:10:18.058Z","1.0.0-canary-b12bc0c-1610446212065":"2021-01-12T10:10:59.204Z","1.0.0-canary-3bef17e-1610446611431":"2021-01-12T10:17:39.919Z","1.0.0-canary-e654a07-1610446918787":"2021-01-12T10:22:48.366Z","1.0.0-canary-58daf38-1610447029596":"2021-01-12T10:24:36.097Z","1.0.0-canary-ad4ad96-1610447299963":"2021-01-12T10:29:03.416Z","1.0.0-canary-e0b3f53-1610498581480":"2021-01-13T00:43:47.026Z","1.0.0-canary-e0b3f53-1610498582516":"2021-01-13T00:43:58.823Z","1.0.0-canary-2a72046-1610752203602":"2021-01-15T23:10:47.567Z","1.0.0-canary-2a72046-1610752204951":"2021-01-15T23:10:55.907Z","1.0.0-canary-3067210-1610778666890":"2021-01-16T06:31:56.759Z","1.0.0-canary-f92e403-1610820648008":"2021-01-16T18:11:35.013Z","1.0.0-canary-f92e403-1610820648277":"2021-01-16T18:12:18.976Z","1.0.0-canary-abc16c0-1610850970812":"2021-01-17T02:36:57.660Z","1.0.0-canary-abc16c0-1610850978293":"2021-01-17T02:37:08.367Z","1.0.0-canary-b5aeaee-1610925992471":"2021-01-17T23:27:23.406Z","1.0.0-canary-007c5ca-1610926003333":"2021-01-17T23:27:32.899Z","1.0.0-canary-429f445-1610962429004":"2021-01-18T09:34:39.536Z","1.0.0-canary-3caf2b2-1610963526855":"2021-01-18T09:53:00.832Z","1.0.0-canary-a86cc65-1610964044685":"2021-01-18T10:01:28.983Z","1.0.0-canary-d9b243f-1611045870922":"2021-01-19T08:45:22.239Z","1.0.0-canary-d9b243f-1611045873380":"2021-01-19T08:45:53.025Z","1.0.0-canary-6c6b141-1611145527857":"2021-01-20T12:26:13.871Z","1.0.0-canary-6c6b141-1611145532260":"2021-01-20T12:26:23.711Z","1.0.0-canary-2ea8098-1611147839098":"2021-01-20T13:04:44.393Z","1.0.0-canary-a7a4990-1611333154002":"2021-01-22T16:33:28.966Z","1.0.0-canary-a7a4990-1611333153009":"2021-01-22T16:33:34.675Z","1.0.0-canary-1bdfdfe-1611433257912":"2021-01-23T20:21:45.758Z","1.0.0-canary-d0600d1-1611517062925":"2021-01-24T19:38:34.600Z","1.0.0-canary-8954eab-1611530086839":"2021-01-24T23:16:03.849Z","1.0.0-canary-300cc04-1611565391346":"2021-01-25T09:03:58.504Z","1.0.0-canary-147e9ee-1611586330673":"2021-01-25T14:53:03.249Z","1.0.0-canary-147e9ee-1611586337970":"2021-01-25T14:53:21.616Z","1.0.0-canary-49db81b-1611591150110":"2021-01-25T16:13:25.979Z","1.0.0-canary-49db81b-1611591147293":"2021-01-25T16:13:33.915Z","1.0.0-canary-3a8e373-1611616541373":"2021-01-25T23:16:28.973Z","1.0.0-canary-3ae21d5-1611843818150":"2021-01-28T14:24:36.669Z","1.0.0-canary-3ae21d5-1611843821490":"2021-01-28T14:24:42.492Z","1.0.0-canary-9f0b868-1611928476205":"2021-01-29T13:55:27.399Z","1.0.0-canary-9f0b868-1611928478437":"2021-01-29T13:55:33.190Z","1.0.0-canary-4a02239-1611930851108":"2021-01-29T14:35:03.255Z","1.0.0-canary-9a48105-1612069266512":"2021-01-31T05:01:56.640Z","1.0.0-canary-9a48105-1612069270179":"2021-01-31T05:02:03.743Z","1.0.0-canary-5ac5dc3-1612079844964":"2021-01-31T07:58:08.287Z","1.0.0-canary-5ac5dc3-1612079845273":"2021-01-31T07:58:15.473Z","1.0.0-canary-c8b34bd-1612125377174":"2021-01-31T20:37:05.153Z","1.0.0-canary-c8b34bd-1612125375058":"2021-01-31T20:37:15.251Z","1.0.0-canary-15c5be1-1612171126259":"2021-02-01T09:19:45.549Z","1.0.0-canary-72faca4-1612178121674":"2021-02-01T11:16:11.843Z","1.0.0-canary-58a302d-1612221376598":"2021-02-01T23:17:05.744Z","1.0.0-canary-7bd79dc-1612254583379":"2021-02-02T08:30:31.860Z","1.0.0-canary-0caef8f-1612271125996":"2021-02-02T13:06:16.438Z","1.0.0-canary-15f8d3b-1612281582369":"2021-02-02T16:00:40.187Z","1.0.0-canary-92374fa-1612514189682":"2021-02-05T08:37:24.299Z","1.0.0-canary-1313a5d-1612531250097":"2021-02-05T13:21:38.237Z","1.0.0-canary-a3b401a-1612548394970":"2021-02-05T18:07:25.606Z","1.0.0-canary-a3b401a-1612548395102":"2021-02-05T18:07:35.733Z","1.0.0-canary-f427017-1612628821731":"2021-02-06T16:27:50.607Z","1.0.0-canary-f427017-1612628824209":"2021-02-06T16:27:56.759Z","1.0.0-canary-56ed5bd-1612652117025":"2021-02-06T22:56:09.022Z","1.0.0-canary-56ed5bd-1612652117783":"2021-02-06T22:57:01.617Z","1.0.0-canary-67c63f9-1612739860467":"2021-02-07T23:18:32.329Z","1.0.0-canary-0dc4175-1612775142842":"2021-02-08T09:06:42.481Z","1.0.0-canary-10abdd0-1612873602913":"2021-02-09T12:27:33.053Z","1.0.0-canary-10abdd0-1612873602980":"2021-02-09T12:27:39.986Z","1.0.0-canary-4ac427f-1612897579191":"2021-02-09T19:07:14.606Z","1.0.0-canary-dfbda9e-1612912591368":"2021-02-09T23:17:33.750Z","1.0.0-canary-dc2c177-1612990668784":"2021-02-10T20:58:36.363Z","1.0.0-canary-ea3a500-1612998945824":"2021-02-10T23:16:33.336Z","1.0.0-canary-07b6c65-1613014639213":"2021-02-11T03:38:11.899Z","1.0.0-canary-6ac1ae3-1613057570212":"2021-02-11T15:33:41.233Z","1.0.0-canary-af3cb0e-1613146050211":"2021-02-12T16:08:27.701Z","1.0.0-canary-fe416f5-1613169986329":"2021-02-12T22:47:17.983Z","1.0.0-canary-34d7388-1613344475382":"2021-02-14T23:15:37.727Z","1.0.0-canary-1597986-1613361013069":"2021-02-15T03:51:05.956Z","1.0.0-canary-793c4ae-1613378779278":"2021-02-15T08:47:12.188Z","1.0.0-canary-22dc271-1613385657345":"2021-02-15T10:41:47.759Z","1.0.0-canary-3f9f1ac-1613391751158":"2021-02-15T12:23:19.971Z","1.0.0-canary-892730b-1613395699386":"2021-02-15T13:29:16.520Z","1.0.0-canary-04adfd7-1613666330276":"2021-02-18T16:39:46.526Z","1.0.0-canary-04adfd7-1613666329426":"2021-02-18T16:39:51.953Z","1.0.0-canary-481c081-1613791337573":"2021-02-20T03:23:08.137Z","1.0.0-canary-0fd1a82-1613865686127":"2021-02-21T00:02:17.445Z","1.0.0-canary-0fd1a82-1613865690349":"2021-02-21T00:03:20.039Z","1.0.0-canary-e829452-1613984333023":"2021-02-22T08:59:48.084Z","1.0.0-canary-d70dd1d-1614001736375":"2021-02-22T13:49:47.535Z","1.0.0-canary-f10fd64-1614002829344":"2021-02-22T14:07:54.219Z","1.0.0-canary-f10fd64-1614002828692":"2021-02-22T14:25:20.033Z","1.0.0-canary-a2f8ee4-1614013287719":"2021-02-22T17:02:15.075Z","1.0.0-canary-a2f8ee4-1614013292912":"2021-02-22T17:02:21.064Z","1.0.0-canary-3683e69-1614013500069":"2021-02-22T17:05:45.616Z","1.0.0-canary-3683e69-1614014087501":"2021-02-22T17:15:37.856Z","1.0.0-canary-0b9ef8f-1614014140520":"2021-02-22T17:16:35.161Z","1.0.0-canary-43621e5-1614014751171":"2021-02-22T17:26:47.896Z","1.1.0":"2021-02-22T17:29:30.130Z","1.1.0-canary-2740533-1614045905592":"2021-02-23T02:05:50.372Z","1.1.0-canary-2740533-1614045907300":"2021-02-23T02:05:58.459Z","1.1.0-canary-7bcef51-1614074761405":"2021-02-23T10:06:51.182Z","1.1.0-canary-7ffecdc-1614074763892":"2021-02-23T10:07:04.792Z","1.1.0-canary-0390e68-1614116860862":"2021-02-23T21:48:33.939Z","1.1.0-canary-6977b0b-1614118741073":"2021-02-23T22:19:49.718Z","1.1.0-canary-6977b0b-1614118741398":"2021-02-23T22:20:20.515Z","1.1.0-canary-93e17ab-1614184334069":"2021-02-24T16:33:09.775Z","1.1.0-canary-805d793-1614350770600":"2021-02-26T14:47:48.107Z","1.1.0-canary-b3aae1a-1614355844238":"2021-02-26T16:11:34.203Z","1.1.0-canary-33cc796-1614464185504":"2021-02-27T22:17:06.792Z","1.1.0-canary-33cc796-1614464187876":"2021-02-27T22:17:19.546Z","1.1.0-canary-14e8f67-1614554896619":"2021-02-28T23:28:59.943Z","1.1.0-canary-85a0b17-1614589310125":"2021-03-01T09:02:42.594Z","1.1.0-canary-f117734-1614835254541":"2021-03-04T05:21:42.137Z","1.1.0-canary-c8f0e70-1614847047294":"2021-03-04T08:38:30.526Z","1.1.0-canary-c8f0e70-1614847061112":"2021-03-04T08:38:35.993Z","1.1.0-canary-201b354-1614851177942":"2021-03-04T09:47:13.551Z","1.1.0-canary-ea5353a-1614897657437":"2021-03-04T22:41:53.264Z","1.1.0-canary-ea5353a-1614897655805":"2021-03-04T22:42:13.150Z","1.1.0-canary-fa2aa79-1614899903195":"2021-03-04T23:19:12.682Z","1.1.0-canary-04c11a8-1615048039370":"2021-03-06T16:28:14.602Z","1.1.0-canary-1ecd0ae-1615193548552":"2021-03-08T08:53:20.978Z","1.1.0-canary-61c4e8c-1615280261314":"2021-03-09T08:58:31.763Z","1.1.0-canary-15b5e29-1615301036537":"2021-03-09T14:44:53.959Z","1.1.0-canary-c259800-1615440561562":"2021-03-11T05:30:11.914Z","1.1.0-canary-ba4ea6d-1615458999549":"2021-03-11T10:37:25.188Z","1.1.0-canary-a7c9ffd-1615559986817":"2021-03-12T14:41:01.632Z","1.1.0-canary-11fa3e4-1615586002791":"2021-03-12T21:54:10.803Z","1.1.0-canary-f40eae5-1615693924634":"2021-03-14T03:52:57.143Z","1.1.0-canary-f40eae5-1615693922466":"2021-03-14T03:53:03.859Z","1.1.0-canary-8902d06-1615752257802":"2021-03-14T20:05:02.259Z","1.1.0-canary-8902d06-1615752259264":"2021-03-14T20:05:14.715Z","1.1.0-canary-3bf22cc-1615799778810":"2021-03-15T09:17:22.673Z","1.1.0-canary-3d25e74-1615800420662":"2021-03-15T09:28:00.061Z","1.1.0-canary-850afe2-1615800819347":"2021-03-15T09:34:45.641Z","1.1.0-canary-44ff3c4-1615886606779":"2021-03-16T09:24:13.373Z","1.1.0-canary-37462ef-1615905110470":"2021-03-16T14:32:50.979Z","1.1.0-canary-62a30c6-1615906787265":"2021-03-16T15:00:47.881Z","1.1.0-canary-7e1168e-1615987984527":"2021-03-17T13:34:10.266Z","1.1.0-canary-44b1dd3-1615997027853":"2021-03-17T16:04:39.994Z","1.1.0-canary-adcea0c-1616045280313":"2021-03-18T05:28:45.420Z","1.1.0-canary-adcea0c-1616045280440":"2021-03-18T05:28:53.283Z","1.1.0-canary-d4f6973-1616060337259":"2021-03-18T09:39:47.976Z","1.1.0-canary-79fc8ba-1616060591727":"2021-03-18T09:43:56.724Z","1.1.0-canary-a17cbf7-1616063819474":"2021-03-18T10:37:45.538Z","1.1.0-canary-35f3055-1616142590162":"2021-03-19T08:30:42.548Z","1.1.0-canary-35f3055-1616142592265":"2021-03-19T08:30:48.870Z","1.1.0-canary-213eb91-1616220408100":"2021-03-20T06:07:53.233Z","1.1.0-canary-9b02e0c-1616369055186":"2021-03-21T23:24:58.937Z","1.1.0-canary-51c498a-1616376513816":"2021-03-22T01:29:30.320Z","1.1.0-canary-67107c8-1616393890006":"2021-03-22T06:18:56.696Z","1.1.0-canary-025b1cc-1616404000766":"2021-03-22T09:07:29.061Z","1.1.0-canary-1371bcd-1616404620931":"2021-03-22T09:17:49.179Z","1.1.0-canary-daba473-1616424952009":"2021-03-22T14:57:10.783Z","1.1.0-canary-daba473-1616424965023":"2021-03-22T14:57:41.598Z","1.1.0-canary-f983f08-1616428389669":"2021-03-22T15:54:03.377Z","1.1.0-canary-c396e0f-1616596807997":"2021-03-24T14:41:06.426Z","1.1.0-canary-c396e0f-1616596808736":"2021-03-24T14:42:00.279Z","1.1.0-canary-8886b91-1616627765270":"2021-03-24T23:16:52.666Z","1.1.0-canary-105d16f-1616643397076":"2021-03-25T03:37:44.919Z","1.1.0-canary-751c1a4-1616663077877":"2021-03-25T09:05:27.070Z","1.1.0-canary-53d6f16-1616663267891":"2021-03-25T09:08:46.926Z","1.1.0-canary-ee2093c-1616695686050":"2021-03-25T18:08:54.853Z","1.1.0-canary-ee2093c-1616695687737":"2021-03-25T18:09:02.537Z","1.1.0-canary-73eb2f3-1616784610082":"2021-03-26T18:51:09.062Z","1.1.0-canary-73eb2f3-1616784608414":"2021-03-26T18:51:18.919Z","1.1.0-canary-9be62ac-1616793443691":"2021-03-26T21:18:20.429Z","1.1.0-canary-9be62ac-1616793453518":"2021-03-26T21:18:29.719Z","1.1.0-canary-d1938e2-1616823812069":"2021-03-27T05:44:27.064Z","1.1.0-canary-269053b-1616912548399":"2021-03-28T06:23:21.105Z","1.1.0-canary-269053b-1616912553695":"2021-03-28T06:23:28.369Z","1.1.0-canary-22ed9a6-1617008363456":"2021-03-29T09:00:05.038Z","1.1.0-canary-9044414-1617031376057":"2021-03-29T15:24:00.908Z","1.1.0-canary-74d58f6-1617105479651":"2021-03-30T11:58:44.943Z","1.1.0-canary-c81152d-1617480993069":"2021-04-03T20:17:25.805Z","1.1.0-canary-0453292-1617578067624":"2021-04-04T23:15:29.033Z","1.1.0-canary-0d0056b-1617647144564":"2021-04-05T18:26:35.502Z","1.1.0-canary-720b4ac-1617694405399":"2021-04-06T07:34:14.252Z","1.1.0-canary-a8c599f-1617697953962":"2021-04-06T08:33:28.203Z","1.1.0-canary-4a974aa-1617821842815":"2021-04-07T18:58:21.496Z","1.1.0-canary-4a974aa-1617821842264":"2021-04-07T18:58:29.499Z","1.1.0-canary-04a6624-1617833675244":"2021-04-07T22:15:52.270Z","1.1.0-canary-52ab90e-1617946100671":"2021-04-09T05:29:02.967Z","1.1.0-canary-52ab90e-1617946100231":"2021-04-09T05:29:22.262Z","1.1.0-canary-b9190f1-1618006542651":"2021-04-09T22:16:29.327Z","1.1.0-canary-15c73d5-1618031944727":"2021-04-10T05:20:06.101Z","1.1.0-canary-15c73d5-1618031944755":"2021-04-10T05:23:45.046Z","1.1.0-canary-cdd329e-1618179831547":"2021-04-11T22:24:42.176Z","1.1.0-canary-e745550-1618265732891":"2021-04-12T22:16:27.450Z","1.1.0-canary-5fcff19-1618291962592":"2021-04-13T05:33:30.386Z","1.1.0-canary-5fcff19-1618291961213":"2021-04-13T05:33:42.527Z","1.1.0-canary-2244745-1618352161584":"2021-04-13T22:17:22.403Z","1.1.0-canary-8b6a3c9-1618438570775":"2021-04-14T22:16:54.502Z","1.1.0-canary-43e64cd-1618524862711":"2021-04-15T22:15:07.970Z","1.1.0-canary-f44badc-1618784025354":"2021-04-18T22:14:38.907Z","1.1.0-canary-8e37ddd-1619122888360":"2021-04-22T20:22:15.728Z","1.1.0-canary-f69cb96-1619129641478":"2021-04-22T22:15:06.000Z","1.1.0-canary-bb9f2a8-1619146228005":"2021-04-23T02:51:11.630Z","1.1.0-canary-bb9f2a8-1619146233977":"2021-04-23T02:51:34.147Z","1.1.0-canary-1d54d8f-1619164071224":"2021-04-23T07:48:39.635Z","1.1.0-canary-62023b8-1619218135049":"2021-04-23T22:49:42.858Z","1.1.0-canary-9c02e36-1619392987083":"2021-04-25T23:23:53.049Z","1.1.0-canary-dac043b-1619552677205":"2021-04-27T19:45:30.382Z","1.1.0-canary-dac043b-1619552675331":"2021-04-27T19:45:39.023Z","1.1.0-canary-6e93133-1619674769250":"2021-04-29T05:40:25.807Z","1.1.0-canary-44a7887-1619683171224":"2021-04-29T08:00:26.380Z","1.1.0-canary-542a692-1620106044529":"2021-05-04T05:28:08.112Z","1.1.0-canary-542a692-1620106048019":"2021-05-04T05:28:15.927Z","1.1.0-canary-bea75f5-1620137385745":"2021-05-04T14:11:09.299Z","1.1.0-canary-bea75f5-1620137385828":"2021-05-04T14:11:41.306Z","1.1.0-canary-9e3d2d3-1620166550486":"2021-05-04T22:16:38.768Z","1.1.0-canary-739172b-1620252842400":"2021-05-05T22:14:50.736Z","1.1.0-canary-d9588bf-1620396375462":"2021-05-07T14:07:22.697Z","1.1.0-canary-11a2d7c-1620399290226":"2021-05-07T14:55:48.428Z","1.1.0-canary-1d872da-1620442292227":"2021-05-08T02:52:21.292Z","1.1.0-canary-91f2951-1620599066954":"2021-05-09T22:25:23.843Z","1.1.0-canary-1a9ef9a-1621054540158":"2021-05-15T04:56:47.488Z","1.1.0-canary-6ceae53-1621206639549":"2021-05-16T23:11:31.223Z","1.1.0-canary-b8ca634-1621454103168":"2021-05-19T19:56:04.269Z","1.1.0-canary-b8ca634-1621454104949":"2021-05-19T19:56:14.413Z","1.1.0-canary-15aae89-1621462509245":"2021-05-19T22:15:53.904Z","1.1.0-canary-41332ae-1621647037855":"2021-05-22T01:31:26.315Z","1.1.0-canary-41332ae-1621647037269":"2021-05-22T01:31:35.880Z","1.1.0-canary-4e797d6-1621747453538":"2021-05-23T05:25:04.592Z","1.1.0-canary-230590b-1621812251395":"2021-05-23T23:25:08.930Z","1.1.0-canary-8bff5d7-1621812284309":"2021-05-23T23:25:33.062Z","1.1.0-canary-6b47da6-1621847774214":"2021-05-24T09:16:57.641Z","1.1.0-canary-706e2bb-1621933802760":"2021-05-25T09:10:53.006Z","1.1.0-canary-09f7513-1621934485417":"2021-05-25T09:22:12.395Z","1.1.0-canary-623b193-1621938473734":"2021-05-25T10:28:33.585Z","1.1.0-canary-fdd2ddd-1621940616250":"2021-05-25T11:04:39.393Z","1.1.0-canary-6da7e94-1622017589981":"2021-05-26T08:27:19.101Z","1.1.0-canary-a9aa0b4-1622031121648":"2021-05-26T12:12:46.468Z","1.1.0-canary-6dcf744-1622050575653":"2021-05-26T17:37:11.271Z","1.1.0-canary-6dcf744-1622050579042":"2021-05-26T17:37:26.808Z","1.1.0-canary-303cb2d-1622108078656":"2021-05-27T09:35:42.308Z","1.1.0-canary-303cb2d-1622108080010":"2021-05-27T09:36:00.326Z","1.1.0-canary-5c726ff-1622114876095":"2021-05-27T11:28:41.618Z","1.1.0-canary-bcf2d00-1622194813454":"2021-05-28T09:41:18.315Z","1.1.0-canary-bcf2d00-1622194813217":"2021-05-28T09:42:16.136Z","1.1.0-canary-08d7c87-1622203140498":"2021-05-28T11:59:45.516Z","1.1.0-canary-0744e13-1622207966846":"2021-05-28T13:20:16.648Z","1.1.0-canary-b6301ee-1622263942276":"2021-05-29T04:53:20.429Z","1.1.0-canary-509db69-1622292626104":"2021-05-29T12:51:03.511Z","1.1.0-canary-509db69-1622292625339":"2021-05-29T12:51:12.724Z","1.1.0-canary-1593446-1622312698390":"2021-05-29T18:25:55.810Z","1.1.0-canary-1593446-1622312698242":"2021-05-29T18:26:01.689Z","1.1.0-canary-78fd972-1622401311660":"2021-05-30T19:02:42.564Z","1.1.0-canary-78fd972-1622401312782":"2021-05-30T19:02:50.161Z","1.1.0-canary-395eec6-1622414493520":"2021-05-30T22:42:21.872Z","1.1.0-canary-3c5f93a-1622469711030":"2021-05-31T14:02:35.789Z","1.1.0-canary-3c5f93a-1622469714797":"2021-05-31T14:02:45.852Z","1.1.0-canary-3c5f93a-1622469718313":"2021-05-31T14:06:14.680Z","1.1.1":"2021-05-31T14:10:12.671Z","1.1.1-canary-907357a-1622475026346":"2021-05-31T15:31:15.103Z","1.1.1-canary-79c9348-1622475046540":"2021-05-31T15:31:40.351Z","1.1.1-canary-c6ed13b-1622499842501":"2021-05-31T22:24:47.194Z","1.1.1-canary-c6ed13b-1622499845898":"2021-05-31T22:24:55.332Z","1.1.1-canary-9479aff-1622538531622":"2021-06-01T09:09:34.638Z","1.1.1-canary-e6cc5bb-1622552057967":"2021-06-01T12:54:59.425Z","1.1.1-canary-dd97712-1622772171605":"2021-06-04T02:03:48.642Z","1.1.1-canary-dd97712-1622772177338":"2021-06-04T02:04:01.955Z","1.1.1-canary-fd48f71-1622793465046":"2021-06-04T07:58:34.300Z","1.1.1-canary-fd48f71-1622793465741":"2021-06-04T07:58:40.997Z","1.1.1-canary-be8acdc-1622793773548":"2021-06-04T08:03:41.527Z","1.1.1-canary-be8acdc-1622793779431":"2021-06-04T08:03:50.038Z","1.1.1-canary-1ef0af5-1622793963125":"2021-06-04T08:06:51.854Z","1.1.1-canary-14c1474-1623031358527":"2021-06-07T02:03:54.448Z","1.1.1-canary-14c1474-1623031359389":"2021-06-07T02:04:03.701Z","1.1.1-canary-14c1474-1623031417445":"2021-06-07T02:04:45.543Z","1.1.1-canary-14c1474-1623031419128":"2021-06-07T02:05:21.730Z","1.1.1-canary-15a216a-1623055378004":"2021-06-07T08:43:45.905Z","1.1.1-canary-15a216a-1623055409393":"2021-06-07T08:44:15.736Z","1.1.1-canary-15a216a-1623055661003":"2021-06-07T08:48:32.291Z","1.1.1-canary-f70971b-1623055791409":"2021-06-07T08:50:56.134Z","1.1.1-canary-f70971b-1623055811615":"2021-06-07T08:51:05.728Z","1.1.1-canary-f06a303-1623056816246":"2021-06-07T09:08:02.152Z","1.1.1-canary-f06a303-1623056781475":"2021-06-07T09:08:13.400Z","1.1.1-canary-f06a303-1623056871428":"2021-06-07T09:08:46.169Z","1.1.1-canary-302413a-1623056956232":"2021-06-07T09:10:20.325Z","1.1.1-canary-cfb3e0c-1623059323124":"2021-06-07T09:49:34.408Z","1.1.1-canary-cfb3e0c-1623059345291":"2021-06-07T09:49:55.399Z","1.1.1-canary-ed4509f-1623067811606":"2021-06-07T12:10:57.283Z","1.1.1-canary-de34657-1623070086232":"2021-06-07T12:48:54.308Z","1.1.1-canary-41b11c5-1623204125265":"2021-06-09T02:02:54.707Z","1.1.1-canary-db0d632-1623636161589":"2021-06-14T02:03:37.086Z","1.1.1-canary-db0d632-1623636151826":"2021-06-14T02:03:53.143Z","1.1.1-canary-10353c3-1623661440472":"2021-06-14T09:04:58.521Z","1.1.1-canary-3bc6e5c-1623664277221":"2021-06-14T09:52:18.203Z","1.1.1-canary-3bc6e5c-1623664284021":"2021-06-14T09:52:26.501Z","1.1.1-canary-3bc6e5c-1623664308588":"2021-06-14T09:52:51.117Z","1.1.1-canary-3631be7-1623668120673":"2021-06-14T10:56:11.551Z","1.1.1-canary-5f4ebd3-1623686644087":"2021-06-14T16:04:57.897Z","1.1.1-canary-26896f2-1623687595587":"2021-06-14T16:20:43.275Z","1.1.1-canary-ef86f58-1623895413866":"2021-06-17T02:04:44.530Z","1.1.1-canary-ef86f58-1623895388474":"2021-06-17T02:04:58.841Z","1.1.1-canary-ef86f58-1623895476507":"2021-06-17T02:05:26.029Z","1.1.1-canary-ef86f58-1623895479196":"2021-06-17T02:05:37.540Z","1.1.1-canary-6ba0e3f-1623917619543":"2021-06-17T08:15:28.050Z","1.1.1-canary-6ba0e3f-1623917645004":"2021-06-17T08:15:39.190Z","1.1.1-canary-e7a5de4-1623917845252":"2021-06-17T08:18:28.593Z","1.1.1-canary-e7a5de4-1623917857399":"2021-06-17T08:18:37.432Z","1.1.1-canary-e7a5de4-1623917865117":"2021-06-17T08:18:43.310Z","1.1.1-canary-5d3f62d-1623918007319":"2021-06-17T08:21:12.460Z","1.1.1-canary-eb24f2e-1623918039519":"2021-06-17T08:21:40.384Z","1.1.1-canary-eb24f2e-1623918066671":"2021-06-17T08:22:13.098Z","1.1.1-canary-eb24f2e-1623918083142":"2021-06-17T08:22:31.408Z","1.1.1-canary-4c08875-1623918546264":"2021-06-17T08:29:55.500Z","1.1.1-canary-f1361db-1623919076612":"2021-06-17T08:38:53.701Z","1.1.1-canary-f7ec6d9-1623919731522":"2021-06-17T08:49:37.781Z","1.1.1-canary-3552985-1623981724835":"2021-06-18T02:02:56.055Z","1.1.1-canary-9a2b0af-1624002503855":"2021-06-18T07:49:30.819Z","1.1.1-canary-d18ee20-1624003245952":"2021-06-18T08:01:34.392Z","1.1.1-canary-d18ee20-1624003274563":"2021-06-18T08:02:01.373Z","1.1.1-canary-b6b0a89-1624240940941":"2021-06-21T02:03:23.291Z","1.1.1-canary-b6b0a89-1624240943941":"2021-06-21T02:03:35.991Z","1.1.1-canary-5c0017d-1624262553577":"2021-06-21T08:03:33.884Z","1.1.1-canary-5c0017d-1624262575598":"2021-06-21T08:03:47.347Z","1.1.1-canary-6721d52-1624262725615":"2021-06-21T08:06:09.973Z","1.1.1-canary-2cb6b9b-1624262974309":"2021-06-21T08:10:19.706Z","1.1.1-canary-31aa68f-1624263448597":"2021-06-21T08:18:16.910Z","1.1.1-canary-113bfa0-1624327300399":"2021-06-22T02:02:27.707Z","1.1.1-canary-33a4c11-1624358694155":"2021-06-22T10:45:42.538Z","1.1.1-canary-33a4c11-1624358730494":"2021-06-22T10:46:19.151Z","1.1.1-canary-8f98b03-1624413719138":"2021-06-23T02:02:46.061Z","1.1.1-canary-28f2a43-1624845714378":"2021-06-28T02:03:25.743Z","1.1.1-canary-f0af1ee-1624880367591":"2021-06-28T11:40:21.272Z","1.1.1-canary-4ff2d41-1624880709792":"2021-06-28T11:45:58.940Z","1.1.1-canary-1a55803-1624881712791":"2021-06-28T12:02:41.025Z","1.1.1-canary-c71afe9-1624882110424":"2021-06-28T12:09:52.199Z","1.1.1-canary-23c429c-1624884007352":"2021-06-28T12:40:53.469Z","1.1.1-canary-29c10de-1624884270175":"2021-06-28T12:45:21.633Z","1.1.1-canary-29c10de-1624884299465":"2021-06-28T12:45:41.259Z","1.1.1-canary-026e962-1624932103016":"2021-06-29T02:02:34.649Z","1.1.1-canary-a0c26e0-1625104984196":"2021-07-01T02:04:02.981Z","1.1.1-canary-a0c26e0-1625104956732":"2021-07-01T02:04:10.854Z","1.1.1-canary-a0c26e0-1625104982062":"2021-07-01T02:04:20.352Z","1.1.1-canary-7798cf7-1625130697854":"2021-07-01T09:12:40.140Z","1.1.1-canary-7798cf7-1625130670385":"2021-07-01T09:12:57.566Z","1.1.1-canary-c87127a-1625131293699":"2021-07-01T09:22:21.193Z","1.1.1-canary-c87127a-1625131299564":"2021-07-01T09:22:37.840Z","1.1.1-canary-deb426b-1625145920232":"2021-07-01T13:26:11.923Z","1.1.1-canary-f609f25-1625153818777":"2021-07-01T15:37:48.246Z","1.1.1-canary-64bebd5-1625154280714":"2021-07-01T15:45:28.436Z","1.1.1-canary-1120031-1625450528281":"2021-07-05T02:03:08.034Z","1.1.1-canary-714cae9-1625471947816":"2021-07-05T08:00:10.161Z","1.1.1-canary-9baaf07-1625472423356":"2021-07-05T08:08:03.101Z","1.1.1-canary-57dab38-1625472807345":"2021-07-05T08:14:20.479Z","1.1.1-canary-dc8fb96-1625623309137":"2021-07-07T02:02:37.044Z","1.1.1-canary-e77fddd-1625709744467":"2021-07-08T02:03:14.797Z","1.1.1-canary-ba8a7bc-1625735914322":"2021-07-08T09:19:21.356Z","1.1.1-canary-fe80256-1625736427078":"2021-07-08T09:27:47.570Z","1.1.1-canary-c1c3e4a-1626055334250":"2021-07-12T02:03:49.857Z","1.1.1-canary-c1c3e4a-1626055334303":"2021-07-12T02:03:56.690Z","1.1.1-canary-81a1526-1626082525383":"2021-07-12T09:36:14.953Z","1.1.1-canary-4bf046d-1626082692818":"2021-07-12T09:39:13.768Z","1.1.1-canary-915464f-1626400960994":"2021-07-16T02:03:47.919Z","1.1.1-canary-cacbfe4-1626424806706":"2021-07-16T08:41:01.989Z","1.1.1-canary-ab4e76d-1626435190296":"2021-07-16T11:33:59.191Z","1.1.1-canary-0868351-1626435344673":"2021-07-16T11:37:09.099Z","1.1.1-canary-6977596-1626660563558":"2021-07-19T02:10:10.379Z","1.1.1-canary-6977596-1626660566315":"2021-07-19T02:10:17.530Z","1.1.1-canary-8c247e4-1626919318505":"2021-07-22T02:02:55.179Z","1.1.1-canary-8c247e4-1626919337079":"2021-07-22T02:03:11.380Z","1.1.1-canary-8c247e4-1626919343331":"2021-07-22T02:03:18.618Z","1.1.1-canary-8c247e4-1626919318122":"2021-07-22T02:03:45.353Z","1.1.1-canary-f46f94b-1626941035998":"2021-07-22T08:04:46.545Z","1.1.1-canary-9a9224c-1626941899477":"2021-07-22T08:19:08.232Z","1.1.1-canary-7142b3e-1626942114395":"2021-07-22T08:22:56.064Z","1.1.1-canary-39a7cc7-1627264911976":"2021-07-26T02:02:53.715Z","1.1.1-canary-c54119f-1627287692208":"2021-07-26T08:22:33.149Z","1.1.1-canary-c54119f-1627287723865":"2021-07-26T08:22:53.330Z","1.1.1-canary-c1f0c3c-1627292766135":"2021-07-26T09:48:04.701Z","1.1.1-canary-38417c7-1627351337514":"2021-07-27T02:03:04.694Z","1.1.1-canary-38417c7-1627351342201":"2021-07-27T02:03:10.190Z","1.1.1-canary-479d536-1627371654622":"2021-07-27T07:41:40.983Z","1.1.1-canary-8d8264a-1627524132243":"2021-07-29T02:03:02.102Z","1.1.1-canary-8d8264a-1627524131846":"2021-07-29T02:03:09.387Z","1.1.1-canary-afa0236-1627547982076":"2021-07-29T08:40:56.564Z","1.1.1-canary-2f8e72e-1627548240189":"2021-07-29T08:44:52.800Z","1.1.1-canary-4c7308e-1627610527028":"2021-07-30T02:02:58.046Z","1.1.1-canary-4c7308e-1627610523533":"2021-07-30T02:03:06.220Z","1.1.1-canary-d67a93d-1627869757476":"2021-08-02T02:03:45.930Z","1.1.1-canary-d67a93d-1627869730106":"2021-08-02T02:04:04.254Z","1.1.1-canary-d67a93d-1627869826566":"2021-08-02T02:05:03.860Z","1.1.1-canary-d67a93d-1627869826934":"2021-08-02T02:06:02.803Z","1.1.1-canary-d67a93d-1628215327314":"2021-08-06T02:02:55.657Z","1.1.1-canary-d67a93d-1628215329590":"2021-08-06T02:03:02.034Z","1.1.1-canary-d67a93d-1628474537235":"2021-08-09T02:03:03.718Z","1.1.1-canary-d67a93d-1628474541305":"2021-08-09T02:03:09.429Z","1.1.1-canary-d67a93d-1628647374373":"2021-08-11T02:03:44.579Z","1.1.1-canary-d67a93d-1628647413068":"2021-08-11T02:04:13.766Z","1.1.1-canary-d67a93d-1628647416742":"2021-08-11T02:04:32.379Z","1.1.1-canary-d67a93d-1628820146193":"2021-08-13T02:03:06.825Z","1.1.1-canary-d67a93d-1628820146865":"2021-08-13T02:03:15.207Z","1.1.1-canary-d67a93d-1629424923507":"2021-08-20T02:02:46.251Z","1.1.1-canary-d67a93d-1629424924912":"2021-08-20T02:02:54.885Z","1.1.1-canary-d67a93d-1629770527825":"2021-08-24T02:03:00.242Z","1.1.1-canary-d67a93d-1630288989697":"2021-08-30T02:03:59.018Z","1.1.1-canary-d67a93d-1630288992072":"2021-08-30T02:04:13.062Z","1.1.1-canary-d67a93d-1631498536717":"2021-09-13T02:03:19.193Z","1.1.1-canary-d67a93d-1632103335995":"2021-09-20T02:03:12.102Z","1.1.1-canary-d67a93d-1632103335135":"2021-09-20T02:03:53.033Z","1.1.1-canary-d67a93d-1632276138702":"2021-09-22T02:03:17.386Z","1.1.1-canary-d67a93d-1632276172025":"2021-09-22T02:03:41.745Z","1.1.1-canary-d67a93d-1632362590782":"2021-09-23T02:04:07.437Z","1.1.1-canary-d67a93d-1633313096064":"2021-10-04T02:05:45.923Z","1.1.1-canary-d67a93d-1633313104910":"2021-10-04T02:06:03.201Z","1.1.1-canary-d67a93d-1633313167122":"2021-10-04T02:06:59.862Z","1.1.1-canary-d67a93d-1633313170273":"2021-10-04T02:07:21.318Z","1.1.1-canary-d67a93d-1633313237681":"2021-10-04T02:08:17.773Z","1.1.1-canary-d67a93d-1633313238263":"2021-10-04T02:08:31.079Z","1.1.1-canary-d67a93d-1633917874410":"2021-10-11T02:05:28.515Z","1.1.1-canary-d67a93d-1634263414706":"2021-10-15T02:04:22.576Z","1.1.1-canary-d67a93d-1634263416385":"2021-10-15T02:05:26.356Z","1.1.1-canary-d67a93d-1634522576598":"2021-10-18T02:03:39.246Z","1.1.1-canary-d67a93d-1634522578034":"2021-10-18T02:03:52.424Z","1.1.1-canary-d67a93d-1634695385552":"2021-10-20T02:03:52.290Z","1.1.1-canary-d67a93d-1634695384739":"2021-10-20T02:03:58.111Z","1.1.1-canary-d67a93d-1635127387563":"2021-10-25T02:05:02.184Z","1.1.1-canary-d67a93d-1635127385784":"2021-10-25T02:05:06.259Z","1.1.1-canary-d67a93d-1635127483466":"2021-10-25T02:05:39.199Z","1.1.1-canary-d67a93d-1635213793221":"2021-10-26T02:04:01.528Z","1.1.1-canary-d67a93d-1635213795404":"2021-10-26T02:04:11.362Z","1.1.1-canary-d67a93d-1635818555400":"2021-11-02T02:03:23.610Z","1.1.1-canary-d67a93d-1635818556855":"2021-11-02T02:03:30.956Z","1.1.1-canary-d67a93d-1636337047359":"2021-11-08T02:04:54.252Z","1.1.1-canary-d67a93d-1636337051787":"2021-11-08T02:05:05.537Z","1.1.1-canary-d67a93d-1636337035586":"2021-11-08T02:05:16.891Z","1.1.1-canary-d67a93d-1636337035855":"2021-11-08T02:05:28.122Z","1.1.1-canary-d67a93d-1636941742097":"2021-11-15T02:03:13.907Z","1.1.1-canary-d67a93d-1636941741885":"2021-11-15T02:04:12.497Z","1.1.1-canary-d67a93d-1636941809282":"2021-11-15T02:04:17.524Z","1.1.1-canary-d67a93d-1637287414464":"2021-11-19T02:04:21.832Z","1.1.1-canary-d67a93d-1637546665205":"2021-11-22T02:05:10.690Z","1.1.1-canary-d67a93d-1637546673364":"2021-11-22T02:05:19.489Z","1.1.1-canary-d67a93d-1637633030112":"2021-11-23T02:04:33.022Z","1.1.1-canary-d67a93d-1637633032745":"2021-11-23T02:04:40.207Z","1.1.1-canary-d67a93d-1637805758499":"2021-11-25T02:03:26.263Z","1.1.1-canary-d67a93d-1638324177439":"2021-12-01T02:03:45.640Z","1.1.1-canary-d67a93d-1638324179129":"2021-12-01T02:04:02.326Z","1.1.1-canary-d67a93d-1638756272033":"2021-12-06T02:05:13.815Z","1.1.1-canary-d67a93d-1638756271849":"2021-12-06T02:05:21.400Z","1.1.1-canary-d67a93d-1638842660136":"2021-12-07T02:05:09.490Z","1.1.1-canary-d67a93d-1639101819806":"2021-12-10T02:04:34.423Z","1.1.1-canary-d67a93d-1639360978527":"2021-12-13T02:03:51.924Z","1.1.1-canary-d67a93d-1639965825466":"2021-12-20T02:05:29.285Z","1.1.1-canary-d67a93d-1640570609151":"2021-12-27T02:04:22.495Z","1.1.1-canary-d67a93d-1640570950160":"2021-12-27T02:10:06.424Z","1.1.1-canary-d67a93d-1640916126359":"2021-12-31T02:02:52.696Z","1.1.1-canary-d67a93d-1640916124934":"2021-12-31T02:02:59.311Z","1.1.1-canary-d67a93d-1641175399440":"2022-01-03T02:04:14.428Z","1.1.1-canary-d67a93d-1641348218942":"2022-01-05T02:05:27.574Z","1.1.1-canary-d67a93d-1641348219165":"2022-01-05T02:05:34.153Z","1.1.1-canary-f39ec38-1641482194561":"2022-01-06T15:17:59.998Z","1.1.1-canary-f39ec38-1641482193379":"2022-01-06T15:18:09.517Z","1.1.1-canary-f39ec38-1641482256591":"2022-01-06T15:18:21.932Z","1.1.1-canary-f39ec38-1641482256234":"2022-01-06T15:19:04.324Z","1.1.1-canary-f39ec38-1641482261217":"2022-01-06T15:19:28.933Z","1.1.1-canary-10271fc-1643709774650":"2022-02-01T10:03:42.385Z","1.1.1-canary-10271fc-1643709779366":"2022-02-01T10:03:48.668Z","1.1.1-canary-10271fc-1643709792622":"2022-02-01T10:04:09.953Z","1.1.1-canary-10271fc-1643709821001":"2022-02-01T10:04:27.048Z","1.1.1-canary-10271fc-1643709824511":"2022-02-01T10:04:38.399Z","1.1.1-canary-10271fc-1643709797463":"2022-02-01T10:05:05.357Z","1.1.1-canary-76b1459-1644906996486":"2022-02-15T06:40:04.384Z","1.1.1-canary-76b1459-1644906992232":"2022-02-15T06:40:13.074Z","1.1.1-canary-76b1459-1644907185928":"2022-02-15T06:40:32.216Z","1.1.1-canary-76b1459-1644907063756":"2022-02-15T06:42:10.725Z","1.1.1-canary-76b1459-1644907132861":"2022-02-15T06:43:02.671Z","1.1.1-canary-0adfe8d-1644907190688":"2022-02-15T06:43:09.805Z","1.1.1-canary-0c81dee-1644909277662":"2022-02-15T07:16:59.434Z","1.1.1-canary-0c81dee-1644909341275":"2022-02-15T07:18:05.363Z","1.1.1-canary-0c81dee-1644909349548":"2022-02-15T07:19:05.328Z","1.1.1-canary-08d62d2-1644909464446":"2022-02-15T07:19:11.326Z","1.1.1-canary-08d62d2-1644909528605":"2022-02-15T07:19:59.590Z","1.1.1-canary-08d62d2-1644909527325":"2022-02-15T07:20:06.929Z","1.1.1-canary-08d62d2-1646128890920":"2022-03-01T10:02:14.054Z","1.1.1-canary-08d62d2-1646128922118":"2022-03-01T10:02:51.640Z","1.1.1-canary-08d62d2-1646128924634":"2022-03-01T10:03:02.109Z","1.1.1-canary-08d62d2-1646128993154":"2022-03-01T10:04:08.400Z","1.1.1-canary-08d62d2-1646129005584":"2022-03-01T10:04:21.472Z","1.1.1-canary-08d62d2-1646129026963":"2022-03-01T10:04:34.147Z","1.1.1-canary-08d62d2-1646129008721":"2022-03-01T10:05:25.476Z","1.1.1-canary-08d62d2-1648344645750":"2022-03-27T01:31:27.245Z","1.1.1-canary-08d62d2-1648344650694":"2022-03-27T01:31:42.488Z","1.1.1-canary-08d62d2-1648807400819":"2022-04-01T10:04:12.151Z","1.1.1-canary-08d62d2-1648807383097":"2022-04-01T10:04:39.443Z","1.1.1-canary-08d62d2-1648807382208":"2022-04-01T10:04:55.463Z","1.1.1-canary-08d62d2-1651399292964":"2022-05-01T10:02:18.970Z","1.1.1-canary-08d62d2-1651399399898":"2022-05-01T10:04:01.416Z","1.1.1-canary-08d62d2-1651399436059":"2022-05-01T10:04:42.386Z","1.1.1-canary-08d62d2-1651399434032":"2022-05-01T10:04:48.473Z","1.1.1-canary-08d62d2-1651399452687":"2022-05-01T10:05:05.740Z","1.1.1-canary-08d62d2-1651399454564":"2022-05-01T10:05:12.574Z","1.1.1-canary-08d62d2-1654080673706":"2022-06-01T10:52:03.303Z","1.1.1-canary-08d62d2-1654080688858":"2022-06-01T10:52:11.553Z","1.1.1-canary-08d62d2-1654080695183":"2022-06-01T10:52:24.223Z","1.1.1-canary-08d62d2-1654080739809":"2022-06-01T10:53:12.853Z","1.1.1-canary-08d62d2-1654080746531":"2022-06-01T10:53:18.800Z","1.1.1-canary-08d62d2-1656669712655":"2022-07-01T10:03:02.949Z","1.1.1-canary-08d62d2-1656669712623":"2022-07-01T10:03:12.892Z","1.1.1-canary-08d62d2-1656669725600":"2022-07-01T10:03:23.326Z","1.1.1-canary-08d62d2-1656669728078":"2022-07-01T10:03:29.648Z","1.1.1-canary-08d62d2-1656669811670":"2022-07-01T10:04:42.154Z","1.1.1-canary-08d62d2-1656669823295":"2022-07-01T10:04:52.709Z","1.1.1-canary-08d62d2-1658281564132":"2022-07-20T01:47:05.333Z","1.1.1-canary-08d62d2-1658281566112":"2022-07-20T01:47:54.731Z","1.1.1-canary-08d62d2-1659348085470":"2022-08-01T10:02:15.801Z","1.1.1-canary-08d62d2-1659348081554":"2022-08-01T10:02:47.184Z","1.1.1-canary-08d62d2-1659348162304":"2022-08-01T10:03:40.200Z","1.1.1-canary-08d62d2-1659348188312":"2022-08-01T10:03:55.040Z","1.1.1-canary-08d62d2-1659348187111":"2022-08-01T10:04:06.675Z","1.1.1-canary-08d62d2-1662026514683":"2022-09-01T10:02:50.054Z","1.1.1-canary-08d62d2-1662026564408":"2022-09-01T10:03:34.685Z","1.1.1-canary-08d62d2-1662026567494":"2022-09-01T10:03:48.336Z","1.1.1-canary-08d62d2-1662026600008":"2022-09-01T10:04:02.031Z","1.1.1-canary-08d62d2-1662026600440":"2022-09-01T10:04:08.889Z","1.1.1-canary-08d62d2-1662026583829":"2022-09-01T10:04:55.944Z","1.1.1-canary-08d62d2-1664618478727":"2022-10-01T10:02:05.607Z","1.1.1-canary-08d62d2-1664618502429":"2022-10-01T10:02:21.651Z","1.1.1-canary-08d62d2-1664618514891":"2022-10-01T10:02:43.027Z","1.1.1-canary-08d62d2-1664618519286":"2022-10-01T10:02:54.668Z","1.1.1-canary-08d62d2-1664618506651":"2022-10-01T10:03:30.214Z","1.1.1-canary-08d62d2-1667296909419":"2022-11-01T10:02:34.216Z","1.1.1-canary-08d62d2-1667296908891":"2022-11-01T10:02:41.262Z","1.1.1-canary-08d62d2-1667296959258":"2022-11-01T10:03:22.760Z","1.1.1-canary-08d62d2-1667296963164":"2022-11-01T10:03:37.599Z","1.1.1-canary-08d62d2-1667296977305":"2022-11-01T10:03:51.332Z","1.1.1-canary-08d62d2-1669888867650":"2022-12-01T10:01:51.238Z","1.1.1-canary-08d62d2-1669888874011":"2022-12-01T10:02:06.946Z","1.1.1-canary-08d62d2-1669888930734":"2022-12-01T10:02:52.375Z","1.1.1-canary-08d62d2-1669888930533":"2022-12-01T10:03:00.877Z","1.1.1-canary-08d62d2-1669888962006":"2022-12-01T10:03:24.107Z","1.1.1-canary-08d62d2-1672567249462":"2023-01-01T10:01:30.430Z","1.1.1-canary-08d62d2-1672567251540":"2023-01-01T10:01:43.236Z","1.1.1-canary-08d62d2-1672567390401":"2023-01-01T10:04:20.529Z","1.1.1-canary-08d62d2-1672567369746":"2023-01-01T10:04:33.680Z","1.1.1-canary-08d62d2-1672567389564":"2023-01-01T10:05:41.548Z","1.1.1-canary-08d62d2-1672567433421":"2023-01-01T10:07:05.263Z","1.1.1-canary-08d62d2-1672608188846":"2023-01-01T21:23:51.760Z","1.1.1-canary-08d62d2-1672608187797":"2023-01-01T21:23:58.115Z","1.1.1-canary-08d62d2-1673120755098":"2023-01-07T19:46:38.043Z","1.1.1-canary-08d62d2-1673120756019":"2023-01-07T19:46:47.020Z","1.1.1-canary-08d62d2-1675245718232":"2023-02-01T10:02:41.267Z","1.1.1-canary-08d62d2-1675245719544":"2023-02-01T10:02:50.570Z","1.1.1-canary-08d62d2-1675245752989":"2023-02-01T10:03:18.475Z","1.1.1-canary-08d62d2-1675245753523":"2023-02-01T10:03:33.922Z","1.1.1-canary-08d62d2-1675246016133":"2023-02-01T10:07:38.817Z","1.1.1-canary-08d62d2-1675246015945":"2023-02-01T10:07:46.019Z","1.1.1-canary-08d62d2-1677668266932":"2023-03-01T10:58:31.217Z","1.1.1-canary-08d62d2-1677668371867":"2023-03-01T11:00:13.056Z","1.1.1-canary-08d62d2-1677988516446":"2023-03-05T03:55:55.075Z","1.1.1-canary-08d62d2-1680346625012":"2023-04-01T10:57:46.285Z","1.1.1-canary-08d62d2-1680346697411":"2023-04-01T10:58:56.562Z","1.1.1-canary-08d62d2-1680346698641":"2023-04-01T10:59:01.464Z"},"bugs":{"url":"https://github.com/iadvize/store-library/issues"},"author":{"name":"iAdvize developers"},"license":"MIT","homepage":"https://github.com/iadvize/store-library#readme","keywords":["iAdvize"],"repository":{"url":"git+https://github.com/iadvize/store-library.git","type":"git"},"description":"Store library","maintainers":[{"email":"david.bonnemaison@iadvize.com","name":"davidiadvize"},{"email":"npm-iadvize-oss@iadvize.com","name":"iadvize-bot"},{"email":"jules.trehorel@iadvize.com","name":"jules.trehorel"},{"email":"simon.liotier@iadvize.com","name":"simon.liotier.iadvize"},{"email":"etienne.rouillard@iadvize.com","name":"etienne.rouillard.iadvize"},{"email":"ludovic.dupont29@gmail.com","name":"korial29"}],"readme":"","readmeFilename":""}